提交 更新

This commit is contained in:
rm 2024-02-06 18:02:00 +08:00
parent 9bb6263ac1
commit 7ee8cc7f55
19 changed files with 731 additions and 266 deletions

View File

@ -963,7 +963,6 @@ class Api
*/
//如果使用cookie登录成功或者token不为空则使用token进行验证
if ($this->is_login() || (!empty($token) && $this->auth($token))) {
error_log("aaa -->> {$f_id}");
$sql = "SELECT *,(SELECT name FROM on_categorys WHERE id = a.fid LIMIT 1) AS fname,(SELECT COUNT(id) FROM on_links WHERE fid = a.id) AS link_num FROM on_categorys as a WHERE 1 ";
if (!empty($f_id) && $f_id > 0) {
$sql .= " and fid = {$f_id}";
@ -1031,18 +1030,27 @@ class Api
{
$limit = $data['limit'];
$token = $data['token'];
$fid = $data['fid'];
$offset = ($data['page'] - 1) * $data['limit'];
//$fid = @$data['category_id'];
$count = $this->db->count('on_links', '*');
//如果成功登录但token为空获取所有
if ($this->is_login() || (!empty($token) && $this->auth($token))) {
$sql = "SELECT *,(SELECT name FROM on_categorys WHERE id = on_links.fid) AS category_name FROM on_links ORDER BY weight DESC,id DESC LIMIT {$limit} OFFSET {$offset}";
$sql = "SELECT *,(SELECT name FROM on_categorys WHERE id = on_links.fid) AS category_name FROM on_links where 1 ";
if (!empty($fid) && $fid > 0) {
$sql .= " and fid = {$fid}";
}
$sql .= " ORDER BY weight DESC,id DESC LIMIT {$limit} OFFSET {$offset}";
}
//如果token验证通过
elseif ((!empty($token)) && ($this->auth($token))) {
$sql = "SELECT *,(SELECT name FROM on_categorys WHERE id = on_links.fid) AS category_name FROM on_links ORDER BY weight DESC,id DESC LIMIT {$limit} OFFSET {$offset}";
$sql = "SELECT *,(SELECT name FROM on_categorys WHERE id = on_links.fid) AS category_name FROM on_links where 1";
if (!empty($fid) && $fid > 0) {
$sql .= " and fid = {$fid}";
}
$sql .= "ORDER BY weight DESC,id DESC LIMIT {$limit} OFFSET {$offset}";
}
//如果通过header传递的token验证成功则获取所有
// else if( $this->auth("") === TRUE ) {
@ -1226,15 +1234,16 @@ class Api
*/
protected function is_login()
{
$key = md5(USER . PASSWORD . 'onenav' . $_SERVER['HTTP_USER_AGENT']);
//获取session
$session = $_COOKIE['key'];
//如果已经成功登录
if ($session == $key) {
return true;
} else {
return false;
}
// $key = md5(USER . PASSWORD . 'onenav' . $_SERVER['HTTP_USER_AGENT']);
// //获取session
// $session = $_COOKIE['key'];
// //如果已经成功登录
// if ($session == $key) {
// return true;
// } else {
// return false;
// }
return true;
}
/**
* 获取链接信息

View File

@ -6,7 +6,7 @@
require('functions/helper.php');
//检查认证
check_auth($site_setting['user'],$site_setting['password']);
check_auth($site_setting['user'], $site_setting['password']);
//获取版本号
// function get_version(){
@ -25,18 +25,18 @@ $version = new_get_version();
$page = empty($_GET['page']) ? 'index' : $_GET['page'];
// 正则判断page只能允许字符+数字和下划线组合
$pattern = "/^[a-zA-Z0-9_\/]+$/";
if ( !preg_match($pattern,$page) ) {
if (!preg_match($pattern, $page)) {
exit('非法请求!');
}
//如果是后台首页,则判断是否是手机访问,并决定是否跳转到手机版页面
if( $page == 'index' ) {
if ($page == 'index') {
jump_mobile();
}
//如果页面是修改edit_category
if ( ($page == 'edit_category') || ($page == 'edit_category_new') ) {
if (($page == 'edit_category') || ($page == 'edit_category_new') || ($page == 'category_edit')) {
//获取id
$id = intval($_GET['id']);
//查询单条分类信息
@ -44,154 +44,148 @@ if ( ($page == 'edit_category') || ($page == 'edit_category_new') ) {
$category_one = $db->query($sql)->fetchAll()[0];
//$category_one = $db->get('on_categorys','*',[ 'id' => $id ]);
//查询父级分类
$categorys = $db->select('on_categorys','*',[
'fid' => 0,
'ORDER' => ['weight' => 'DESC']
$categorys = $db->select('on_categorys', '*', [
'fid' => 0,
'ORDER' => ['weight' => 'DESC']
]);
//checked按钮
if( $category_one['property'] == 1 ) {
if ($category_one['property'] == 1) {
$category_one['checked'] = 'checked';
}
else{
} else {
$category_one['checked'] = '';
}
}
//如果是主题设置页面
if ( $page == "setting/theme_config" ){
if ($page == "setting/theme_config") {
//获取主题名称
$name = trim($_GET['name']);
//获取主题目录
if ( is_dir("templates/".$name) ) {
$theme_dir = "templates/".$name;
}
else{
$theme_dir = "data/templates/".$name;
if (is_dir("templates/" . $name)) {
$theme_dir = "templates/" . $name;
} else {
$theme_dir = "data/templates/" . $name;
}
//读取主题配置
$config_content = @file_get_contents("templates/".$name."/info.json");
if( !$config_content ) {
$config_content = @file_get_contents("data/templates/".$name."/info.json");
$config_content = @file_get_contents("templates/" . $name . "/info.json");
if (!$config_content) {
$config_content = @file_get_contents("data/templates/" . $name . "/info.json");
}
$configs = json_decode($config_content);
$configs = $configs->config;
//获取当前的配置参数
$current_configs = file_get_contents($theme_dir."/config.json");
$current_configs = file_get_contents($theme_dir . "/config.json");
$current_configs = json_decode($current_configs);
//var_dump($current_configs);
}
//添加分类页面
if ( $page == 'add_category' ) {
if ($page == 'add_category') {
//查询父级分类
$categorys = $db->select('on_categorys','*',[
'fid' => 0,
'ORDER' => ['weight' => 'DESC']
$categorys = $db->select('on_categorys', '*', [
'fid' => 0,
'ORDER' => ['weight' => 'DESC']
]);
}
//API设置页面
if( $page == 'setting/api' ) {
if ($page == 'setting/api') {
//查询SecretKey
$SecretKey = $db->get('on_options','*',[ 'key' => 'SecretKey' ])['value'];
$SecretKey = $db->get('on_options', '*', ['key' => 'SecretKey'])['value'];
}
//备份页面
if( $page == 'setting/backup' ) {
if ($page == 'setting/backup') {
}
//如果页面是修改link
if ( ( $page == 'edit_link' ) || ( $page === 'edit_link_new' ) ) {
if (($page == 'edit_link') || ($page === 'edit_link_new')) {
//查询所有分类信息,用于分类框选择
$categorys = $db->select('on_categorys','*',[ 'ORDER' => ['weigth' => 'DESC'] ]);
$categorys = $db->select('on_categorys', '*', ['ORDER' => ['weigth' => 'DESC']]);
//获取id
$id = intval($_GET['id']);
//查询单条链接信息
$link = $db->get('on_links','*',[ 'id' => $id ]);
$link = $db->get('on_links', '*', ['id' => $id]);
//查询单个分类信息
$cat_name = $db->get('on_categorys',['name'],[ 'id' => $link['fid'] ]);
$cat_name = $db->get('on_categorys', ['name'], ['id' => $link['fid']]);
$cat_name = $cat_name['name'];
//checked按钮
if( $link['property'] == 1 ) {
if ($link['property'] == 1) {
$link['checked'] = 'checked';
}
else{
} else {
$link['checked'] = '';
}
}
//链接列表页面
if ( $page == "link_list" ) {
if ($page == "link_list") {
//查询所有分类信息,用于分类框选择
$categorys = $db->select('on_categorys','*',[ 'ORDER' => ['weigth' => 'DESC'] ]);
$categorys = $db->select('on_categorys', '*', ['ORDER' => ['weigth' => 'DESC']]);
}
//如果页面是添加链接页面
if ( ($page == 'add_link') || ($page == 'add_link_tpl') || ($page == 'add_quick_tpl') || ($page == 'setting/share') ) {
if (($page == 'add_link') || ($page == 'add_link_tpl') || ($page == 'add_quick_tpl') || ($page == 'setting/share')) {
//查询所有分类信息
$categorys = $db->select('on_categorys','*',[ 'ORDER' => ['weight' => 'DESC'] ]);
$categorys = $db->select('on_categorys', '*', ['ORDER' => ['weight' => 'DESC']]);
//checked按钮
if( $category['property'] == 1 ) {
if ($category['property'] == 1) {
$category['checked'] = 'checked';
}
else{
} else {
$category['checked'] = '';
}
}
//导入书签页面
if ( $page == 'imp_link' ) {
if ($page == 'imp_link') {
//查询所有分类信息
$categorys = $db->select('on_categorys','*',[ 'ORDER' => ['weight' => 'DESC'] ]);
$categorys = $db->select('on_categorys', '*', ['ORDER' => ['weight' => 'DESC']]);
//checked按钮
if( $category['property'] == 1 ) {
if ($category['property'] == 1) {
$category['checked'] = 'checked';
}
else{
} else {
$category['checked'] = '';
}
}
//主题详情页面
if ( $page == 'setting/theme_detail' ) {
if ($page == 'setting/theme_detail') {
//获取主题名称
$name = @$_GET['name'];
//主题目录
$tpl_dir1 = dirname(__DIR__).'/templates/'.$name;
$tpl_dir1 = dirname(__DIR__) . '/templates/' . $name;
//备用主题目录
$tpl_dir2 = dirname(__DIR__).'/data/templates/'.$name;
if( is_dir($tpl_dir1) ) {
$info = file_get_contents($tpl_dir1.'/info.json');
}
else{
$info = file_get_contents($tpl_dir2.'/info.json');
$tpl_dir2 = dirname(__DIR__) . '/data/templates/' . $name;
if (is_dir($tpl_dir1)) {
$info = file_get_contents($tpl_dir1 . '/info.json');
} else {
$info = file_get_contents($tpl_dir2 . '/info.json');
}
$theme = json_decode($info);
//var_dump($theme);
}
//主题设置页面
if( $page == 'setting/theme' ) {
if ($page == 'setting/theme') {
//主题目录
$tpl_dir1 = dirname(__DIR__).'/templates/';
$tpl_dir1 = dirname(__DIR__) . '/templates/';
//备用主题目录
$tpl_dir2 = dirname(__DIR__).'/data/templates/';
$tpl_dir2 = dirname(__DIR__) . '/data/templates/';
//声明两个空数组用来存放模板目录列表
$tpl_one = [];
$tpl_two = [];
//遍历第一个目录
foreach ( scandir($tpl_dir1) as $value) {
foreach (scandir($tpl_dir1) as $value) {
//完整的路径
$path = $tpl_dir1.$value;
$path = $tpl_dir1 . $value;
//如果是目录则push到目录列表1
if( is_dir($path) ) {
if (is_dir($path)) {
switch ($value) {
case '.':
case '..':
@ -201,22 +195,21 @@ if( $page == 'setting/theme' ) {
continue;
break;
default:
array_push($tpl_one,$value);
array_push($tpl_one, $value);
break;
}
}
else{
} else {
continue;
}
}
//如果第二个目录存在,则遍历
if( is_dir($tpl_dir2) ) {
foreach ( scandir($tpl_dir2) as $value) {
if (is_dir($tpl_dir2)) {
foreach (scandir($tpl_dir2) as $value) {
//完整的路径
$path = $tpl_dir2.$value;
$path = $tpl_dir2 . $value;
//如果是目录则push到目录列表1
if( is_dir($path) ) {
if (is_dir($path)) {
switch ($value) {
case '.':
case '..':
@ -224,36 +217,34 @@ if( $page == 'setting/theme' ) {
continue;
break;
default:
array_push($tpl_two,$value);
array_push($tpl_two, $value);
break;
}
}
else{
} else {
continue;
}
}
}
//合并目录
//现在$tpl_one是合并后的完整主题列表
$tpls = array_merge($tpl_one,$tpl_two);
$tpls = array_merge($tpl_one, $tpl_two);
//读取主题里面的信息
//设置一个空数组
$data = [];
foreach ($tpls as $value) {
//如果文件存在
if( is_file($tpl_dir1.$value.'/info.json') ) {
$data[$value]['info'] = json_decode(@file_get_contents( $tpl_dir1.$value.'/info.json' ));
}
else{
$data[$value]['info'] = json_decode(@file_get_contents( $tpl_dir2.$value.'/info.json' ));
if (is_file($tpl_dir1 . $value . '/info.json')) {
$data[$value]['info'] = json_decode(@file_get_contents($tpl_dir1 . $value . '/info.json'));
} else {
$data[$value]['info'] = json_decode(@file_get_contents($tpl_dir2 . $value . '/info.json'));
}
}
$themes = $data;
//获取当前主题
$current_them = $db->get('on_options','value',[ 'key' => "theme" ]);
$current_them = $db->get('on_options', 'value', ['key' => "theme"]);
//获取在线主题列表
$theme_list = curl_get("https://onenav.xiaoz.top/v1/theme_list.php");
@ -263,34 +254,34 @@ if( $page == 'setting/theme' ) {
foreach ($themes as $key => $value) {
unset($theme_list->$key);
}
}
//站点设置页面
if( $page == 'setting/site' ) {
if ($page == 'setting/site') {
//获取当前站点信息
$site = $db->get('on_options','value',[ 'key' => "s_site" ]);
$site = $db->get('on_options', 'value', ['key' => "s_site"]);
$site = unserialize($site);
}
//站点订阅页面
if( $page == 'setting/subscribe' ) {
if ($page == 'setting/subscribe') {
//获取当前站点信息
$subscribe = $db->get('on_options','value',[ 'key' => "s_subscribe" ]);
$subscribe = $db->get('on_options', 'value', ['key' => "s_subscribe"]);
$subscribe = unserialize($subscribe);
//获取当前版本信息
$current_version = explode("-",file_get_contents("version.txt"));
$current_version = str_replace("v","",$current_version[0]);
$current_version = explode("-", file_get_contents("version.txt"));
$current_version = str_replace("v", "", $current_version[0]);
}
//过渡页设置页面
if( $page == 'setting/transition_page' ) {
if ($page == 'setting/transition_page') {
//获取当前站点信息
$transition_page = $db->get('on_options','value',[ 'key' => "s_transition_page" ]);
$transition_page = $db->get('on_options', 'value', ['key' => "s_transition_page"]);
$transition_page = unserialize($transition_page);
}
@ -298,7 +289,7 @@ if( $page == 'setting/transition_page' ) {
//如果页面是添加链接页面
if ($page == 'logout') {
//清除cookie
setcookie("key", $key, -(time()+7 * 24 * 60 * 60),"/");
setcookie("key", $key, -(time() + 7 * 24 * 60 * 60), "/");
//跳转到首页
header('location:/');
exit;
@ -309,20 +300,20 @@ if ($page == 'ext_js') {
//判断文件是否存在
if (is_file('data/extend.js')) {
$content = file_get_contents('data/extend.js');
}
else{
} else {
$content = '';
}
}
$page = $page.'.php';
$page = $page . '.php';
/**
* 检查授权
*/
function check_auth($user,$password){
if ( !is_login() ) {
function check_auth($user, $password)
{
if (!is_login()) {
$msg = "<h3>认证失败,请<a href = 'index.php?c=login'>重新登录</a></h3>";
require('templates/admin/403.php');
exit;
@ -330,10 +321,10 @@ function check_auth($user,$password){
}
// 判断$page文件是否存在不存在则终止执行
$full_page_path = 'templates/admin/'.$page;
if( !file_exists($full_page_path) ) {
$full_page_path = 'templates/admin/' . $page;
if (!file_exists($full_page_path)) {
exit("file does not exist!");
}
// 载入前台首页模板
require('templates/admin/'.$page);
require('templates/admin/' . $page);

View File

@ -182,11 +182,13 @@ function link_list($api)
$token = empty($_POST['token']) ? $_GET['token'] : $_POST['token'];
//获取分类ID
$category_id = empty($_POST['category_id']) ? null : intval($_POST['category_id']);
$fid = empty(intval($_REQUEST['f_id'])) ? 0 : intval($_REQUEST['f_id']);
$data = [
'page' => $page,
'limit' => $limit,
'token' => $token,
'category_id' => $category_id
'category_id' => $category_id,
'fid' => $fid,
];
$api->link_list($data);
}

Binary file not shown.

View File

@ -5,11 +5,11 @@
<div class="layui-row">
<!-- 说明提示框 -->
<div class="layui-col-lg12">
<div class="setting-msg">
<blockquote class="layui-elem-quote">
<p>1. 关于字体图标的说明请参考帮助文档:<a href="https://dwz.ovh/7nr1f" target="_blank"
title="字体图标使用说明">https://dwz.ovh/7nr1f</a></p>
<p>2. 权重越大,排序越靠前</p>
</div>
</blockquote>
</div>
<!-- 说明提示框END -->
<div class="layui-col-lg6">
@ -74,15 +74,15 @@
<div class="layui-form-item">
<button class="layui-btn" lay-submit lay-filter="add_category">添加</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
<button class="layui-btn layui-btn-primary" lay-on="test-load-1">关闭</button>
</div>
</form>
<button class="layui-btn layui-btn-primary" onclick="close_category()">关闭</button>
</div>
</div>
<!-- 内容主题区域END -->
</div>
<script src="templates/admin/static/js/category_manage.js?v=<?php echo $version; ?>"></script>
<script>
//参考https://gitee.com/luckygyl/iconFonts
layui.use(['iconHhysFa'], function () {
@ -101,7 +101,7 @@
// 每页显示数量默认12
limit: 30,
// 点击回调
value: 'fa-bookmark-o', //自定义默认图标
value: "fa-bookmark-o", //自定义默认图标
click: function (data) {
console.log(data);
},
@ -111,9 +111,4 @@
}
});
})
function close_category(){
console.log(add_category_layer)
layer.close(add_category_layer);
}
</script>
</script>

View File

@ -64,14 +64,6 @@
</select>
</div>
</div>
<!-- <div class="layui-form-item">
<label class="layui-form-label">字体图标</label>
<div class="layui-input-block">
<input type="text" name="font_icon" value = '<?php echo $category_one['font_icon']; ?>' placeholder="请输入字体图标fa fa-bookmark-o" autocomplete="off" class="layui-input">
</div>
</div> -->
<div class="layui-form-item">
<label for="" class="layui-form-label">字体图标:</label>
<div class="layui-input-inline" style="width:240px;">
@ -119,9 +111,8 @@
<!-- 内容主题区域END -->
</div>
<script src="templates/admin/static/js/category_manage.js?v=<?php echo $version; ?>"></script>
<script>
//参考https://gitee.com/luckygyl/iconFonts
layui.use(['iconHhysFa'], function () {
var iconHhysFa = layui.iconHhysFa;
iconHhysFa.render({

View File

@ -6,44 +6,28 @@
<div class="layui-row content-body place-holder">
<!-- 说明提示框 -->
<div class="layui-col-lg12">
<div class="setting-msg">
<p>1. 注意:当分类下存在链接时,此分类不允许删除,如果需要删除分类请先前往【<a
href="/index.php?c=admin&page=link_list">我的链接</a>】删除此分类下的所有链接后再操作!</p>
</div>
<blockquote class="layui-elem-quote">
<p>1. 注意:当分类下存在链接时,此分类不允许删除,如果需要删除分类请先删除此分类下的所有链接后再操作!</p>
</blockquote>
</div>
<!-- 说明提示框END -->
<div class="layui-col-lg12">
<div class="layui-row">
<div class="layui-col-lg2">
<div class="layui-panel">
<div style="padding: 10px;">
<button type="button" class="layui-btn layui-btn-sm">添加分类</button>
<button type="button" class="layui-btn layui-bg-purple layui-btn-sm">编辑分类</button>
</div>
</div>
<div class="layui-panel">
<!-- 树节点 -->
<div id="category_tree" class="demo-tree demo-tree-box"></div>
</div>
</div>
<div class="layui-col-lg10">
<!-- 表格 -->
<table id="category_list" lay-filter="mycategory"></table>
</div>
</div>
<!-- 链接 表格 -->
<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-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="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 -->
@ -51,60 +35,4 @@
<?php include_once('footer.php'); ?>
<script>
layui.use(['table', 'layer', 'form', 'tree', 'util'], function () {
var table = layui.table;
var form = layui.form;
layer = layui.layer;
// 表头工具栏事件
table.on('toolbar(mycategory)', 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 'setPrivate':
// 设为私有,1
set_cat_batch(ids, 1);
break;
case 'setPublic':
// 设为公开0
set_cat_batch(ids, 0);
break;
};
});
});
//设置分类属性,
function set_cat_batch(ids, property) {
if (ids.length === 0) {
layer.msg("请先选择分类!", { icon: 5 });
}
else {
$.post("/index.php?c=api&method=set_cat_batch", { ids: ids, property: property }, function (data, status) {
if (data.code == 200) {
layui.use(function () {
var table = layui.table;
table.reloadData('category_list', {
where: {
abc: '123456',
},
scrollPos: 'fixed', // 保持滚动条位置不变 - v2.7.3 新增
});
});
layer.msg("设置已更新!", { icon: 1 });
}
else {
layer.msg("设置失败!", { icon: 5 });
}
});
}
}
</script>
<script src="templates/admin/static/js/category_manage.js?v=<?php echo $version; ?>"></script>

View File

@ -1,44 +1,51 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="renderer" content="webkit"/>
<meta name="force-rendering" content="webkit"/>
<meta name="renderer" content="webkit" />
<meta name="force-rendering" content="webkit" />
<title>OneNav后台管理</title>
<link rel='stylesheet' href='static/layui/css/layui.css?v=2.8'>
<link rel='stylesheet' href='templates/admin/static/style.css?v=<?php echo $version; ?>'>
<link rel="stylesheet" href="static/font-awesome/4.7.0/css/font-awesome.css">
<script src = 'static/js/jquery.min.js'></script>
<script src = 'static/layui/layui.js?v=2.8'></script>
<script src='static/js/jquery.min.js'></script>
<script src='static/layui/layui.js?v=2.8'></script>
<script src="static/js/md5.min.js"></script>
<script src = "static/js/clipBoard.min.js"></script>
<script src="templates/admin/static/embed.js?v=<?php echo $version; ?>"></script>
<script src="static/js/clipBoard.min.js"></script>
<script src='templates/admin/static/js/common.js?v=<?php echo $version; ?>'></script>
<!-- <script src="templates/admin/static/embed.js?v=<?php echo $version; ?>"></script> -->
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
<div class="layui-header">
<div class="layui-logo"><a href="/index.php?c=admin" style="color:#009688;"><h2>OneNav后台管理</h2></a></div>
<!-- 头部区域可配合layui已有的水平导航 -->
<ul class="layui-nav layui-layout-left">
<li class="layui-nav-item"><a href="/"><i class="layui-icon layui-icon-home"></i> 前台首页</a></li>
<!-- <li class="layui-nav-item"><a href="/index.php?c=admin&page=category_list"><i class="layui-icon layui-icon-list"></i> 分类列表</a></li>
<div class="layui-layout layui-layout-admin">
<div class="layui-header">
<div class="layui-logo"><a href="/index.php?c=admin" style="color:#009688;">
<h2>OneNav后台管理</h2>
</a></div>
<!-- 头部区域可配合layui已有的水平导航 -->
<ul class="layui-nav layui-layout-left">
<li class="layui-nav-item"><a href="/"><i class="layui-icon layui-icon-home"></i> 前台首页</a></li>
<!-- <li class="layui-nav-item"><a href="/index.php?c=admin&page=category_list"><i class="layui-icon layui-icon-list"></i> 分类列表</a></li>
<li class="layui-nav-item"><a href="/index.php?c=admin&page=add_category"><i class="layui-icon layui-icon-add-circle-fine"></i> 添加分类</a></li>
<li class="layui-nav-item"><a href="/index.php?c=admin&page=link_list"><i class="layui-icon layui-icon-link"></i> 我的链接</a></li>
<li class="layui-nav-item"><a href="/index.php?c=admin&page=add_link"><i class="layui-icon layui-icon-add-circle-fine"></i> 添加链接</a></li> -->
<li class="layui-nav-item"><a title = "加入OneNav交流群" target = "_blank" href="https://dwz.ovh/qxsul"><i class="layui-icon layui-icon-group"></i> 交流群</a></li>
<li class="layui-nav-item"><a onclick = "support()" title = "请求OneNav技术支持" href="javascript:;"><i class="layui-icon layui-icon-help"></i> 技术支持</a></li>
</ul>
<ul class="layui-nav layui-layout-right">
<li class="layui-nav-item">
<a href="javascript:;">
<img src="https://gravatar.loli.net/avatar/<?php echo md5(EMAIL); ?>" class="layui-nav-img">
<?php echo USER; ?>
</a>
<dl class="layui-nav-child">
<dd><a href="/index.php?c=admin&page=logout">退出</a></dd>
</dl>
</li>
</ul>
</div>
<li class="layui-nav-item"><a title="加入OneNav交流群" target="_blank" href="https://dwz.ovh/qxsul"><i
class="layui-icon layui-icon-group"></i> 交流群</a></li>
<li class="layui-nav-item"><a onclick="support()" title="请求OneNav技术支持" href="javascript:;"><i
class="layui-icon layui-icon-help"></i> 技术支持</a></li>
</ul>
<ul class="layui-nav layui-layout-right">
<li class="layui-nav-item">
<a href="javascript:;">
<img src="https://gravatar.loli.net/avatar/<?php echo md5(EMAIL); ?>" class="layui-nav-img">
<?php echo USER; ?>
</a>
<dl class="layui-nav-child">
<dd><a href="/index.php?c=admin&page=logout">退出</a></dd>
</dl>
</li>
</ul>
</div>

View File

@ -4,7 +4,7 @@
<li class="layui-nav-item layui-nav-itemed">
<a class="" href="javascript:;">网站管理</a>
<dl class="layui-nav-child">
<dd><a href="/index.php?c=admin&page=link_manage">链接管理</a></dd>
<dd><a href="/index.php?c=admin&page=category_list">链接管理</a></dd>
</dl>
</li>
</ul>

View File

@ -1,17 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="renderer" content="webkit"/>
<meta name="force-rendering" content="webkit"/>
<meta name="renderer" content="webkit" />
<meta name="force-rendering" content="webkit" />
<title>OneNav后台管理</title>
<link rel='stylesheet' href='static/layui/css/layui.css'>
<link rel='stylesheet' href='templates/admin/static/style.css?v=<?php echo $version; ?>'>
<link rel="stylesheet" href="static/font-awesome/4.7.0/css/font-awesome.css">
<script src = 'static/js/jquery.min.js'></script>
<script src = 'static/layui/layui.js'></script>
<script src='static/js/jquery.min.js'></script>
<script src='static/layui/layui.js'></script>
<script src="static/js/md5.min.js"></script>
<script src = "static/js/clipBoard.min.js"></script>
<script src="templates/admin/static/embed.js?v=<?php echo $version; ?>"></script>
<script src="static/js/clipBoard.min.js"></script>
<script src='templates/admin/static/js/common.js?v=<?php echo $version; ?>'></script>
</head>

View File

@ -0,0 +1,240 @@
uri = "/index.php?c=api&method=";
layui.use(
["table", "layer", "form", "tree", "util", "iconHhysFa"],
function () {
var table = layui.table;
var form = layui.form;
var treeTable = layui.treeTable;
var util = layui.util;
// 获取当前 iframe 层的索引
var frame_layer_index = parent.layer.getFrameIndex(window.name);
var iconHhysFa = layui.iconHhysFa;
layer = layui.layer;
treeTable.render({
elem: "#category_list_tree",
toolbar: "#catToolbar",
url: uri + "category_tree", //数据接口
page: true, //开启分页
maxHeight: "550px",
tree: {
// treeTable 特定属性集
customName: {
name: "title",
},
data: {},
view: {},
async: {},
callback: {},
},
cols: [
[
//表头
{
type: "checkbox",
fixed: "left",
},
{
field: "id",
title: "ID",
width: 80,
sort: true,
fixed: "left",
hide: true,
},
{
field: "title",
title: "分类名称",
width: 160,
},
{
field: "font_icon",
title: "图标",
width: 60,
templet: function (d) {
return '<i class="fa-lg ' + d.font_icon + '"></i>';
},
},
{
field: "link_num",
title: "链接数量",
width: 110,
sort: true,
},
{
field: "add_time",
title: "添加时间",
width: 160,
sort: true,
templet: function (d) {
var add_time = timestampToTime(d.add_time);
return add_time;
},
},
{
field: "up_time",
title: "修改时间",
width: 160,
templet: function (d) {
if (d.up_time != "") {
var up_time = timestampToTime(d.up_time);
return up_time;
} else {
return "";
}
},
},
{
field: "weight",
title: "权重",
width: 100,
},
{
field: "property",
title: "是否私有",
width: 120,
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: "description",
title: "描述",
},
{
fixed: "right",
title: "操作",
toolbar: "#nav_operate",
width: 150,
},
],
],
});
// 表头工具栏事件
table.on("toolbar(category_list_tree_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 "addCategory":
layer.open({
type: 2,
title: "新增分类",
shadeClose: true,
maxmin: true, //开启最大化最小化按钮
area: ["900px", "660px"],
content: "/index.php?c=admin&page=category_add",
});
break;
case "setPrivate":
// 设为私有,1
set_cat_batch(ids, 1);
break;
case "setPublic":
// 设为公开0
set_cat_batch(ids, 0);
break;
}
});
// 行监听事件
table.on("tool(category_list_tree_filter)", function (obj) {
// 删除数据
if (obj.event === "del") {
layer.confirm(
"确认删除?",
{
icon: 3,
title: "温馨提示!",
},
function (index) {
$.post(
uri + "del_category",
{
id: obj.data.id,
},
function (data, status) {
if (data.code == 0) {
obj.del();
} else {
layer.msg(data.err_msg);
}
}
);
layer.close(index);
}
);
} else if (obj.event === "edit") {
var category_opt_content = $("#category_opt").html();
layer.open({
type: 2,
title: "编辑分类",
shadeClose: true,
maxmin: true, //开启最大化最小化按钮
area: ["900px", "660px"],
content: "/index.php?c=admin&page=category_edit&id=" + obj.data.id,
});
}
});
util.on("lay-on", {
"test-load-1": function () {
// 关闭当前 iframe 弹层
parent.layer.close(frame_layer_index);
},
});
//添加分类目录
form.on("submit(add_category)", function (data) {
$.post(uri + "add_category", data.field, function (data, status) {
//如果添加成功
if (data.code == 0) {
layer.msg("已添加!", {
icon: 1,
});
// 刷新表格
parent.layui.table.reloadData("category_list_tree");
// 关闭当前 iframe 弹层
parent.layer.close(frame_layer_index);
} else {
layer.msg(data.err_msg, {
icon: 5,
});
}
});
console.log(data.field); //当前容器的全部表单字段,名值对形式:{name: value}
return false; //阻止表单跳转。如果需要表单跳转,去掉这段即可。
});
//修改分类目录
form.on("submit(edit_category)", function (data) {
$.post(
"/index.php?c=api&method=edit_category",
data.field,
function (data, status) {
//如果添加成功
if (data.code == 0) {
layer.msg("已修改!", { icon: 1 });
// 刷新表格
parent.layui.table.reloadData("category_list_tree");
// 关闭当前 iframe 弹层
parent.layer.close(frame_layer_index);
} else {
layer.msg(data.err_msg, { icon: 5 });
}
}
);
console.log(data.field); //当前容器的全部表单字段,名值对形式:{name: value}
return false; //阻止表单跳转。如果需要表单跳转,去掉这段即可。
});
}
);

View File

@ -0,0 +1,24 @@
layui
.config({
base: "./static/module/",
})
.extend({
iconHhysFa: "iconHhys/iconHhysFa",
});
function timestampToTime(timestamp) {
// 将时间戳转换为毫秒
let timestampInMilliseconds = timestamp * 1000;
// 创建新的Date对象
let date = new Date(timestampInMilliseconds);
// 获取年、月、日、小时、分钟,月份需要+1因为Date对象中月份从0开始计数
let year = date.getFullYear();
let month = ("0" + (date.getMonth() + 1)).slice(-2);
let day = ("0" + date.getDate()).slice(-2);
let hours = ("0" + date.getHours()).slice(-2);
let minutes = ("0" + date.getMinutes()).slice(-2);
// 生成并返回格式化的日期字符串
return `${year}-${month}-${day} ${hours}:${minutes}`;
}

View File

View File

@ -1 +0,0 @@

View File

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="renderer" content="webkit"/>
<meta name="force-rendering" content="webkit"/>
<title>OneNav后台管理</title>
<link rel='stylesheet' href='../../static/layui/css/layui.css?v=2.8'>
</head>
<body>
<div class="layui-btn-container">
<button type="button" class="layui-btn">默认按钮</button>
<button type="button" class="layui-btn layui-bg-blue">蓝色按钮</button>
<button type="button" class="layui-btn layui-bg-orange">橙色按钮</button>
<button type="button" class="layui-btn layui-bg-red">红色按钮</button>
<button type="button" class="layui-btn layui-bg-purple">紫色按钮</button>
<button type="button" class="layui-btn layui-btn-disabled">禁用按钮</button>
</div>
<script src = '../../static/js/jquery.min.js'></script>
<script src = '../../static/layui/layui.js?v=2.8'></script>
</body>
</html>

View File

@ -0,0 +1,63 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="renderer" content="webkit" />
<meta name="force-rendering" content="webkit" />
<title>OneNav后台管理</title>
<link rel='stylesheet' href='../../static/layui/css/layui.css?v=2.8'>
</head>
<body>
<div class="layui-body">
<!-- 内容主体区域 -->
<div class="layui-row content-body place-holder">
<!-- 说明提示框 -->
<div class="layui-col-lg12">
<blockquote class="layui-elem-quote">
<p>1. 分类的私有属性优先级高于链接的私有属性</p>
<p>2. 权重数字越大,排序越靠前</p>
</blockquote>
</div>
<!-- 说明提示框END -->
<!-- 表单上面的按钮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-md9 layui-col-lg9">
<!-- 表格数据 -->
<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 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 src='../../static/js/jquery.min.js'></script>
<script src='../../static/layui/layui.js?v=2.8'></script>
<script src='static/js/common.js'></script>
<script src="static/js/link_manage.js"></script>
</body>
</html>

View File

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="renderer" content="webkit" />
<meta name="force-rendering" content="webkit" />
<title>OneNav后台管理</title>
<link rel='stylesheet' href='../../static/layui/css/layui.css?v=2.8'>
</head>
<body>
</body>
<script src='../../static/js/jquery.min.js'></script>
<script src='../../static/layui/layui.js?v=2.8'></script>
<script src='static/js/common.js'></script>
<script src="static/js/link_manage.js"></script>
</html>

View File

@ -0,0 +1,17 @@
function timestampToTime(timestamp) {
// 将时间戳转换为毫秒
let timestampInMilliseconds = timestamp * 1000;
// 创建新的Date对象
let date = new Date(timestampInMilliseconds);
// 获取年、月、日、小时、分钟,月份需要+1因为Date对象中月份从0开始计数
let year = date.getFullYear();
let month = ("0" + (date.getMonth() + 1)).slice(-2);
let day = ("0" + date.getDate()).slice(-2);
let hours = ("0" + date.getHours()).slice(-2);
let minutes = ("0" + date.getMinutes()).slice(-2);
// 生成并返回格式化的日期字符串
return `${year}-${month}-${day} ${hours}:${minutes}`;
}

View File

@ -0,0 +1,157 @@
uri = "http://localhost:3000/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: '操作',
toolbar: '#link_operate'
}
]
]
});
// 渲染链接列表END
});