- 修复上个版本七牛云、又拍云图片无法管理的bug
- 增加上传默认文件夹功能
This commit is contained in:
@@ -15,29 +15,32 @@ class Users extends Validate
|
||||
protected $rule = [
|
||||
'username' => 'require|max:15|unique:users',
|
||||
'nickname' => 'max:15',
|
||||
'default_folder' => 'max:30|chsAlphaNum',
|
||||
'email' => 'require|email|max:50|unique:users',
|
||||
'password' => 'require|confirm',
|
||||
'captcha' => 'require|captcha|token',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'username.require' => '用户名不能为空',
|
||||
'username.max' => '用户名字符长度超出',
|
||||
'username.unique' => '用户名已存在,请更换',
|
||||
'nickname.max' => '昵称字符长度超出',
|
||||
'email.require' => '邮箱不能为空',
|
||||
'email.email' => '邮箱格式不正确',
|
||||
'email.max' => '邮箱字符长度超出',
|
||||
'email.unique' => '邮箱已存在',
|
||||
'password.require' => '密码不能为空',
|
||||
'password.confirm' => '两次输入的密码不一致',
|
||||
'captcha.require' => '请输入验证码',
|
||||
'captcha.captcha' => '验证码错误',
|
||||
'username.require' => '用户名不能为空',
|
||||
'username.max' => '用户名字符长度超出',
|
||||
'username.unique' => '用户名已存在,请更换',
|
||||
'nickname.max' => '昵称字符长度超出',
|
||||
'default_folder.max' => '默认上传文件夹名称长度超出',
|
||||
'default_folder.chsAlphaNum'=> '默认上传文件夹名称只能是汉字、字母和数字',
|
||||
'email.require' => '邮箱不能为空',
|
||||
'email.email' => '邮箱格式不正确',
|
||||
'email.max' => '邮箱字符长度超出',
|
||||
'email.unique' => '邮箱已存在',
|
||||
'password.require' => '密码不能为空',
|
||||
'password.confirm' => '两次输入的密码不一致',
|
||||
'captcha.require' => '请输入验证码',
|
||||
'captcha.captcha' => '验证码错误',
|
||||
];
|
||||
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['nickname', 'password'])->remove('password', 'require');
|
||||
return $this->only(['nickname', 'default_folder', 'password'])->remove('password', 'require');
|
||||
}
|
||||
|
||||
public function sceneAdminEdit()
|
||||
|
||||
@@ -217,8 +217,11 @@ EOT;
|
||||
// 新建表字段
|
||||
$tableFields = [
|
||||
'lsky_images' => [
|
||||
'folder_id' => 'ALTER TABLE `lsky_images` ADD `folder_id` INT NOT NULL DEFAULT \'0\' COMMENT \'文件夹ID\' AFTER `user_id`;'
|
||||
]
|
||||
'folder_id' => "ALTER TABLE `lsky_images` ADD `folder_id` INT NOT NULL DEFAULT '0' COMMENT '文件夹ID' AFTER `user_id`;"
|
||||
],
|
||||
'lsky_users' => [
|
||||
'default_folder' => "ALTER TABLE `lsky_users` ADD `default_folder` VARCHAR(32) DEFAULT NULL COMMENT '默认上传文件夹' AFTER `quota`;"
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($tableFields as $table => $fields) {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
namespace app\index\controller;
|
||||
|
||||
use app\common\model\Folders;
|
||||
use app\common\model\Images;
|
||||
use app\common\model\Users;
|
||||
use GuzzleHttp\Client;
|
||||
@@ -77,7 +78,7 @@ class Upload extends Base
|
||||
if (Config::get('app.app_debug')) {
|
||||
throw new Exception($strategy->getError());
|
||||
}
|
||||
throw new Exception('上传失败');
|
||||
throw new Exception('上传失败,请检查策略配置是否正确!');
|
||||
}
|
||||
|
||||
$cdnDomain = $currentStrategy . '_cdn_domain';
|
||||
@@ -107,7 +108,7 @@ class Upload extends Base
|
||||
}
|
||||
}
|
||||
|
||||
if (!Images::create([
|
||||
$imageData = [
|
||||
'user_id' => $user ? $user->id : 0,
|
||||
'strategy' => $currentStrategy,
|
||||
'path' => dirname($pathname),
|
||||
@@ -117,7 +118,25 @@ class Upload extends Base
|
||||
'mime' => $mime,
|
||||
'sha1' => $sha1,
|
||||
'md5' => $md5
|
||||
])) {
|
||||
];
|
||||
|
||||
// 默认上传文件夹,暂只支持一级
|
||||
if ($this->user->default_folder) {
|
||||
$folderId = $this->user->folders()->where('name', $this->user->default_folder)->value('id');
|
||||
if (!$folderId) {
|
||||
if (!$folderId = $this->user->folders()->insertGetId([
|
||||
'user_id' => $this->user->id,
|
||||
'parent_id' => 0,
|
||||
'name' => $this->user->default_folder
|
||||
])) {
|
||||
throw new Exception('文件夹创建失败!');
|
||||
}
|
||||
}
|
||||
|
||||
$imageData['folder_id'] = $folderId;
|
||||
}
|
||||
|
||||
if (!Images::create($imageData)) {
|
||||
$strategy->delete($pathname);
|
||||
throw new Exception('图片数据保存失败');
|
||||
}
|
||||
|
||||
@@ -19,6 +19,10 @@
|
||||
<label class="mdui-textfield-label">昵称</label>
|
||||
<input class="mdui-textfield-input" type="text" name="nickname" value="{$user.nickname}" maxlength="15" placeholder="昵称"/>
|
||||
</div>
|
||||
<div class="mdui-textfield">
|
||||
<label class="mdui-textfield-label">默认上传文件夹</label>
|
||||
<input class="mdui-textfield-input" type="text" name="default_folder" value="{$user.default_folder}" maxlength="30" placeholder="默认上传文件夹名(不存在上传时自动创建)"/>
|
||||
</div>
|
||||
<div class="mdui-textfield">
|
||||
<label class="mdui-textfield-label">原密码</label>
|
||||
<input class="mdui-textfield-input" type="password" name="password_old" placeholder="原密码,不修改请留空"/>
|
||||
|
||||
+1
-1
@@ -205,4 +205,4 @@ ALTER TABLE `lsky_users`
|
||||
-- 使用表AUTO_INCREMENT `lsky_folders`
|
||||
--
|
||||
ALTER TABLE `lsky_folders`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID', AUTO_INCREMENT=1;
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID', AUTO_INCREMENT=1;
|
||||
@@ -41,3 +41,8 @@ CREATE TABLE IF NOT EXISTS `lsky_folders` (
|
||||
`update_time` int(11) DEFAULT NULL COMMENT '更新时间',
|
||||
`create_time` int(11) DEFAULT NULL COMMENT '添加时间'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='文件夹表';
|
||||
|
||||
-- v1.4.2
|
||||
UPDATE `lsky_config` SET `value` = '1.4.2' WHERE `lsky_config`.`name` = 'system_version';
|
||||
UPDATE `lsky`.`lsky_images` SET `strategy` = 'uss' WHERE `lsky_images`.`strategy` = 'upyun';
|
||||
UPDATE `lsky`.`lsky_images` SET `strategy` = 'kodo' WHERE `lsky_images`.`strategy` = 'qiniu';
|
||||
Reference in New Issue
Block a user