提交一些修改
This commit is contained in:
parent
7ee8cc7f55
commit
1e8f04faed
|
@ -931,7 +931,6 @@ class Api
|
|||
'data' => $this->formatTreeData($datas)
|
||||
];
|
||||
$str = json_encode($datas);
|
||||
error_log("data_tree -->> {$str}");
|
||||
exit(json_encode($datas));
|
||||
}
|
||||
|
||||
|
|
|
@ -83,12 +83,13 @@ if ($page == "setting/theme_config") {
|
|||
}
|
||||
|
||||
//添加分类页面
|
||||
if ($page == 'add_category') {
|
||||
if ($page == 'category_add') {
|
||||
//查询父级分类
|
||||
$categorys = $db->select('on_categorys', '*', [
|
||||
'fid' => 0,
|
||||
'ORDER' => ['weight' => 'DESC']
|
||||
]);
|
||||
error_log($categorys);
|
||||
}
|
||||
|
||||
//API设置页面
|
||||
|
@ -131,7 +132,7 @@ if ($page == "link_list") {
|
|||
}
|
||||
|
||||
//如果页面是添加链接页面
|
||||
if (($page == 'add_link') || ($page == 'add_link_tpl') || ($page == 'add_quick_tpl') || ($page == 'setting/share')) {
|
||||
if (($page == 'link_add') || ($page == 'add_link_tpl') || ($page == 'add_quick_tpl') || ($page == 'setting/share')) {
|
||||
//查询所有分类信息
|
||||
$categorys = $db->select('on_categorys', '*', ['ORDER' => ['weight' => 'DESC']]);
|
||||
//checked按钮
|
||||
|
|
|
@ -4,141 +4,147 @@
|
|||
*/
|
||||
|
||||
//获取当前站点信息
|
||||
$site = $db->get('on_options','value',[ 'key' => "s_site" ]);
|
||||
$site = $db->get('on_options', 'value', ['key' => "s_site"]);
|
||||
$site = unserialize($site);
|
||||
// 获取链接数量,默认为30
|
||||
$link_num = empty( $site['link_num'] ) ? 30 : intval($site['link_num']);
|
||||
$link_num = empty($site['link_num']) ? 30 : intval($site['link_num']);
|
||||
|
||||
|
||||
|
||||
//如果已经登录,获取所有分类和链接
|
||||
// 载入辅助函数
|
||||
require('functions/helper.php');
|
||||
if( is_login() ){
|
||||
if (is_login()) {
|
||||
//查询所有分类目录
|
||||
$categorys = [];
|
||||
//查询一级分类目录,分类fid为0的都是一级分类
|
||||
$category_parent = $db->select('on_categorys','*',[
|
||||
"fid" => 0,
|
||||
"ORDER" => ["weight" => "DESC"]
|
||||
$category_parent = $db->select('on_categorys', '*', [
|
||||
"fid" => 0,
|
||||
"ORDER" => ["weight" => "DESC"]
|
||||
]);
|
||||
//遍历一级分类,然后获取下面的二级分类,获取到了就push
|
||||
foreach ($category_parent as $key => $value) {
|
||||
//把一级分类先加入到空数组
|
||||
array_push($categorys,$value);
|
||||
array_push($categorys, $value);
|
||||
//然后查询他下面的子分类,再追加到数组
|
||||
$category_subs = $db->select('on_categorys','*',[
|
||||
"fid" => $value['id'],
|
||||
"ORDER" => ["weight" => "DESC"]
|
||||
$category_subs = $db->select('on_categorys', '*', [
|
||||
"fid" => $value['id'],
|
||||
"ORDER" => ["weight" => "DESC"]
|
||||
]);
|
||||
|
||||
|
||||
foreach ($category_subs as $category_sub) {
|
||||
array_push($categorys,$category_sub);
|
||||
array_push($categorys, $category_sub);
|
||||
}
|
||||
}
|
||||
//根据分类ID查询二级分类,分类fid大于0的都是二级分类
|
||||
function get_category_sub($id) {
|
||||
function get_category_sub($id)
|
||||
{
|
||||
global $db;
|
||||
$id = intval($id);
|
||||
|
||||
$category_sub = $db->select('on_categorys','*',[
|
||||
"fid" => $id,
|
||||
"ORDER" => ["weight" => "DESC"]
|
||||
$category_sub = $db->select('on_categorys', '*', [
|
||||
"fid" => $id,
|
||||
"ORDER" => ["weight" => "DESC"]
|
||||
]);
|
||||
|
||||
return $category_sub;
|
||||
}
|
||||
|
||||
//根据category id查询链接
|
||||
function get_links($fid) {
|
||||
function get_links($fid)
|
||||
{
|
||||
global $db;
|
||||
$fid = intval($fid);
|
||||
$links = $db->select('on_links','*',[
|
||||
'fid' => $fid,
|
||||
'ORDER' => ["weight" => "DESC"]
|
||||
]);
|
||||
$links = $db->select('on_links', '*', [
|
||||
'fid' => $fid,
|
||||
'ORDER' => ["weight" => "DESC"]
|
||||
]);
|
||||
return $links;
|
||||
}
|
||||
|
||||
|
||||
//根据category id查询有限链接
|
||||
function get_limit_links($fid) {
|
||||
function get_limit_links($fid)
|
||||
{
|
||||
global $db;
|
||||
global $link_num;
|
||||
$fid = intval($fid);
|
||||
$links = $db->select('on_links','*',[
|
||||
'fid' => $fid,
|
||||
'ORDER' => ["weight" => "DESC"],
|
||||
'LIMIT' => $link_num
|
||||
]);
|
||||
|
||||
$links = $db->select('on_links', '*', [
|
||||
'fid' => $fid,
|
||||
'ORDER' => ["weight" => "DESC"],
|
||||
'LIMIT' => $link_num
|
||||
]);
|
||||
|
||||
return $links;
|
||||
}
|
||||
|
||||
|
||||
//右键菜单标识
|
||||
$onenav['right_menu'] = 'admin_menu();';
|
||||
}
|
||||
//如果没有登录,只获取公有链接
|
||||
else{
|
||||
else {
|
||||
// 检查分类是否全私有,如果是,则跳转到登录界面
|
||||
check_all_cat();
|
||||
//查询分类目录
|
||||
$categorys = [];
|
||||
//查询一级分类目录,分类fid为0的都是一级分类
|
||||
$category_parent = $db->select('on_categorys','*',[
|
||||
"fid" => 0,
|
||||
'property' => 0,
|
||||
"ORDER" => ["weight" => "DESC"]
|
||||
$category_parent = $db->select('on_categorys', '*', [
|
||||
"fid" => 0,
|
||||
'property' => 0,
|
||||
"ORDER" => ["weight" => "DESC"]
|
||||
]);
|
||||
//遍历一级分类,然后获取下面的二级分类,获取到了就push
|
||||
foreach ($category_parent as $key => $value) {
|
||||
//把一级分类先加入到空数组
|
||||
array_push($categorys,$value);
|
||||
array_push($categorys, $value);
|
||||
//然后查询他下面的子分类,再追加到数组
|
||||
$category_subs = $db->select('on_categorys','*',[
|
||||
"fid" => $value['id'],
|
||||
'property' => 0,
|
||||
"ORDER" => ["weight" => "DESC"]
|
||||
$category_subs = $db->select('on_categorys', '*', [
|
||||
"fid" => $value['id'],
|
||||
'property' => 0,
|
||||
"ORDER" => ["weight" => "DESC"]
|
||||
]);
|
||||
|
||||
|
||||
foreach ($category_subs as $category_sub) {
|
||||
array_push($categorys,$category_sub);
|
||||
array_push($categorys, $category_sub);
|
||||
}
|
||||
}
|
||||
//根据分类ID查询二级分类,分类fid大于0的都是二级分类
|
||||
function get_category_sub($id) {
|
||||
function get_category_sub($id)
|
||||
{
|
||||
global $db;
|
||||
$id = intval($id);
|
||||
|
||||
$category_sub = $db->select('on_categorys','*',[
|
||||
"fid" => $id,
|
||||
'property' => 0,
|
||||
"ORDER" => ["weight" => "DESC"]
|
||||
$category_sub = $db->select('on_categorys', '*', [
|
||||
"fid" => $id,
|
||||
'property' => 0,
|
||||
"ORDER" => ["weight" => "DESC"]
|
||||
]);
|
||||
|
||||
return $category_sub;
|
||||
}
|
||||
//根据category id查询链接
|
||||
function get_links($fid) {
|
||||
function get_links($fid)
|
||||
{
|
||||
global $db;
|
||||
global $link_num;
|
||||
$fid = intval($fid);
|
||||
$links = $db->select('on_links','*',[
|
||||
'fid' => $fid,
|
||||
'property' => 0,
|
||||
'ORDER' => ["weight" => "DESC"]
|
||||
$links = $db->select('on_links', '*', [
|
||||
'fid' => $fid,
|
||||
'property' => 0,
|
||||
'ORDER' => ["weight" => "DESC"]
|
||||
]);
|
||||
return $links;
|
||||
}
|
||||
//根据category id查询有限链接
|
||||
function get_limit_links($fid) {
|
||||
function get_limit_links($fid)
|
||||
{
|
||||
global $db;
|
||||
$fid = intval($fid);
|
||||
$links = $db->select('on_links','*',[
|
||||
'fid' => $fid,
|
||||
'property' => 0,
|
||||
'ORDER' => ["weight" => "DESC"],
|
||||
'LIMIT' => $link_num
|
||||
]);
|
||||
$links = $db->select('on_links', '*', [
|
||||
'fid' => $fid,
|
||||
'property' => 0,
|
||||
'ORDER' => ["weight" => "DESC"],
|
||||
'LIMIT' => $link_num
|
||||
]);
|
||||
return $links;
|
||||
}
|
||||
//右键菜单标识
|
||||
|
@ -151,9 +157,9 @@ $get_links = 'get_limit_links';
|
|||
$cid = @$_GET['cid'];
|
||||
|
||||
// 如果存在分类ID,则只查询这个分类
|
||||
if ( !empty($cid) ) {
|
||||
if (!empty($cid)) {
|
||||
foreach ($categorys as $key => $tmp) {
|
||||
if( $tmp['id'] == $cid ) {
|
||||
if ($tmp['id'] == $cid) {
|
||||
$empty_cat[0] = $tmp;
|
||||
break;
|
||||
}
|
||||
|
@ -164,61 +170,60 @@ if ( !empty($cid) ) {
|
|||
}
|
||||
|
||||
//获取版本号
|
||||
function get_version(){
|
||||
if( file_exists('version.txt') ) {
|
||||
function get_version()
|
||||
{
|
||||
if (file_exists('version.txt')) {
|
||||
$version = @file_get_contents('version.txt');
|
||||
return $version;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$version = 'null';
|
||||
return $version;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//将URL转换为base64编码
|
||||
function base64($url){
|
||||
function base64($url)
|
||||
{
|
||||
$urls = parse_url($url);
|
||||
|
||||
//获取请求协议
|
||||
$scheme = empty( $urls['scheme'] ) ? 'http://' : $urls['scheme'].'://';
|
||||
$scheme = empty($urls['scheme']) ? 'http://' : $urls['scheme'] . '://';
|
||||
//获取主机名
|
||||
$host = $urls['host'];
|
||||
//获取端口
|
||||
$port = empty( $urls['port'] ) ? '' : ':'.$urls['port'];
|
||||
$port = empty($urls['port']) ? '' : ':' . $urls['port'];
|
||||
|
||||
$new_url = $scheme.$host.$port;
|
||||
$new_url = $scheme . $host . $port;
|
||||
return base64_encode($new_url);
|
||||
}
|
||||
|
||||
//获取版本号
|
||||
$version = get_version();
|
||||
//载入js扩展
|
||||
if( file_exists('data/extend.js') ) {
|
||||
if (file_exists('data/extend.js')) {
|
||||
$onenav['extend'] = '<script src = "data/extend.js"></script>';
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$onenav['extend'] = '';
|
||||
}
|
||||
|
||||
|
||||
// 载入前台首页模板
|
||||
//查询主题设置
|
||||
$template = $db->get("on_options","value",[
|
||||
"key" => "theme"
|
||||
$template = $db->get("on_options", "value", [
|
||||
"key" => "theme"
|
||||
]);
|
||||
//获取用户传递的主题参数
|
||||
$theme = trim( @$_GET['theme'] );
|
||||
$theme = trim(@$_GET['theme']);
|
||||
//如果用户传递了主题参数
|
||||
if( !empty($theme) ) {
|
||||
if (!empty($theme)) {
|
||||
//获取所有主题
|
||||
$themes = get_all_themes();
|
||||
|
||||
//查找主题是否存在
|
||||
if( array_search($theme,$themes) !== FALSE ) {
|
||||
if (array_search($theme, $themes) !== FALSE) {
|
||||
//改变默认主题
|
||||
$template = $theme;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
//主题不存在,终止执行
|
||||
exit("<h1>主题参数错误!</h1>");
|
||||
}
|
||||
|
@ -226,27 +231,23 @@ if( !empty($theme) ) {
|
|||
|
||||
|
||||
//获取主题配置信息
|
||||
if( file_exists("templates/".$template."/config.json") ) {
|
||||
$config_file = "templates/".$template."/config.json";
|
||||
}
|
||||
else if( file_exists("data/templates/".$template."/config.json") ) {
|
||||
$config_file = "data/templates/".$template."/config.json";
|
||||
}
|
||||
else if( file_exists("templates/".$template."/info.json") ) {
|
||||
$config_file = "templates/".$template."/info.json";
|
||||
}
|
||||
else {
|
||||
$config_file = "data/templates/".$template."/info.json";
|
||||
if (file_exists("templates/" . $template . "/config.json")) {
|
||||
$config_file = "templates/" . $template . "/config.json";
|
||||
} else if (file_exists("data/templates/" . $template . "/config.json")) {
|
||||
$config_file = "data/templates/" . $template . "/config.json";
|
||||
} else if (file_exists("templates/" . $template . "/info.json")) {
|
||||
$config_file = "templates/" . $template . "/info.json";
|
||||
} else {
|
||||
$config_file = "data/templates/" . $template . "/info.json";
|
||||
}
|
||||
|
||||
//读取主题配置
|
||||
$config_content = @file_get_contents($config_file);
|
||||
//如果是info.json,则特殊处理下
|
||||
if ( strstr($config_file,"info.json") ) {
|
||||
if (strstr($config_file, "info.json")) {
|
||||
$config_content = json_decode($config_content);
|
||||
$theme_config = $config_content->config;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$config_content = $config_content;
|
||||
$theme_config = json_decode($config_content);
|
||||
}
|
||||
|
@ -255,67 +256,67 @@ else{
|
|||
|
||||
|
||||
//判断文件夹是否存在
|
||||
if( is_dir('templates/'.$template) ){
|
||||
if (is_dir('templates/' . $template)) {
|
||||
$tpl_dir = 'templates/';
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$tpl_dir = 'data/templates/';
|
||||
}
|
||||
|
||||
//定义搜索引擎
|
||||
$search_engines = [
|
||||
"baidu" => [
|
||||
"name" => "百度",
|
||||
"url" => "https://www.baidu.com/s?ie=utf-8&word="
|
||||
"baidu" => [
|
||||
"name" => "百度",
|
||||
"url" => "https://www.baidu.com/s?ie=utf-8&word="
|
||||
],
|
||||
"google" => [
|
||||
"name" => "Google",
|
||||
"url" => "https://www.google.com/search?q="
|
||||
"google" => [
|
||||
"name" => "Google",
|
||||
"url" => "https://www.google.com/search?q="
|
||||
],
|
||||
"bing" => [
|
||||
"name" => "必应",
|
||||
"url" => "https://cn.bing.com/search?FORM=BESBTB&q="
|
||||
"bing" => [
|
||||
"name" => "必应",
|
||||
"url" => "https://cn.bing.com/search?FORM=BESBTB&q="
|
||||
],
|
||||
"sogou" => [
|
||||
"name" => "搜狗",
|
||||
"url" => "https://www.sogou.com/web?query="
|
||||
"sogou" => [
|
||||
"name" => "搜狗",
|
||||
"url" => "https://www.sogou.com/web?query="
|
||||
],
|
||||
"so360" => [
|
||||
"name" => "360搜索",
|
||||
"url" => "https://www.so.com/s?ie=utf-8&fr=none&src=360sou_newhome&ssid=&q="
|
||||
"so360" => [
|
||||
"name" => "360搜索",
|
||||
"url" => "https://www.so.com/s?ie=utf-8&fr=none&src=360sou_newhome&ssid=&q="
|
||||
],
|
||||
"zhihu" => [
|
||||
"name" => "知乎",
|
||||
"url" => "https://www.zhihu.com/search?type=content&q="
|
||||
"zhihu" => [
|
||||
"name" => "知乎",
|
||||
"url" => "https://www.zhihu.com/search?type=content&q="
|
||||
],
|
||||
"weibo" => [
|
||||
"name" => "微博",
|
||||
"url" => "https://s.weibo.com/weibo?q="
|
||||
]
|
||||
"weibo" => [
|
||||
"name" => "微博",
|
||||
"url" => "https://s.weibo.com/weibo?q="
|
||||
]
|
||||
];
|
||||
|
||||
//获取主题的最低版本要求
|
||||
$info_json = @file_get_contents($tpl_dir.$template."/info.json");
|
||||
$info_json = @file_get_contents($tpl_dir . $template . "/info.json");
|
||||
|
||||
if( $info_json ) {
|
||||
if ($info_json) {
|
||||
$info = json_decode($info_json);
|
||||
|
||||
|
||||
$min_version = @$info->require->min;
|
||||
//获取到了最低版本
|
||||
if( !empty($min_version) ) {
|
||||
if (!empty($min_version)) {
|
||||
//如果主程序不满足主题要求
|
||||
if( new_get_version() < $min_version ) {
|
||||
if (new_get_version() < $min_version) {
|
||||
$onenav_version = new_get_version();
|
||||
exit($template."主题要求最低OneNav版本为:".$min_version.",您当前OneNav版本为:".$onenav_version.",请先<a title = 'OneNav升级说明' href = 'https://dwz.ovh/br5wt' target = '_blank'>升级OneNav版本!</a>");
|
||||
exit($template . "主题要求最低OneNav版本为:" . $min_version . ",您当前OneNav版本为:" . $onenav_version . ",请先<a title = 'OneNav升级说明' href = 'https://dwz.ovh/br5wt' target = '_blank'>升级OneNav版本!</a>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 该分类下可见的链接数量
|
||||
function get_links_number($fid){
|
||||
function get_links_number($fid)
|
||||
{
|
||||
$number = count(get_links($fid));
|
||||
return $number;
|
||||
}
|
||||
|
||||
//载入主题
|
||||
require($tpl_dir.$template.'/index.php');
|
||||
require($tpl_dir . $template . '/index.php');
|
|
@ -1,109 +0,0 @@
|
|||
<?php include_once('header.php'); ?>
|
||||
<?php include_once('left.php'); ?>
|
||||
|
||||
<div class="layui-body">
|
||||
<!-- 内容主体区域 -->
|
||||
<div class="layui-row content-body place-holder">
|
||||
<!-- 说明提示框 -->
|
||||
<div class="layui-col-lg12">
|
||||
<div class="setting-msg">
|
||||
<p>1. 权重越大,排序越靠前</p>
|
||||
<p>2. 识别功能可以自动获取链接标题和描述信息,但不确保一定成功</p>
|
||||
<p>3. 仅 5iux/heimdall/tushan2/webstack 支持自定义图标,其余主题均自动获取链接图标。</p>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 说明提示框END -->
|
||||
<div class="layui-col-lg12">
|
||||
<form class="layui-form layui-form-pane">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">URL</label>
|
||||
<div class="layui-input-block">
|
||||
<input id = "url" name="url" required lay-verify="required" placeholder="请输入有效链接" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<!-- 添加备用链接 -->
|
||||
<div class="layui-col-lg12">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">备用URL</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="url" id = "url_standby" name="url_standby" placeholder="请输入备用链接,如果没有,请留空" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<!-- 备用链接END -->
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">图标</label>
|
||||
<div class="layui-input-inline" style="width:810px;">
|
||||
<button type="button" id = "iconUpload" name="iconUpload" class="layui-btn"><i class="layui-icon"></i>上传图标</button>
|
||||
<button type="button" class="layui-btn layui-btn-danger" onclick="del_link_icon()">删除图标</button>
|
||||
<!-- 显示图标 -->
|
||||
<div id="show_icon">
|
||||
<img src="static/images/white64.png" alt="">
|
||||
</div>
|
||||
<!-- 显示图标 -->
|
||||
<div class="layui-form-mid layui-word-aux" style = "float:right;">图标最小尺寸建议为 64 * 64像素,大小不超过100KB,仅部分主题支持自定义图标!</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">图标链接</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="url" id = "font_icon" name="font_icon" placeholder="请输入图标链接,如果没有,请留空(可输入外部https链接)" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">链接名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" id = "title" name="title" required lay-verify="required" placeholder="请输入链接名称" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">所属分类</label>
|
||||
<div class="layui-input-block">
|
||||
<select name="fid" lay-verify="required" lay-search>
|
||||
<option value=""></option>
|
||||
<?php foreach ($categorys as $category) {
|
||||
# code...
|
||||
?>
|
||||
<option value="<?php echo $category['id'] ?>"><?php echo $category['name']; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">权重</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="weight" min = "0" max = "999" value = "0" required lay-verify="required|number" placeholder="权重越高,排名越靠前,范围为0-999" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否私有</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="checkbox" name="property" value = "1" lay-skin="switch" lay-text="是|否">
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux">私有链接需要登录后才能查看!</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">描述(选填)</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea name="description" id = "description" placeholder="请输入内容" class="layui-textarea"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<button class="layui-btn" id = "add_link" lay-submit lay-filter="add_link">添加</button>
|
||||
<!-- <button class="layui-btn" lay-submit lay-filter="get_link_info">识别</button> -->
|
||||
<a href="javascript:;" class="layui-btn" onclick="get_link_info()">识别</a>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- 内容主题区域END -->
|
||||
</div>
|
||||
|
||||
<?php include_once('footer.php'); ?>
|
|
@ -38,7 +38,6 @@
|
|||
<select name="fid" lay-verify="">
|
||||
<option value="0">无</option>
|
||||
<?php foreach ($categorys as $key => $category) {
|
||||
|
||||
?>
|
||||
<option value="<?php echo $category['id']; ?>">
|
||||
<?php echo $category['name']; ?>
|
||||
|
|
|
@ -16,18 +16,18 @@
|
|||
<table id="category_list_tree" lay-filter="category_list_tree_filter"></table>
|
||||
</div>
|
||||
<script type="text/html" id="nav_operate">
|
||||
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
|
||||
<a class="layui-btn layui-btn-danger layui-bg-red layui-btn-xs" lay-event="del" onclick="">删除</a>
|
||||
</script>
|
||||
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
|
||||
<a class="layui-btn layui-btn-danger layui-bg-red layui-btn-xs" lay-event="del" onclick="">删除</a>
|
||||
</script>
|
||||
|
||||
<!-- 表头工具栏 -->
|
||||
<script type="text/html" id="catToolbar">
|
||||
<div class="layui-btn-container">
|
||||
<button class="layui-btn layui-btn-sm" lay-event="addCategory">新增分类</button>
|
||||
<button class="layui-btn layui-btn-sm" lay-event="setPrivate">设为私有</button>
|
||||
<button class="layui-btn layui-btn-sm" lay-event="setPublic">设为公开</button>
|
||||
</div>
|
||||
</script>
|
||||
<div class="layui-btn-container">
|
||||
<button class="layui-btn layui-btn-sm" lay-event="addCategory">新增分类</button>
|
||||
<button class="layui-btn layui-btn-sm" lay-event="setPrivate">设为私有</button>
|
||||
<button class="layui-btn layui-btn-sm" lay-event="setPublic">设为公开</button>
|
||||
</div>
|
||||
</script>
|
||||
<!-- 表头工具栏END -->
|
||||
</div>
|
||||
<!-- 内容主题区域END -->
|
||||
|
@ -35,4 +35,4 @@
|
|||
|
||||
<?php include_once('footer.php'); ?>
|
||||
|
||||
<script src="templates/admin/static/js/category_manage.js?v=<?php echo $version; ?>"></script>
|
||||
<script src="templates/admin/static/js/category_manage.js?v=<?php echo $version; ?>"></script>
|
|
@ -0,0 +1,117 @@
|
|||
<?php include_once('s_header.php'); ?>
|
||||
<div class="layui-container">
|
||||
<!-- 内容主体区域 -->
|
||||
<div class="layui-row content-body place-holder">
|
||||
<!-- 说明提示框 -->
|
||||
<div class="layui-col-lg12">
|
||||
<div class="setting-msg">
|
||||
<p>1. 权重越大,排序越靠前</p>
|
||||
<p>2. 识别功能可以自动获取链接标题和描述信息,但不确保一定成功</p>
|
||||
<p>3. 仅 5iux/heimdall/tushan2/webstack 支持自定义图标,其余主题均自动获取链接图标。</p>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 说明提示框END -->
|
||||
<div class="layui-col-lg12">
|
||||
<form class="layui-form layui-form-pane">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">URL</label>
|
||||
<div class="layui-input-block">
|
||||
<input id="url" name="url" required lay-verify="required" placeholder="请输入有效链接" autocomplete="off"
|
||||
class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<!-- 添加备用链接 -->
|
||||
<div class="layui-col-lg12">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">备用URL</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="url" id="url_standby" name="url_standby" placeholder="请输入备用链接,如果没有,请留空" autocomplete="off"
|
||||
class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<!-- 备用链接END -->
|
||||
<!-- 显示图标 -->
|
||||
<!-- <div class="layui-form-item">
|
||||
<label class="layui-form-label">图标</label>
|
||||
<div class="layui-input-inline">
|
||||
<div class="layui-btn-group">
|
||||
<button type="button" id="iconUpload" name="iconUpload" class="layui-btn layui-btn-sm">
|
||||
<i class="layui-icon"></i>
|
||||
上传图标
|
||||
</button>
|
||||
<button type="button" class="layui-btn layui-btn-sm layui-btn-danger"
|
||||
onclick="del_link_icon()">删除图标</button>
|
||||
<div id="show_icon">
|
||||
<img src="static/images/white64.png" alt="">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux" style="float:right;">图标最小尺寸建议为 64 *
|
||||
64像素,大小不超过100KB,仅部分主题支持自定义图标!</div> -->
|
||||
<!-- 显示图标end -->
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">图标链接</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="url" id="font_icon" name="font_icon" placeholder="请输入图标链接,如果没有,请留空(可输入外部https链接)"
|
||||
autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">链接名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" id="title" name="title" required lay-verify="required" placeholder="请输入链接名称"
|
||||
autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">所属分类</label>
|
||||
<div class="layui-input-block">
|
||||
<select name="fid" lay-verify="required" lay-search>
|
||||
<option value=""></option>
|
||||
<?php foreach ($categorys as $key => $category) {
|
||||
?>
|
||||
<option value="<?php echo $category['id']; ?>">
|
||||
<?php echo $category['name']; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">权重</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="weight" min="0" max="999" value="0" required lay-verify="required|number"
|
||||
placeholder="权重越高,排名越靠前,范围为0-999" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否私有</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="checkbox" name="property" value="1" lay-skin="switch" lay-text="是|否">
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux">私有链接需要登录后才能查看!</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">描述(选填)</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea name="description" id="description" placeholder="请输入内容" class="layui-textarea"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<button class="layui-btn" id="add_link" lay-submit lay-filter="add_link">添加</button>
|
||||
<!-- <button class="layui-btn" lay-submit lay-filter="get_link_info">识别</button> -->
|
||||
<a href="javascript:;" class="layui-btn" onclick="get_link_info()">识别</a>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- 内容主题区域END -->
|
||||
</div>
|
||||
<script src="templates/admin/static/js/link_manage.js?v=<?php echo $version; ?>"></script>
|
|
@ -2,273 +2,242 @@
|
|||
<?php include_once('left.php'); ?>
|
||||
|
||||
<div class="layui-body">
|
||||
<!-- 内容主体区域 -->
|
||||
<div class="layui-row content-body place-holder">
|
||||
<!-- 内容主体区域 -->
|
||||
<div class="layui-row content-body place-holder">
|
||||
|
||||
<!-- 说明提示框 -->
|
||||
<div class="layui-col-lg12">
|
||||
<div class="page-msg">
|
||||
<ol>
|
||||
<li>仅 5iux/heimdall/tushan2/webstack 支持自定义图标,其余主题均自动获取链接图标。</li>
|
||||
<li>分类的私有属性优先级高于链接的私有属性</li>
|
||||
<li>权重数字越大,排序越靠前</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 说明提示框END -->
|
||||
|
||||
<!-- 表单上面的按钮 -->
|
||||
<div class="lay-col-lg12">
|
||||
<form class="layui-form layui-form-pane" action="">
|
||||
<div class="layui-form-item">
|
||||
|
||||
<div class="layui-inline">
|
||||
<div class="layui-input-inline">
|
||||
<select name="fid" lay-verify="" lay-search id = "fid">
|
||||
<option value="">请选择一个分类</option>
|
||||
<?php foreach( $categorys AS $category ){ ?>
|
||||
<option value="<?php echo $category['id'] ?>"><?php echo $category['name']; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="layui-input-inline" style="width: 100px;">
|
||||
<button class="layui-btn" lay-submit lay-filter="screen_link">查询此分类下的链接</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="width:50px;display: inline-block;"></div>
|
||||
|
||||
<!-- 顶部搜索 -->
|
||||
<div class="layui-inline">
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="keyword" id="keyword" placeholder="请输入关键词" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
<div class="layui-input-inline" style="width: 100px;">
|
||||
<button class="layui-btn" lay-submit lay-filter="search_keyword">搜索</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 顶部搜索END -->
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<!-- 表单上面的按钮END -->
|
||||
<div class="layui-col-lg12">
|
||||
<table id="link_list" lay-filter="mylink" lay-data="{id: 'mylink_reload'}"></table>
|
||||
<!-- 开启表格头部工具栏 -->
|
||||
<script type="text/html" id="linktool">
|
||||
<div class="layui-btn-container">
|
||||
<button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="getCheckData">删除选中</button>
|
||||
<button class="layui-btn layui-btn-sm" lay-event="readmoredata">批量修改分类</button>
|
||||
<button class="layui-btn layui-btn-sm" lay-event="set_private">设为私有</button>
|
||||
<button class="layui-btn layui-btn-sm" lay-event="set_public">设为公有</button>
|
||||
<button class="layui-btn layui-btn-sm" lay-event="reset_query">重置查询</button>
|
||||
<!-- <button class="layui-btn layui-btn-sm" lay-event="getCheckLength">获取选中数目</button>
|
||||
<button class="layui-btn layui-btn-sm" lay-event="isAll">验证是否全选</button> -->
|
||||
</div>
|
||||
</script>
|
||||
<!-- 开启表格头部工具栏END -->
|
||||
</div>
|
||||
<script type="text/html" id="link_operate">
|
||||
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
|
||||
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del" onclick = "">删除</a>
|
||||
</script>
|
||||
<!-- 表单下面的按钮 -->
|
||||
<button style="margin-top:16px;" class="layui-btn layui-btn-sm" lay-submit onclick = "export_link()">导出所有链接</button>
|
||||
<!-- 表单下面的按钮END -->
|
||||
</div>
|
||||
<!-- 内容主题区域END -->
|
||||
<!-- 说明提示框 -->
|
||||
<div class="layui-col-lg12">
|
||||
<blockquote class="layui-elem-quote">
|
||||
<p>1. 分类的私有属性优先级高于链接的私有属性</p>
|
||||
<p>2. 权重数字越大,排序越靠前</p>
|
||||
</blockquote>
|
||||
</div>
|
||||
<!-- 说明提示框END -->
|
||||
<!-- 内容主题区域 -->
|
||||
<div class="layui-col-md12 layui-col-lg12">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-md2 layui-col-lg2">
|
||||
<!-- 树节点 -->
|
||||
<div id="category_tree"></div>
|
||||
</div>
|
||||
<div class="layui-col-md10 layui-col-lg10">
|
||||
<!-- 表格数据 -->
|
||||
<table id="link_list_table" lay-filter="link_list_table_filter" lay-data="{id: 'mylink_reload'}"></table>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 开启表格头部工具栏 -->
|
||||
<script type="text/html" id="linktool">
|
||||
<div class="layui-btn-container">
|
||||
<button class="layui-btn layui-btn-sm" lay-event="addLink">新增分类</button>
|
||||
<button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="getCheckData">删除选中</button>
|
||||
<button class="layui-btn layui-btn-sm" lay-event="readmoredata">批量修改分类</button>
|
||||
<button class="layui-btn layui-btn-sm" lay-event="set_private">设为私有</button>
|
||||
<button class="layui-btn layui-btn-sm" lay-event="set_public">设为公有</button>
|
||||
<button class="layui-btn layui-btn-sm" lay-event="reset_query">重置查询</button>
|
||||
<!-- <button class="layui-btn layui-btn-sm" lay-event="getCheckLength">获取选中数目</button>
|
||||
<button class="layui-btn layui-btn-sm" lay-event="isAll">验证是否全选</button> -->
|
||||
</div>
|
||||
</script>
|
||||
<!-- 开启表格头部工具栏END -->
|
||||
</div>
|
||||
<script type="text/html" id="link_operate">
|
||||
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
|
||||
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del" onclick="">删除</a>
|
||||
</script>
|
||||
</div>
|
||||
<!-- 内容主题区域END -->
|
||||
</div>
|
||||
|
||||
<script>
|
||||
layui.use(['table','form'], function(){
|
||||
var table = layui.table;
|
||||
var form = layui.form;
|
||||
// <script>
|
||||
// layui.use(['table','form'], function(){
|
||||
// var table = layui.table;
|
||||
// var form = layui.form;
|
||||
|
||||
// 编辑单行
|
||||
table.on('edit(mylink)',function(obj){
|
||||
var field = obj.field; // 得到字段
|
||||
var value = obj.value; // 得到修改后的值
|
||||
var data = obj.data; // 得到所在行所有键值
|
||||
// // 编辑单行
|
||||
// table.on('edit(mylink)',function(obj){
|
||||
// var field = obj.field; // 得到字段
|
||||
// var value = obj.value; // 得到修改后的值
|
||||
// var data = obj.data; // 得到所在行所有键值
|
||||
|
||||
// 获取到权重并判断是否合法
|
||||
let weight = data.weight;
|
||||
if( /^[-+]?\d*\.?\d+$/.test(weight) == false ) {
|
||||
layer.msg("权重必须为数字!",{icon:5});
|
||||
return obj.reedit();
|
||||
}
|
||||
// 获取到标题并判断是否合法
|
||||
let title = data.title.trim();
|
||||
if( title.length == 0 ) {
|
||||
layer.msg("标题不能为空!",{icon:5});
|
||||
return obj.reedit();
|
||||
}
|
||||
// // 获取到权重并判断是否合法
|
||||
// let weight = data.weight;
|
||||
// if( /^[-+]?\d*\.?\d+$/.test(weight) == false ) {
|
||||
// layer.msg("权重必须为数字!",{icon:5});
|
||||
// return obj.reedit();
|
||||
// }
|
||||
// // 获取到标题并判断是否合法
|
||||
// let title = data.title.trim();
|
||||
// if( title.length == 0 ) {
|
||||
// layer.msg("标题不能为空!",{icon:5});
|
||||
// return obj.reedit();
|
||||
// }
|
||||
|
||||
// 请求后端API
|
||||
$.ajax({
|
||||
url: '/index.php?c=api&method=edit_link_row',
|
||||
type: 'POST',
|
||||
data: JSON.stringify(data),
|
||||
contentType: 'application/json',
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
// 请求成功后执行的代码
|
||||
if( response.code == 0 ) {
|
||||
layer.msg("已修改!",{icon:1});
|
||||
}
|
||||
else{
|
||||
layer.msg(response.msg,{icon:5});
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// 请求出错时执行的代码
|
||||
console.log(error);
|
||||
layer.msg("修改失败!",{icon:5});
|
||||
}
|
||||
});
|
||||
});
|
||||
// // 请求后端API
|
||||
// $.ajax({
|
||||
// url: '/index.php?c=api&method=edit_link_row',
|
||||
// type: 'POST',
|
||||
// data: JSON.stringify(data),
|
||||
// contentType: 'application/json',
|
||||
// dataType: 'json',
|
||||
// success: function(response) {
|
||||
// // 请求成功后执行的代码
|
||||
// if( response.code == 0 ) {
|
||||
// layer.msg("已修改!",{icon:1});
|
||||
// }
|
||||
// else{
|
||||
// layer.msg(response.msg,{icon:5});
|
||||
// }
|
||||
// },
|
||||
// error: function(xhr, status, error) {
|
||||
// // 请求出错时执行的代码
|
||||
// console.log(error);
|
||||
// layer.msg("修改失败!",{icon:5});
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
|
||||
// 提交搜索
|
||||
form.on('submit(search_keyword)', function(data){
|
||||
console.log(data.field);
|
||||
let keyword = data.field.keyword;
|
||||
// // 提交搜索
|
||||
// form.on('submit(search_keyword)', function(data){
|
||||
// console.log(data.field);
|
||||
// let keyword = data.field.keyword;
|
||||
|
||||
if( keyword.length < 2 ) {
|
||||
layer.msg("关键词过短!",{icon:5});
|
||||
return false;
|
||||
}
|
||||
// if( keyword.length < 2 ) {
|
||||
// layer.msg("关键词过短!",{icon:5});
|
||||
// return false;
|
||||
// }
|
||||
|
||||
//渲染链接列表
|
||||
table.render({
|
||||
elem: '#link_list'
|
||||
,height: 530
|
||||
,url: 'index.php?c=api&method=global_search&keyword=' + keyword //数据接口
|
||||
,method: 'post'
|
||||
,toolbar: '#linktool'
|
||||
,cols: [[ //表头
|
||||
{type:'checkbox'} //开启复选框
|
||||
,{field: 'id', title: 'ID', width:80, sort: true}
|
||||
,{field: 'font_icon', title: '图标', width:60, templet:function(d){
|
||||
if(d.font_icon == null || d.font_icon == "")
|
||||
{
|
||||
return '<img src="static/images/default.png" width="28" height="28">';
|
||||
}
|
||||
else
|
||||
{
|
||||
let random = getRandStr(4);
|
||||
let font_icon = d.font_icon;
|
||||
return `<img src="${font_icon}?random=${random}" width="28" height="28">`;
|
||||
}
|
||||
}}
|
||||
// ,{field: 'fid', title: '分类ID',sort:true, width:90}
|
||||
,{field: 'category_name', title: '所属分类',sort:true,width:120}
|
||||
,{field: 'url', title: 'URL',width:140,templet:function(d){
|
||||
var url = '<a target = "_blank" href = "' + d.url + '" title = "' + d.url + '">' + d.url + '</a>';
|
||||
return url;
|
||||
}}
|
||||
,{field: 'title', title: '链接标题', width:140,edit: 'text'}
|
||||
,{field: 'add_time', title: '添加时间', width:148, sort: true,templet:function(d){
|
||||
var add_time = timestampToTime(d.add_time);
|
||||
return add_time;
|
||||
}}
|
||||
,{field: 'up_time', title: '修改时间', width:148,sort:true,templet:function(d){
|
||||
if(d.up_time == null){
|
||||
return '';
|
||||
}
|
||||
else{
|
||||
var up_time = timestampToTime(d.up_time);
|
||||
return up_time;
|
||||
}
|
||||
// //渲染链接列表
|
||||
// table.render({
|
||||
// elem: '#link_list'
|
||||
// ,height: 530
|
||||
// ,url: 'index.php?c=api&method=global_search&keyword=' + keyword //数据接口
|
||||
// ,method: 'post'
|
||||
// ,toolbar: '#linktool'
|
||||
// ,cols: [[ //表头
|
||||
// {type:'checkbox'} //开启复选框
|
||||
// ,{field: 'id', title: 'ID', width:80, sort: true}
|
||||
// ,{field: 'font_icon', title: '图标', width:60, templet:function(d){
|
||||
// if(d.font_icon == null || d.font_icon == "")
|
||||
// {
|
||||
// return '<img src="static/images/default.png" width="28" height="28">';
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// let random = getRandStr(4);
|
||||
// let font_icon = d.font_icon;
|
||||
// return `<img src="${font_icon}?random=${random}" width="28" height="28">`;
|
||||
// }
|
||||
// }}
|
||||
// // ,{field: 'fid', title: '分类ID',sort:true, width:90}
|
||||
// ,{field: 'category_name', title: '所属分类',sort:true,width:120}
|
||||
// ,{field: 'url', title: 'URL',width:140,templet:function(d){
|
||||
// var url = '<a target = "_blank" href = "' + d.url + '" title = "' + d.url + '">' + d.url + '</a>';
|
||||
// return url;
|
||||
// }}
|
||||
// ,{field: 'title', title: '链接标题', width:140,edit: 'text'}
|
||||
// ,{field: 'add_time', title: '添加时间', width:148, sort: true,templet:function(d){
|
||||
// var add_time = timestampToTime(d.add_time);
|
||||
// return add_time;
|
||||
// }}
|
||||
// ,{field: 'up_time', title: '修改时间', width:148,sort:true,templet:function(d){
|
||||
// if(d.up_time == null){
|
||||
// return '';
|
||||
// }
|
||||
// else{
|
||||
// var up_time = timestampToTime(d.up_time);
|
||||
// return up_time;
|
||||
// }
|
||||
|
||||
}}
|
||||
,{field: 'weight', title: '权重', width: 75,sort:true,edit: 'text'}
|
||||
,{field: 'property', title: '私有', width: 80, sort: true,templet: function(d){
|
||||
if(d.property == 1) {
|
||||
return '<button type="button" class="layui-btn layui-btn-xs">是</button>';
|
||||
}
|
||||
else {
|
||||
return '<button type="button" class="layui-btn layui-btn-xs layui-btn-danger">否</button>';
|
||||
}
|
||||
}}
|
||||
,{field: 'click', title: '点击数',width:90,sort:true}
|
||||
,{fixed: 'right', title:'操作', toolbar: '#link_operate'}
|
||||
]]
|
||||
});
|
||||
// 渲染链接列表END
|
||||
// }}
|
||||
// ,{field: 'weight', title: '权重', width: 75,sort:true,edit: 'text'}
|
||||
// ,{field: 'property', title: '私有', width: 80, sort: true,templet: function(d){
|
||||
// if(d.property == 1) {
|
||||
// return '<button type="button" class="layui-btn layui-btn-xs">是</button>';
|
||||
// }
|
||||
// else {
|
||||
// return '<button type="button" class="layui-btn layui-btn-xs layui-btn-danger">否</button>';
|
||||
// }
|
||||
// }}
|
||||
// ,{field: 'click', title: '点击数',width:90,sort:true}
|
||||
// ,{fixed: 'right', title:'操作', toolbar: '#link_operate'}
|
||||
// ]]
|
||||
// });
|
||||
// // 渲染链接列表END
|
||||
|
||||
return false;
|
||||
});
|
||||
// return false;
|
||||
// });
|
||||
|
||||
});
|
||||
// });
|
||||
|
||||
// 重置查询
|
||||
function reset_query(){
|
||||
// 清空关键词
|
||||
$("#keyword").val("");
|
||||
layui.use(['table'], function(){
|
||||
var table = layui.table;
|
||||
// // 重置查询
|
||||
// function reset_query(){
|
||||
// // 清空关键词
|
||||
// $("#keyword").val("");
|
||||
// layui.use(['table'], function(){
|
||||
// var table = layui.table;
|
||||
|
||||
//渲染链接列表
|
||||
table.render({
|
||||
elem: '#link_list'
|
||||
,height: 530
|
||||
,url: 'index.php?c=api&method=link_list'
|
||||
,method: 'post'
|
||||
,page: true //开启分页
|
||||
,toolbar: '#linktool'
|
||||
,cols: [[ //表头
|
||||
{type:'checkbox'} //开启复选框
|
||||
,{field: 'id', title: 'ID', width:80, sort: true}
|
||||
,{field: 'font_icon', title: '图标', width:60, templet:function(d){
|
||||
if(d.font_icon == null || d.font_icon == "")
|
||||
{
|
||||
return '<img src="static/images/default.png" width="28" height="28">';
|
||||
}
|
||||
else
|
||||
{
|
||||
let random = getRandStr(4);
|
||||
let font_icon = d.font_icon;
|
||||
return `<img src="${font_icon}?random=${random}" width="28" height="28">`;
|
||||
}
|
||||
}}
|
||||
// ,{field: 'fid', title: '分类ID',sort:true, width:90}
|
||||
,{field: 'category_name', title: '所属分类',sort:true,width:120}
|
||||
,{field: 'url', title: 'URL',width:140,templet:function(d){
|
||||
var url = '<a target = "_blank" href = "' + d.url + '" title = "' + d.url + '">' + d.url + '</a>';
|
||||
return url;
|
||||
}}
|
||||
,{field: 'title', title: '链接标题', width:140,edit: 'text'}
|
||||
,{field: 'add_time', title: '添加时间', width:148, sort: true,templet:function(d){
|
||||
var add_time = timestampToTime(d.add_time);
|
||||
return add_time;
|
||||
}}
|
||||
,{field: 'up_time', title: '修改时间', width:148,sort:true,templet:function(d){
|
||||
if(d.up_time == null){
|
||||
return '';
|
||||
}
|
||||
else{
|
||||
var up_time = timestampToTime(d.up_time);
|
||||
return up_time;
|
||||
}
|
||||
// //渲染链接列表
|
||||
// table.render({
|
||||
// elem: '#link_list'
|
||||
// ,height: 530
|
||||
// ,url: 'index.php?c=api&method=link_list'
|
||||
// ,method: 'post'
|
||||
// ,page: true //开启分页
|
||||
// ,toolbar: '#linktool'
|
||||
// ,cols: [[ //表头
|
||||
// {type:'checkbox'} //开启复选框
|
||||
// ,{field: 'id', title: 'ID', width:80, sort: true}
|
||||
// ,{field: 'font_icon', title: '图标', width:60, templet:function(d){
|
||||
// if(d.font_icon == null || d.font_icon == "")
|
||||
// {
|
||||
// return '<img src="static/images/default.png" width="28" height="28">';
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// let random = getRandStr(4);
|
||||
// let font_icon = d.font_icon;
|
||||
// return `<img src="${font_icon}?random=${random}" width="28" height="28">`;
|
||||
// }
|
||||
// }}
|
||||
// // ,{field: 'fid', title: '分类ID',sort:true, width:90}
|
||||
// ,{field: 'category_name', title: '所属分类',sort:true,width:120}
|
||||
// ,{field: 'url', title: 'URL',width:140,templet:function(d){
|
||||
// var url = '<a target = "_blank" href = "' + d.url + '" title = "' + d.url + '">' + d.url + '</a>';
|
||||
// return url;
|
||||
// }}
|
||||
// ,{field: 'title', title: '链接标题', width:140,edit: 'text'}
|
||||
// ,{field: 'add_time', title: '添加时间', width:148, sort: true,templet:function(d){
|
||||
// var add_time = timestampToTime(d.add_time);
|
||||
// return add_time;
|
||||
// }}
|
||||
// ,{field: 'up_time', title: '修改时间', width:148,sort:true,templet:function(d){
|
||||
// if(d.up_time == null){
|
||||
// return '';
|
||||
// }
|
||||
// else{
|
||||
// var up_time = timestampToTime(d.up_time);
|
||||
// return up_time;
|
||||
// }
|
||||
|
||||
}}
|
||||
,{field: 'weight', title: '权重', width: 75,sort:true,edit: 'text'}
|
||||
,{field: 'property', title: '私有', width: 80, sort: true,templet: function(d){
|
||||
if(d.property == 1) {
|
||||
return '<button type="button" class="layui-btn layui-btn-xs">是</button>';
|
||||
}
|
||||
else {
|
||||
return '<button type="button" class="layui-btn layui-btn-xs layui-btn-danger">否</button>';
|
||||
}
|
||||
}}
|
||||
,{field: 'click', title: '点击数',width:90,sort:true}
|
||||
,{fixed: 'right', title:'操作', toolbar: '#link_operate'}
|
||||
]]
|
||||
});
|
||||
// 渲染链接列表END
|
||||
})
|
||||
}
|
||||
// }}
|
||||
// ,{field: 'weight', title: '权重', width: 75,sort:true,edit: 'text'}
|
||||
// ,{field: 'property', title: '私有', width: 80, sort: true,templet: function(d){
|
||||
// if(d.property == 1) {
|
||||
// return '<button type="button" class="layui-btn layui-btn-xs">是</button>';
|
||||
// }
|
||||
// else {
|
||||
// return '<button type="button" class="layui-btn layui-btn-xs layui-btn-danger">否</button>';
|
||||
// }
|
||||
// }}
|
||||
// ,{field: 'click', title: '点击数',width:90,sort:true}
|
||||
// ,{fixed: 'right', title:'操作', toolbar: '#link_operate'}
|
||||
// ]]
|
||||
// });
|
||||
// // 渲染链接列表END
|
||||
// })
|
||||
// }
|
||||
|
||||
|
||||
</script>
|
||||
<?php include_once('footer.php'); ?>
|
||||
// </script>
|
||||
<?php include_once('footer.php'); ?>
|
||||
<script src="templates/admin/static/js/link_manage.js?v=<?php echo $version; ?>"></script>
|
|
@ -0,0 +1,224 @@
|
|||
uri = "/index.php?c=api&method=";
|
||||
layui.use(["table", "layer", "form", "tree", "util"], function () {
|
||||
var table = layui.table;
|
||||
var form = layui.form;
|
||||
var treeTable = layui.treeTable;
|
||||
var tree = layui.tree;
|
||||
var util = layui.util;
|
||||
// 获取当前 iframe 层的索引
|
||||
var frame_layer_index = parent.layer.getFrameIndex(window.name);
|
||||
layer = layui.layer;
|
||||
// 加载树节点
|
||||
$.get(uri + "category_tree", function (data, status) {
|
||||
console.log(data.data);
|
||||
//如果登录成功
|
||||
if (data.code == 0) {
|
||||
// 分类树节点
|
||||
tree.render({
|
||||
elem: "#category_tree", //默认是点击节点可进行收缩
|
||||
data: data.data, //数据接口
|
||||
showLine: false,
|
||||
isJump: true,
|
||||
click: function (obj) {
|
||||
// 点击节点回调
|
||||
var type = obj.type; // 得到操作类型:add、edit、del
|
||||
where = {};
|
||||
// 点击节点的回调事件
|
||||
if (obj.data.fid != 0) {
|
||||
// 数据重载 - 仅与数据相关的属性(options)能参与到重载中
|
||||
where = {
|
||||
f_id: obj.data.fid,
|
||||
};
|
||||
} else {
|
||||
where = {
|
||||
id: obj.data.id,
|
||||
};
|
||||
}
|
||||
console.log(where); // 可以获取点击的节点数据
|
||||
table.reloadData("link_list_table", {
|
||||
where: {
|
||||
f_id: obj.data.id,
|
||||
},
|
||||
scrollPos: "fixed",
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
//渲染链接列表
|
||||
table.render({
|
||||
elem: "#link_list_table",
|
||||
height: 530,
|
||||
url: uri + "link_list",
|
||||
method: "post",
|
||||
//开启分页
|
||||
page: true,
|
||||
toolbar: "#linktool",
|
||||
cols: [
|
||||
[
|
||||
//表头
|
||||
{
|
||||
type: "checkbox",
|
||||
}, //开启复选框
|
||||
{
|
||||
field: "id",
|
||||
title: "ID",
|
||||
width: 80,
|
||||
sort: true,
|
||||
},
|
||||
{
|
||||
field: "font_icon",
|
||||
title: "图标",
|
||||
width: 60,
|
||||
templet: function (d) {
|
||||
if (d.font_icon == null || d.font_icon == "") {
|
||||
return '<img src="static/images/default.png" width="28" height="28">';
|
||||
} else {
|
||||
let random = getRandStr(4);
|
||||
let font_icon = d.font_icon;
|
||||
return `<img src="${font_icon}?random=${random}" width="28" height="28">`;
|
||||
}
|
||||
},
|
||||
},
|
||||
// ,{field: 'fid', title: '分类ID',sort:true, width:90}
|
||||
{
|
||||
field: "category_name",
|
||||
title: "所属分类",
|
||||
sort: true,
|
||||
width: 120,
|
||||
},
|
||||
{
|
||||
field: "url",
|
||||
title: "URL",
|
||||
width: 140,
|
||||
templet: function (d) {
|
||||
var url =
|
||||
'<a target = "_blank" href = "' +
|
||||
d.url +
|
||||
'" title = "' +
|
||||
d.url +
|
||||
'">' +
|
||||
d.url +
|
||||
"</a>";
|
||||
return url;
|
||||
},
|
||||
},
|
||||
{
|
||||
field: "title",
|
||||
title: "链接标题",
|
||||
width: 140,
|
||||
edit: "text",
|
||||
},
|
||||
{
|
||||
field: "add_time",
|
||||
title: "添加时间",
|
||||
width: 148,
|
||||
sort: true,
|
||||
templet: function (d) {
|
||||
var add_time = timestampToTime(d.add_time);
|
||||
return add_time;
|
||||
},
|
||||
},
|
||||
{
|
||||
field: "up_time",
|
||||
title: "修改时间",
|
||||
width: 148,
|
||||
sort: true,
|
||||
templet: function (d) {
|
||||
if (d.up_time == null) {
|
||||
return "";
|
||||
} else {
|
||||
var up_time = timestampToTime(d.up_time);
|
||||
return up_time;
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
field: "weight",
|
||||
title: "权重",
|
||||
width: 75,
|
||||
sort: true,
|
||||
edit: "text",
|
||||
},
|
||||
{
|
||||
field: "property",
|
||||
title: "私有",
|
||||
width: 80,
|
||||
sort: true,
|
||||
templet: function (d) {
|
||||
if (d.property == 1) {
|
||||
return '<button type="button" class="layui-btn layui-btn-xs">是</button>';
|
||||
} else {
|
||||
return '<button type="button" class="layui-btn layui-btn-xs layui-btn-danger">否</button>';
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
field: "click",
|
||||
title: "点击数",
|
||||
width: 90,
|
||||
sort: true,
|
||||
},
|
||||
{
|
||||
fixed: "right",
|
||||
title: "操作",
|
||||
width: 140,
|
||||
toolbar: "#link_operate",
|
||||
},
|
||||
],
|
||||
],
|
||||
});
|
||||
// 渲染链接列表END
|
||||
// 表头工具栏事件
|
||||
table.on("toolbar(link_list_table_filter)", function (obj) {
|
||||
var id = obj.config.id;
|
||||
var checkStatus = table.checkStatus(id);
|
||||
var othis = lay(this);
|
||||
var data = checkStatus.data;
|
||||
var ids = [];
|
||||
data.map(function (value, index) {
|
||||
ids.push(value.id);
|
||||
});
|
||||
switch (obj.event) {
|
||||
case "addLink":
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: "添加链接",
|
||||
shadeClose: true,
|
||||
maxmin: true, //开启最大化最小化按钮
|
||||
area: ["900px", "660px"],
|
||||
content: "/index.php?c=admin&page=link_add",
|
||||
});
|
||||
break;
|
||||
case "setPrivate":
|
||||
// 设为私有,1
|
||||
set_cat_batch(ids, 1);
|
||||
break;
|
||||
case "setPublic":
|
||||
// 设为公开,0
|
||||
set_cat_batch(ids, 0);
|
||||
break;
|
||||
}
|
||||
});
|
||||
//新增链接
|
||||
form.on("submit(add_link)", function (data) {
|
||||
$.post(uri + "add_link", data.field, function (data, status) {
|
||||
//如果添加成功
|
||||
if (data.code == 0) {
|
||||
layer.msg("已添加!", {
|
||||
icon: 1,
|
||||
});
|
||||
// 刷新表格
|
||||
parent.layui.table.reloadData("link_list_table");
|
||||
// 关闭当前 iframe 弹层
|
||||
parent.layer.close(frame_layer_index);
|
||||
} else {
|
||||
layer.msg(data.err_msg, {
|
||||
icon: 5,
|
||||
});
|
||||
}
|
||||
});
|
||||
console.log(data.field); //当前容器的全部表单字段,名值对形式:{name: value}
|
||||
return false; //阻止表单跳转。如果需要表单跳转,去掉这段即可。
|
||||
});
|
||||
});
|
|
@ -19,10 +19,16 @@
|
|||
<p>1. 分类的私有属性优先级高于链接的私有属性</p>
|
||||
<p>2. 权重数字越大,排序越靠前</p>
|
||||
</blockquote>
|
||||
<div class="layui-btn-group">
|
||||
<button type="button" id="iconUpload" name="iconUpload" class="layui-btn">
|
||||
<i class="layui-icon"></i>
|
||||
上传图标
|
||||
</button>
|
||||
<button type="button" class="layui-btn layui-btn-danger" onclick="del_link_icon()">删除图标</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 说明提示框END -->
|
||||
|
||||
<!-- 表单上面的按钮END -->
|
||||
<!-- 内容主题区域 -->
|
||||
<div class="layui-col-md12 layui-col-lg12">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-md2 layui-col-lg2">
|
||||
|
|
Loading…
Reference in New Issue