Skip to content
Permalink
Browse files

Feat: Color option in dashboard

  • Loading branch information...
HFO4 committed Mar 17, 2019
1 parent 88fac85 commit 7a530f5d582b06023f411e48fb0b8f94576fcffa
@@ -102,6 +102,15 @@ public function SettingReg(){
]);
}
public function Color(){
$options = Option::getValues(["basic"]);
return view('color', [
'options' => $this->siteOptions,
'optionsForSet' => $options,
'colors'=> \json_decode($options["themes"],true)
]);
}
public function Theme(){
$fileName=input("?param.name") ? input("param.name") : "error";
$dir = ROOT_PATH."application/index/view/";
@@ -141,6 +150,10 @@ public function SaveThemeFile(){
return $this->adminObj->saveThemeFile(input('post.'));
}
public function SaveColorSetting(){
return $this->adminObj->saveColorSetting(input('post.'));
}
public function SettingMail(){
return view('mail_setting', [
'options' => $this->siteOptions,
@@ -344,7 +357,7 @@ public function DeleteShare(){
}
public function DeleteShareMultiple(){
return $this->adminObj->deleteShare(json_decode(input('post.id'),true));
return $this->adminObj->deleteShare(\json_decode(input('post.id'),true));

This comment has been minimized.

Copy link
@kengwang

kengwang Mar 26, 2019

这个斜杠仍然没看懂

This comment has been minimized.

Copy link
@HFO4

HFO4 Mar 26, 2019

Author Member

之前命名空间有冲突,现在去掉也可以

}
public function DeleteMultiple(){
@@ -380,7 +393,7 @@ public function DeleteUser(){
}
public function DeleteUsers(){
$uidGroup = json_decode(input('post.id'),true);
$uidGroup = \json_decode(input('post.id'),true);
foreach ($uidGroup as $key => $value) {
$this->adminObj->deleteUser($value,$this->userObj->uid);
}
@@ -468,7 +481,7 @@ public function PolicyAddOnedrive(){
}
public function About(){
$verison = json_decode(file_get_contents(ROOT_PATH . "application/version.json"),true);
$verison = \json_decode(file_get_contents(ROOT_PATH . "application/version.json"),true);
return view('about', [
'options' => $this->siteOptions,
'programVersion' => $verison,
@@ -477,7 +490,7 @@ public function About(){
}
public function Purchase(){
$packData = json_decode(Option::getValue("pack_data"),true);
$packData = \json_decode(Option::getValue("pack_data"),true);
return view('purchase', [
'options' => $this->siteOptions,
'pack' => $packData,
@@ -494,7 +507,7 @@ public function Queue(){
}
public function PurchaseGroup(){
$groupData = json_decode(Option::getValue("group_sell_data"),true);
$groupData = \json_decode(Option::getValue("group_sell_data"),true);
foreach ($groupData as $key => $value) {
$groupData[$key]["group"] = Db::name("groups")->where("id",$value["goup_id"])->find();
}
@@ -25,7 +25,6 @@ public function Qiniu(){
public function Oss(){
ob_end_clean();
error_log("sadasdasdsadsasadasasdasdasd");
header('Content-Type: application/json');
$handllerObj = new CallbackHandler(file_get_contents("php://input"));
$handllerObj -> ossHandler(Request::instance()->header('Authorization'),Request::instance()->header('x-oss-pub-key-url'));
@@ -102,6 +102,37 @@ public function saveBasicSetting($options){
return $this->saveOptions($options);
}
public function saveColorSetting($options){
$colorOptions = [];
foreach ($options["color"] as $key => $value) {
$color = \json_decode($value,true);
$validate = ($color!==null)&&array_key_exists("palette",$color) &&
array_key_exists("common",$color["palette"]) &&
array_key_exists("black",$color["palette"]["common"]) &&
array_key_exists("white",$color["palette"]["common"]) &&
array_key_exists("background",$color["palette"]) &&
array_key_exists("primary",$color["palette"]) &&
array_key_exists("secondary",$color["palette"]) &&
array_key_exists("error",$color["palette"]) &&
array_key_exists("text",$color["palette"]) &&
array_key_exists("explorer",$color["palette"]) &&
array_key_exists("main",$color["palette"]["primary"]) &&
array_key_exists("main",$color["palette"]["secondary"]);
if(!$validate){
return ["error"=>1,"msg"=>"".($key+1)." 行配色方案格式有误"];
}
$colorOptions[$color["palette"]["primary"]["main"]] = $color;
}
if(!array_key_exists($options["header"],$colorOptions)){
return ["error"=>1,"msg"=>"".($key+1)." 默认配色不存在"];
}
$optionsForSet = [
"defaultTheme" => $options["header"],
"themes" => json_encode($colorOptions),
];
return $this->saveOptions($optionsForSet);
}
public function saveRegSetting($options){
foreach(["email_active","login_captcha","reg_captcha","forget_captcha"] as $key){
$options[$key] = array_key_exists($key,$options) ? $options[$key] : 0;
@@ -0,0 +1,98 @@
{extend name="header_admin" /}
{block name="title"}基础设置- {$options.siteName}{/block}
{block name="content"}
<div class="content-wrapper">
<div class="container-fluid">
<!-- Breadcrumbs-->
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="/Admin">管理面板</a>
</li>
<li class="breadcrumb-item active">配色方案</li>
</ol>

<!-- Area Chart Example-->
<div class="row">
<div class="col-12">
<h2>配色方案</h2>
<div class="alert alert-primary" role="alert">
<ul>
<li>你可以使用<a href="https://theme.cloudreve.org">Cloudreve配色工具</a>创建配色,并将生成的配置信息填写在下方;</li>
<li>主色调为不同配色的区分标识,请不要创建主色调相同的配色方案。</li>
</ul>
</div>
<div class="row">
<div class="col-md-9">
<form id="colorForm">
<div class="row form-setting">
<div class="col-md-1 form-label ">
<label for="colFormLabelSm" class="col-form-label col-form-label-sm">默认配色方案</label>
</div>
<div class="col-md-4"><select class="form-control" name="header">
{volist name="colors" id="theme"}
<option value="{$key}" {eq name="optionsForSet.defaultTheme" value="$key"}selected{/eq}>{$key}</option>
{/volist}

</select></div>
</div>
<div class="row form-setting">
<div class="col-md-1 form-label ">
<label for="colFormLabelSm" class="col-form-label col-form-label-sm">可选配色方案</label>
</div>
<div class="col-md-8">
<table class="table" id="colorTable">
<thead>
<tr>
<th scope="col">主色调</th>
<th scope="col">颜色配置</th>
</tr>
</thead>
<tbody>
{volist name="colors" id="theme"}
<tr>
<th scope="row" style="color:{$key}">{$key}
<br><button id="removeRow" type="button" data-action="removeRow" class="btn btn-default">删除</button>
</th>
<td><textarea class="form-control" rows="4" name="color[]">{:json_encode($theme)}</textarea></td>
</tr>
{/volist}

</tbody>
</table>
<div style="text-align:right;"><button id="addRow" type="button" class="btn btn-default">增加一行</button></div>

</div>
</div>
<div class="row form-setting">
<div class="col-md-1 form-label ">
</div>
<div class="col-md-4"> <button type="button" class="btn btn-primary" id="saveColor">保存设置</button></div>
<div class="col-md-4 option-des"> </div>
<br> <br>
</div>
</form>


<br><br>
</div>
<div class="col-md-3">
<div class="file_side">
<div class="nav flex-column nav-pills" id="v-pills-tab" role="tablist" aria-orientation="vertical">
</div>
</div>
</div>

</div>
</div>
</div>

<!-- Example DataTables Card-->
</div>
<!-- /.container-fluid-->
</div>
{/block}
{block name="js"}
<script src="/static/js/admin/color.js"></script>
<script type="text/javascript">
</script>
{/block}
@@ -1,4 +1,3 @@

<link rel="stylesheet" href="/static/css/error.css" />
</head>
<body data-ma-header="teal">
@@ -58,11 +58,19 @@
</li>
</ul>
</li>
<li class="nav-item" data-toggle="tooltip" data-placement="right" title="模板">
<a class="nav-link" href="/Admin/Theme">
<li class="nav-item" data-toggle="tooltip" data-placement="right" title="模板">
<a class="nav-link nav-link-collapse collapsed" data-toggle="collapse" href="#theme">
<i class="fa fa-fw fa-paint-brush"></i>
<span class="nav-link-text">模板</span>
</a>
<ul class="sidenav-second-level collapse" id="theme">
<li>
<a href="/Admin/Theme">模板</a>
</li>
<li>
<a href="/Admin/Color">配色方案</a>
</li>
</ul>
</li>
<li class="nav-item" data-toggle="tooltip" data-placement="right" title="文件">
<a class="nav-link" href="/Admin/Files">
@@ -0,0 +1,23 @@
$("#addRow").click(function(){
$("#colorTable tbody").append('<tr><td></td><td><textarea class="form-control" rows="4" name="color[]"></textarea></td></tr>');
})
$("[data-action='removeRow']").on("click",function(e){
$(this).parent().parent().remove();
});
$("#saveColor").click(function() {
$("#saveColor").attr("disabled", "true");
$.post("/Admin/SaveColorSetting",
$("#colorForm").serialize()
, function(data) {
if (data.error == "1") {
toastr["warning"](data.msg);
$("#saveColor").removeAttr("disabled");
} else if (data.error == "200") {
toastr["success"]("设置已保存");
$("#saveColor").removeAttr("disabled");
}else{
toastr["warning"]("未知错误");
$("#saveColor").removeAttr("disabled");
}
});
})

0 comments on commit 7a530f5

Please sign in to comment.
You can’t perform that action at this time.