mirror of https://github.com/helloxz/onenav.git
19 changed files with 585 additions and 36 deletions
@ -0,0 +1,101 @@
@@ -0,0 +1,101 @@
|
||||
<?php |
||||
|
||||
/** |
||||
* 首字母头像 |
||||
* @param $text |
||||
* @return string |
||||
* 原作者:http://t.zoukankan.com/ccw869476711-p-13596791.html |
||||
*/ |
||||
function letter_avatar($text) |
||||
{ |
||||
$total = unpack('L', hash('adler32', $text, true))[1]; |
||||
$hue = $total % 360; |
||||
list($r, $g, $b) = hsv2rgb($hue / 360, 0.3, 0.9); |
||||
|
||||
$bg = "rgb({$r},{$g},{$b})"; |
||||
$color = "#ffffff"; |
||||
$first = mb_strtoupper(mb_substr($text, 0, 1)); |
||||
$src = '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="100" width="100"><rect fill="' . $bg . '" x="0" y="0" width="100" height="100"></rect><text x="50" y="50" font-size="50" text-copy="fast" fill="' . $color . '" text-anchor="middle" text-rights="admin" alignment-baseline="central">' . $first . '</text></svg>'; |
||||
//$value = 'data:image/svg+xml;base64,' . $src; |
||||
$value = $src; |
||||
return $value; |
||||
} |
||||
|
||||
|
||||
function hsv2rgb($h, $s, $v) |
||||
{ |
||||
$r = $g = $b = 0; |
||||
|
||||
$i = floor($h * 6); |
||||
$f = $h * 6 - $i; |
||||
$p = $v * (1 - $s); |
||||
$q = $v * (1 - $f * $s); |
||||
$t = $v * (1 - (1 - $f) * $s); |
||||
|
||||
switch ($i % 6) { |
||||
case 0: |
||||
$r = $v; |
||||
$g = $t; |
||||
$b = $p; |
||||
break; |
||||
case 1: |
||||
$r = $q; |
||||
$g = $v; |
||||
$b = $p; |
||||
break; |
||||
case 2: |
||||
$r = $p; |
||||
$g = $v; |
||||
$b = $t; |
||||
break; |
||||
case 3: |
||||
$r = $p; |
||||
$g = $q; |
||||
$b = $v; |
||||
break; |
||||
case 4: |
||||
$r = $t; |
||||
$g = $p; |
||||
$b = $v; |
||||
break; |
||||
case 5: |
||||
$r = $v; |
||||
$g = $p; |
||||
$b = $q; |
||||
break; |
||||
} |
||||
|
||||
return [ |
||||
floor($r * 255), |
||||
floor($g * 255), |
||||
floor($b * 255) |
||||
]; |
||||
} |
||||
|
||||
/** |
||||
* 输出svg图像 |
||||
*/ |
||||
function output_ico() { |
||||
//获取文字 |
||||
$text = @trim($_GET['text']); |
||||
$text = empty($text) ? '空' : $text; |
||||
|
||||
//获取当前主机名 |
||||
$host = $_SERVER['HTTP_HOST']; |
||||
//获取reffrer |
||||
$referer = $_SERVER['HTTP_REFERER']; |
||||
|
||||
//如果referer和主机名不匹配,则禁止调用 |
||||
if ( ( !empty($referer) ) && ( !strstr($referer,$host) ) ) { |
||||
exit('调用失败'); |
||||
} |
||||
else{ |
||||
header('Cache-Control: max-age=604800'); |
||||
header('Content-Type:image/svg+xml'); |
||||
echo letter_avatar($text); |
||||
} |
||||
|
||||
} |
||||
|
||||
//调用ico输出函数 |
||||
output_ico(); |
@ -0,0 +1,83 @@
@@ -0,0 +1,83 @@
|
||||
<!-- 主题详情页面 --> |
||||
<html> |
||||
<head> |
||||
<meta charset="utf-8"> |
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> |
||||
<title>OneNav后台管理</title> |
||||
<link rel='stylesheet' href='static/layui/css/layui.css'> |
||||
<link rel='stylesheet' href='templates/admin/static/style.css?v=v0.9.17-20220314'> |
||||
</head> |
||||
<body class="layui-fluid"> |
||||
<div class="layui-row" style = "margin-top:1em;"> |
||||
<!-- 说明提示框 --> |
||||
<div class="layui-col-lg12"> |
||||
<div class="setting-msg"> |
||||
主题自定义参数设置,请参考:<a href="https://dwz.ovh/gnae4" target = "_blank" title = "主题参数设置说明">https://dwz.ovh/gnae4</a>,如果您不清楚,请勿修改。 |
||||
</div> |
||||
</div> |
||||
<!-- 说明提示框END --> |
||||
<div class="layui-col-sm10 layui-col-sm-offset1"> |
||||
<form class="layui-form layui-form-pane"> |
||||
<div class="layui-form-item"> |
||||
<label class="layui-form-label" style = "width:35%;">主题名称</label> |
||||
<div class="layui-input-inline" style = "width:63%;"> |
||||
<input type="text" name="name" required lay-verify="required" value = "<?php echo $name; ?>" readonly="readonly" class="layui-input"> |
||||
</div> |
||||
</div> |
||||
<!-- 遍历配置选项 --> |
||||
<?php foreach ($configs as $key => $config) { |
||||
//如果config.json获取到的数据是空的,则读取info.json |
||||
$value = empty( $current_configs->$key ) ? $config : $current_configs->$key; |
||||
?> |
||||
<div class="layui-form-item"> |
||||
<label class="layui-form-label" style = "width:35%;"><?php echo $key; ?></label> |
||||
<div class="layui-input-inline" style = "width:63%;"> |
||||
<input type="text" name="<?php echo $key; ?>" value = "<?php echo $value; ?>" class="layui-input"> |
||||
</div> |
||||
</div> |
||||
<?php } ?> |
||||
<!-- 遍历配置选项END --> |
||||
<div class="layui-form-item"> |
||||
<button class="layui-btn" lay-submit lay-filter="save_theme_config">保存</button> |
||||
</div> |
||||
</form> |
||||
</div> |
||||
</div> |
||||
<script src="static/js/jquery.min.js"></script> |
||||
<script src="static/layui/layui.js"></script> |
||||
<script> |
||||
layui.use(['layer','form'], function(){ |
||||
var layer = layui.layer; |
||||
var form = layui.form; |
||||
|
||||
form.on('submit(save_theme_config)', function(data){ |
||||
console.log(data.field); |
||||
$.post("/index.php?c=api&method=save_theme_config",data.field,function(data,status){ |
||||
if( data.data == 'success') { |
||||
layer.msg("设置已更新!",{icon:1}); |
||||
} |
||||
else{ |
||||
layer.msg(data.err_msg,{icon:5}); |
||||
} |
||||
|
||||
}); |
||||
return false; |
||||
}); |
||||
}); |
||||
|
||||
function set_theme(name) { |
||||
$.post("/index.php?c=api&method=set_theme",{key:"theme",value:name},function(data,status){ |
||||
if( data.code == 0 ) { |
||||
layer.msg(data.data, {icon: 1}); |
||||
setTimeout(() => { |
||||
location.reload(); |
||||
}, 2000); |
||||
} |
||||
else{ |
||||
layer.msg(data.err_msg, {icon: 5}); |
||||
} |
||||
}); |
||||
} |
||||
</script> |
||||
</body> |
||||
</html> |
@ -1,9 +1,15 @@
@@ -1,9 +1,15 @@
|
||||
{ |
||||
"name":"OneNav默认主题", |
||||
"description":"OneNav默认主题", |
||||
"homepage":"https://www.xiaoz.me", |
||||
"version":"0.9.19", |
||||
"update":"2022/04/22", |
||||
"author":"xiaoz<xiaoz93@outlook.com>", |
||||
"screenshot":"https://img.rss.ink/imgs/2022/03/42ed3ef2c4a50f6d.png" |
||||
"name": "OneNav默认主题", |
||||
"description": "OneNav默认主题", |
||||
"homepage": "https:\/\/www.xiaoz.me", |
||||
"help_url":"https://dwz.ovh/gnae4", |
||||
"version": "0.9.20", |
||||
"update": "2022\/04\/29", |
||||
"author": "xiaoz<xiaoz93@outlook.com>", |
||||
"screenshot": "https:\/\/img.rss.ink\/imgs\/2022\/03\/42ed3ef2c4a50f6d.png", |
||||
"config": { |
||||
"full_width_mode":"off", |
||||
"link_description":"show", |
||||
"favicon": "online" |
||||
} |
||||
} |
Loading…
Reference in new issue