This commit is contained in:
molong
2022-10-18 21:09:17 +08:00
parent 96319f0898
commit f8927e3193
15 changed files with 2041 additions and 146 deletions

View File

@@ -16,4 +16,8 @@ class Request extends \think\Request{
public function auth(){
return app()->make(UsersService::class)->getUserAuth($this->user['uid']);
}
public function static(){
return $this->domain() . '/storage/';
}
}

View File

@@ -29,6 +29,8 @@ class Index extends Base{
}
public function member(){
// $output = $this->app->console->call('migrate:run');
// return $output->fetch();
// $map = [];
// $member = Member::where($map)->select();
// $save = [];

View File

@@ -9,6 +9,7 @@
namespace app\controller\system;
use app\controller\Base;
use app\validate\File as Files;
use app\services\system\DictionaryService;
/**
@@ -16,4 +17,54 @@ use app\services\system\DictionaryService;
*/
class File extends Base{
/**
* @title 上传
*
* @return void
*/
public function upload(){
$file = request()->file('file');
$type = request()->param('type', 'images');
try {
$this->data['data'] = $this->$type($file, $type);
} catch (\think\Exception $e) {
$this->data['code'] = 0;
$this->data['message'] = $e->getMessage();
}
return $this->data;
}
/**
* @title 用户头像上传
*
* @return void
*/
protected function avatar($file, $type){
try {
validate(Files::class)->check(['avatar' => $file]);
// 上传到本地服务器
$savename = \think\facade\Filesystem::putFile( $type, $file);
return ['src' => request()->static() . $savename, 'fileName' => ''];
} catch (\think\exception\ValidateException $e) {
throw new \think\Exception($e->getMessage(), 1);
}
}
/**
* @title 图片上传
*
* @return void
*/
protected function images($file, $type){
try {
validate(Files::class)->check(['image' => $file]);
// 上传到本地服务器
$savename = \think\facade\Filesystem::putFile( $type, $file);
return ['src' => request()->static() . $savename, 'fileName' => ''];
} catch (\think\exception\ValidateException $e) {
throw new \think\Exception($e->getMessage(), 1);
}
}
}

25
app/validate/File.php Normal file
View File

@@ -0,0 +1,25 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\validate;
use think\Validate;
class File extends Validate{
protected $rule = [
'avatar' => 'fileSize:102400|fileExt:jpg,png',
'image' => 'fileSize:204800|fileExt:jpg,jpeg,png,webp',
'file' => 'fileSize:1024 * 1000|fileExt:doc,xls,zip,rar'
];
protected $message = [
'avatar.fileSize' => '图片不大于1M',
'avatar.fileExt' => '头像后缀不正确',
'avatar.image' => '头像尺寸不正确',
];
}

View File

@@ -25,7 +25,10 @@
"topthink/think-orm": "^2.0",
"xiaodi/think-jwt": "^2.0",
"sent/tree": "^1.0",
"xin/helper": "1.0"
"xin/helper": "1.0",
"topthink/think-migration": "^3.0",
"thans/thinkphp-filesystem-cloud": "^1.0",
"yunwuxin/think-cron": "^3.0"
},
"require-dev": {
"symfony/var-dumper": "^4.2",

2042
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -5,5 +5,6 @@
return [
// 指令定义
'commands' => [
'schedule:run'=>\app\command\Schedule::class,
],
];

View File

@@ -20,5 +20,33 @@ return [
'visibility' => 'public',
],
// 更多的磁盘配置信息
'aliyun' => [
'type' => 'aliyun',
'accessId' => '******',
'accessSecret' => '******',
'bucket' => 'bucket',
'endpoint' => 'oss-cn-hongkong.aliyuncs.com',
'url' => 'http://oss-cn-hongkong.aliyuncs.com',//不要斜杠结尾此处为URL地址域名。
],
'qiniu' => [
'type' => 'qiniu',
'accessKey' => '******',
'secretKey' => '******',
'bucket' => 'bucket',
'url' => '',//不要斜杠结尾此处为URL地址域名。
],
'qcloud' => [
'type' => 'qcloud',
'region' => '***', //bucket 所属区域 英文
'appId' => '***', // 域名中数字部分
'secretId' => '***',
'secretKey' => '***',
'bucket' => '***',
'timeout' => 60,
'connect_timeout' => 60,
'cdn' => '您的 CDN 域名',
'scheme' => 'https',
'read_from_cdn' => false,
]
],
];

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -3,7 +3,7 @@ import http from "@/utils/request"
export default {
upload: {
url: `${config.API_URL}file/upload`,
url: `${config.API_URL}system/file/upload`,
name: "文件上传",
post: async function(data, config={}){
return await http.post(this.url, data, config);

View File

@@ -12,7 +12,7 @@ const DEFAULT_CONFIG = {
CORE_VER: "1.6.6",
//接口地址
API_URL: "http://211.149.201.113:88/",
API_URL: "http://127.0.0.1:8000/",
//请求超时
TIMEOUT: 10000,

View File

@@ -47,7 +47,7 @@
</div>
<el-dropdown class="user panel-item" trigger="click" @command="handleUser">
<div class="user-avatar">
<el-avatar :size="30">{{ userNameF }}</el-avatar>
<el-avatar :src="userInfo.avatar" :size="30">{{ userNameF }}</el-avatar>
<label>{{ userName }}</label>
<el-icon class="el-icon--right"><el-icon-arrow-down /></el-icon>
</div>
@@ -82,6 +82,7 @@
},
data(){
return {
userInfo: {},
userName: "",
userNameF: "",
searchVisible: false,
@@ -119,8 +120,8 @@
}
},
created() {
var userInfo = this.$TOOL.data.get("USER_INFO");
this.userName = userInfo.username;
this.userInfo = this.$TOOL.data.get("USER_INFO");
this.userName = this.userInfo.username;
this.userNameF = this.userName.substring(0,1);
},
methods: {

View File

@@ -185,6 +185,7 @@
//表单注入数据
setData(data, pid){
this.form = data
this.form.sort = parseInt(this.form.sort);
this.form.apiList = data.apiList || []
this.form.parent_id = pid
}

View File

@@ -27,11 +27,11 @@
data(){
return {
pageLoading: true,
dashboard: '1'
dashboard: '0'
}
},
created(){
this.dashboard = this.$TOOL.data.get("USER_INFO").dashboard || '1';
this.dashboard = this.$TOOL.data.get("USER_INFO").dashboard || '0';
},
mounted(){

View File

@@ -2,7 +2,7 @@
<el-card shadow="never" header="个人信息">
<el-form ref="form" :rules="rules" :model="form" label-width="120px" style="margin-top:20px;">
<el-form-item label="头像">
<sc-upload v-model="form.avatar" title="头像上传" :cropper="true" :compress="1" :aspectRatio="1/1"></sc-upload>
<sc-upload v-model="form.avatar" :data="{type: 'avatar'}" title="头像上传" :cropper="true" :compress="1" :aspectRatio="1/1"></sc-upload>
</el-form-item>
<el-form-item label="账号">
<el-input v-model="form.username" disabled></el-input>
@@ -36,6 +36,7 @@ export default {
data() {
return {
form: {
avatar: '',
username: "admin",
nickname: "Sakuya",
email: "",
@@ -59,7 +60,7 @@ export default {
async getUserInfo(){
let res = await this.$API.user.userinfo.get();
if(res.code == 1){
this.form = {username: res.data.username, nickname: res.data.nickname, email: res.data.email, sex: res.data.sex, about: res.data.about, uid: res.data.uid}
this.form = {avatar: res.data.avatar,username: res.data.username, nickname: res.data.nickname, email: res.data.email, sex: res.data.sex, about: res.data.about, uid: res.data.uid}
}
},
async submit(){