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
+4
View File
@@ -16,4 +16,8 @@ class Request extends \think\Request{
public function auth(){ public function auth(){
return app()->make(UsersService::class)->getUserAuth($this->user['uid']); return app()->make(UsersService::class)->getUserAuth($this->user['uid']);
} }
public function static(){
return $this->domain() . '/storage/';
}
} }
+2
View File
@@ -29,6 +29,8 @@ class Index extends Base{
} }
public function member(){ public function member(){
// $output = $this->app->console->call('migrate:run');
// return $output->fetch();
// $map = []; // $map = [];
// $member = Member::where($map)->select(); // $member = Member::where($map)->select();
// $save = []; // $save = [];
+51
View File
@@ -9,6 +9,7 @@
namespace app\controller\system; namespace app\controller\system;
use app\controller\Base; use app\controller\Base;
use app\validate\File as Files;
use app\services\system\DictionaryService; use app\services\system\DictionaryService;
/** /**
@@ -16,4 +17,54 @@ use app\services\system\DictionaryService;
*/ */
class File extends Base{ 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
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' => '头像尺寸不正确',
];
}
+4 -1
View File
@@ -25,7 +25,10 @@
"topthink/think-orm": "^2.0", "topthink/think-orm": "^2.0",
"xiaodi/think-jwt": "^2.0", "xiaodi/think-jwt": "^2.0",
"sent/tree": "^1.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": { "require-dev": {
"symfony/var-dumper": "^4.2", "symfony/var-dumper": "^4.2",
Generated
+1910 -132
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -5,5 +5,6 @@
return [ return [
// 指令定义 // 指令定义
'commands' => [ 'commands' => [
'schedule:run'=>\app\command\Schedule::class,
], ],
]; ];
+28
View File
@@ -20,5 +20,33 @@ return [
'visibility' => 'public', '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

+1 -1
View File
@@ -3,7 +3,7 @@ import http from "@/utils/request"
export default { export default {
upload: { upload: {
url: `${config.API_URL}file/upload`, url: `${config.API_URL}system/file/upload`,
name: "文件上传", name: "文件上传",
post: async function(data, config={}){ post: async function(data, config={}){
return await http.post(this.url, data, config); return await http.post(this.url, data, config);
+1 -1
View File
@@ -12,7 +12,7 @@ const DEFAULT_CONFIG = {
CORE_VER: "1.6.6", CORE_VER: "1.6.6",
//接口地址 //接口地址
API_URL: "http://211.149.201.113:88/", API_URL: "http://127.0.0.1:8000/",
//请求超时 //请求超时
TIMEOUT: 10000, TIMEOUT: 10000,
+4 -3
View File
@@ -47,7 +47,7 @@
</div> </div>
<el-dropdown class="user panel-item" trigger="click" @command="handleUser"> <el-dropdown class="user panel-item" trigger="click" @command="handleUser">
<div class="user-avatar"> <div class="user-avatar">
<el-avatar :size="30">{{ userNameF }}</el-avatar> <el-avatar :src="userInfo.avatar" :size="30">{{ userNameF }}</el-avatar>
<label>{{ userName }}</label> <label>{{ userName }}</label>
<el-icon class="el-icon--right"><el-icon-arrow-down /></el-icon> <el-icon class="el-icon--right"><el-icon-arrow-down /></el-icon>
</div> </div>
@@ -82,6 +82,7 @@
}, },
data(){ data(){
return { return {
userInfo: {},
userName: "", userName: "",
userNameF: "", userNameF: "",
searchVisible: false, searchVisible: false,
@@ -119,8 +120,8 @@
} }
}, },
created() { created() {
var userInfo = this.$TOOL.data.get("USER_INFO"); this.userInfo = this.$TOOL.data.get("USER_INFO");
this.userName = userInfo.username; this.userName = this.userInfo.username;
this.userNameF = this.userName.substring(0,1); this.userNameF = this.userName.substring(0,1);
}, },
methods: { methods: {
+1
View File
@@ -185,6 +185,7 @@
//表单注入数据 //表单注入数据
setData(data, pid){ setData(data, pid){
this.form = data this.form = data
this.form.sort = parseInt(this.form.sort);
this.form.apiList = data.apiList || [] this.form.apiList = data.apiList || []
this.form.parent_id = pid this.form.parent_id = pid
} }
+2 -2
View File
@@ -27,11 +27,11 @@
data(){ data(){
return { return {
pageLoading: true, pageLoading: true,
dashboard: '1' dashboard: '0'
} }
}, },
created(){ created(){
this.dashboard = this.$TOOL.data.get("USER_INFO").dashboard || '1'; this.dashboard = this.$TOOL.data.get("USER_INFO").dashboard || '0';
}, },
mounted(){ mounted(){
+3 -2
View File
@@ -2,7 +2,7 @@
<el-card shadow="never" header="个人信息"> <el-card shadow="never" header="个人信息">
<el-form ref="form" :rules="rules" :model="form" label-width="120px" style="margin-top:20px;"> <el-form ref="form" :rules="rules" :model="form" label-width="120px" style="margin-top:20px;">
<el-form-item label="头像"> <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>
<el-form-item label="账号"> <el-form-item label="账号">
<el-input v-model="form.username" disabled></el-input> <el-input v-model="form.username" disabled></el-input>
@@ -36,6 +36,7 @@ export default {
data() { data() {
return { return {
form: { form: {
avatar: '',
username: "admin", username: "admin",
nickname: "Sakuya", nickname: "Sakuya",
email: "", email: "",
@@ -59,7 +60,7 @@ export default {
async getUserInfo(){ async getUserInfo(){
let res = await this.$API.user.userinfo.get(); let res = await this.$API.user.userinfo.get();
if(res.code == 1){ 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(){ async submit(){