diff --git a/application/index/controller/Admin.php b/application/index/controller/Admin.php index e5f16bb4..95fbb7d8 100644 --- a/application/index/controller/Admin.php +++ b/application/index/controller/Admin.php @@ -451,6 +451,12 @@ class Admin extends Controller{ ]); } + public function PolicyAddOnedrive(){ + return view('add_policy_onedrive', [ + 'options' => $this->siteOptions, + ]); + } + public function About(){ $verison = json_decode(file_get_contents(ROOT_PATH . "application/version.json"),true); return view('about', [ @@ -524,9 +530,5 @@ class Admin extends Controller{ $code = input("get.code"); $this->adminObj->oneDriveCalllback($code); } - - public function uploadTest(){ - $this->adminObj->oneDriveTest(); - } } diff --git a/application/index/model/AdminHandler.php b/application/index/model/AdminHandler.php index 730a75ce..0fac613f 100644 --- a/application/index/model/AdminHandler.php +++ b/application/index/model/AdminHandler.php @@ -147,7 +147,7 @@ class AdminHandler extends Model{ } catch (Exception $e) { return ["error"=>1,"msg"=>$e->getMessage()]; } - return ["error"=>200,"msg"=>"设置已保存"]; + return ["error"=>200,"msg"=>"设置已保存","id"=>Db::name('policy')->getLastInsID()]; } public function editPolicy($options){ @@ -724,7 +724,7 @@ class AdminHandler extends Model{ 'offline_access', 'files.readwrite.all', ], Option::getValue("siteURL")."Admin/oneDriveCalllback"); - echo "继续绑定账号"; + echo "正在跳转至Onedrive账号授权页面,如果没有跳转,请点击这里。"; Db::name("policy")->where("id",$policyId)->update([ "sk" => json_encode($onedrive->getState()), @@ -754,6 +754,7 @@ class AdminHandler extends Model{ Db::name("policy")->where("id",$policyId)->update([ "sk" => json_encode($onedrive->getState()), ]); + echo ""; } } diff --git a/application/index/view/admin/add_policy.html b/application/index/view/admin/add_policy.html index b2cc41e2..5dedd067 100644 --- a/application/index/view/admin/add_policy.html +++ b/application/index/view/admin/add_policy.html @@ -82,6 +82,16 @@ +
+
+ Card image cap +
+
Onedrive 中转
+

支持 Onedrive Bussiness 和个人版。配置说明

+ 添加 +
+
+
diff --git a/application/index/view/admin/add_policy_onedrive.html b/application/index/view/admin/add_policy_onedrive.html new file mode 100644 index 00000000..56e397b7 --- /dev/null +++ b/application/index/view/admin/add_policy_onedrive.html @@ -0,0 +1,155 @@ +{extend name="header_admin" /} +{block name="title"}添加上传策略- {$options.siteName}{/block} +{block name="content"} +
+
+ + + + +
+
+

添加上传策略

+
+ + +
+
+ 添加Onedrive上传策略 +
+
+
+ +
+
+ +
+
+
上传策略的名称,用于区别不同策略
+
+ +
+
+ +
+
+
点击这里获取下一步要用到的应用机密和此处的应用ID
+
+ + + + + + +
+
+ +
+
+ +
+
同上一项一起获取
+
+ +
+
+ +
+
+ +
+ + + +
+
+
允许上传的单个文件的最大尺寸
+
+ +
+
+ +
+
+ + +     + + +
+
是否对存储的文件自动重命名。推荐开启,重命名不会影响用户端文件名展示,开启后可以避免文件重名
+
+
+
+ +
+
+ +
+
你可以使用变量对照表中的字段填写
+
+
+
+ +
+
+
+ + Onedrive根目录 + +
+ +
+
文件存放的目录,你可以使用目录变量对照表中的字段填写
+
+ + +
+
+
+
+
+

+
+
+
+ +
+ + + + +
+
+
+ + +
+ +
+ +{/block} +{block name="js"} + +{/block} \ No newline at end of file diff --git a/application/index/view/admin/edit_policy.html b/application/index/view/admin/edit_policy.html index 3078c954..29266716 100644 --- a/application/index/view/admin/edit_policy.html +++ b/application/index/view/admin/edit_policy.html @@ -928,6 +928,128 @@ {/case} + {case value="onedrive"} + +
+
+ 添加Onedrive上传策略 +
+
+
+ +
+
+ +
+
+
上传策略的名称,用于区别不同策略
+
+ +
+
+ +
+
+
点击这里获取下一步要用到的应用机密和此处的应用ID
+
+ + +
+
+ +
+
+ +
+
同上一项一起获取
+
+ +
+
+ +
+
+ +
+ + + +
+
+
允许上传的单个文件的最大尺寸
+
+ +
+
+ +
+
+ {eq name="$policy.autoname" value="1"} + + +     + + + {else/} + + +     + + + {/eq} +
+
是否对存储的文件自动重命名。推荐开启,重命名不会影响用户端文件名展示,开启后可以避免文件重名
+
+
+
+ +
+
+ +
+
你可以使用变量对照表中的字段填写
+
+
+
+ +
+
+
+ + Onedrive根目录/ + +
+ +
+
文件存放的目录,你可以使用目录变量对照表中的字段填写
+
+ + + +
+
+ +
+ {/case} {/switch}
diff --git a/application/index/view/admin/policy_list.html b/application/index/view/admin/policy_list.html index 9ad84000..f02c990d 100644 --- a/application/index/view/admin/policy_list.html +++ b/application/index/view/admin/policy_list.html @@ -45,6 +45,9 @@ + @@ -82,6 +85,7 @@ {case value="upyun"}又拍云{/case} {case value="s3"}Amazon S3{/case} {case value="remote"}远程{/case} + {case value="onedrive"}Onedrive{/case} {default /}其他 {/switch} diff --git a/static/img/onedrive.png b/static/img/onedrive.png new file mode 100644 index 00000000..a1116adb Binary files /dev/null and b/static/img/onedrive.png differ diff --git a/static/js/admin/add_policy.js b/static/js/admin/add_policy.js index 2c13bd90..33c8df57 100644 --- a/static/js/admin/add_policy.js +++ b/static/js/admin/add_policy.js @@ -56,6 +56,24 @@ $("#localPolicy").submit(function() { }); return false; }) +$("#onedrivePolicy").submit(function() { + $("#savePolicy").attr("disabled", "true"); + $.post("/Admin/SavePolicy", + $("#onedrivePolicy").serialize() + , function(data) { + if (data.error == "1") { + toastr["warning"](data.msg); + $("#savePolicy").removeAttr("disabled"); + } else if (data.error == "200") { + toastr["success"]("上传策略已添加"); + location.href = "/Admin/UpdateOnedriveToken?id="+data.id; + }else{ + toastr["warning"]("未知错误"); + $("#savePolicy").removeAttr("disabled"); + } + }); + return false; +}) $("#qiniuPolicy").submit(function() { $("#saveQiniu").attr("disabled", "true"); $.post("/Admin/SavePolicy",