提交一些更新

This commit is contained in:
rm 2024-02-21 18:43:59 +08:00
parent 1e8f04faed
commit fd55b4bcab
11 changed files with 124 additions and 244 deletions

View File

@ -969,7 +969,7 @@ class Api
if (!empty($id) && $id > 0) {
$sql .= " and id = {$id}";
}
$sql .= " ORDER BY weight DESC,id DESC LIMIT {$limit} OFFSET {$offset}";
$sql .= " ORDER BY weight DESC,id DESC ";
//统计总数
$count = $this->db->count('on_categorys', '*');
}
@ -978,17 +978,20 @@ class Api
error_log("bbb -->> {$f_id}");
$this->auth($token);
//查询所有分类
$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 ORDER BY weight DESC,id DESC LIMIT {$limit} OFFSET {$offset}";
$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 ORDER BY weight DESC,id DESC";
//统计总数
$count = $this->db->count('on_categorys', '*');
} else {
error_log("ccc -->> {$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 property = 0 ORDER BY weight DESC,id DESC LIMIT {$limit} OFFSET {$offset}";
$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 property = 0 ORDER BY weight DESC,id DESC";
//统计总数
$count = $this->db->count('on_categorys', '*', [
"property" => 0
]);
}
if (!empty($limit) && !empty($offset)) {
$sql .= " LIMIT {$limit} OFFSET {$offset}";
}
error_log("sql -->> {$sql}");
//原生查询
$datas = $this->db->query($sql)->fetchAll();
@ -1040,7 +1043,7 @@ class Api
if (!empty($fid) && $fid > 0) {
$sql .= " and fid = {$fid}";
}
$sql .= " ORDER BY weight DESC,id DESC LIMIT {$limit} OFFSET {$offset}";
$sql .= " ORDER BY weight DESC,id DESC";
}
//如果token验证通过
@ -1049,7 +1052,7 @@ class Api
if (!empty($fid) && $fid > 0) {
$sql .= " and fid = {$fid}";
}
$sql .= "ORDER BY weight DESC,id DESC LIMIT {$limit} OFFSET {$offset}";
$sql .= "ORDER BY weight DESC,id DESC";
}
//如果通过header传递的token验证成功则获取所有
// else if( $this->auth("") === TRUE ) {
@ -1061,9 +1064,11 @@ class Api
$count = $this->db->query($c_sql)->fetchAll()[0]['num'];
$count = intval($count);
$sql = "SELECT *,(SELECT name FROM on_categorys WHERE id = on_links.fid) AS category_name FROM on_links WHERE property = 0 AND fid IN (SELECT id FROM on_categorys WHERE property = 0) 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 property = 0 AND fid IN (SELECT id FROM on_categorys WHERE property = 0) ORDER BY weight DESC,id DESC";
}
if (!empty($limit) && !empty($offset)) {
$sql .= " LIMIT {$limit} OFFSET {$offset}";
}
//原生查询
$datas = $this->db->query($sql)->fetchAll();

View File

@ -1 +0,0 @@

View File

@ -106,7 +106,7 @@ if ($page == 'setting/backup') {
}
//如果页面是修改link
if (($page == 'edit_link') || ($page === 'edit_link_new')) {
if (($page == 'edit_link') || ($page === 'link_edit')) {
//查询所有分类信息,用于分类框选择
$categorys = $db->select('on_categorys', '*', ['ORDER' => ['weigth' => 'DESC']]);
//获取id

View File

@ -176,8 +176,9 @@ function category_list($api)
*/
function link_list($api)
{
$page = empty(intval($_REQUEST['page'])) ? 1 : intval($_REQUEST['page']);
$limit = empty(intval($_REQUEST['limit'])) ? 10 : intval($_REQUEST['limit']);
error_log("link_list -->> {$_REQUEST['page']} -->> {$_REQUEST['limit']}");
$page = empty(intval($_REQUEST['page'])) ? null : intval($_REQUEST['page']);
$limit = empty(intval($_REQUEST['limit'])) ? null : intval($_REQUEST['limit']);
//获取token
$token = empty($_POST['token']) ? $_GET['token'] : $_POST['token'];
//获取分类ID

Binary file not shown.

View File

@ -4,33 +4,13 @@
<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=category_list">链接管理</a></dd>
</dl>
</li>
</ul>
<!-- 左侧导航区域可配合layui已有的垂直导航 -->
<ul class="layui-nav layui-nav-tree" lay-filter="test">
<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=category_list">分类列表</a></dd>
<dd><a href="/index.php?c=admin&page=add_category">添加分类</a></dd>
</dl>
</li>
</ul>
<ul class="layui-nav layui-nav-tree" lay-filter="test">
<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_list">我的链接</a></dd>
<dd><a href="/index.php?c=admin&page=add_link">添加链接</a></dd>
<dd><a href="/index.php?c=admin&page=category_list">分类管理</a></dd>
<dd><a href="/index.php?c=admin&page=link_list">链接管理</a></dd>
<dd><a href="/index.php?c=admin&page=imp_link">书签导入</a></dd>
<dd><a href="/index.php?c=admin&page=setting/share">书签分享</a></dd>
</dl>
</li>
</ul>
<!-- 系统设置 -->
<ul class="layui-nav layui-nav-tree" lay-filter="test">
<li class="layui-nav-item layui-nav-itemed">

View File

@ -1,6 +1,6 @@
<?php include_once('s_header.php'); ?>
<div class="layui-container"">
<div class="layui-container">
<!-- 内容主体区域 -->
<div class="layui-row">
<!-- 说明提示框 -->
@ -36,20 +36,18 @@
</div>
</div>
<!-- 备用链接END -->
<div class="layui-form-item">
<!-- 显示图标 -->
<!-- <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">&#xe67c;</i>上传图标</button>
<button type="button" class="layui-btn layui-btn-danger" onclick="del_link_icon()">删除图标</button>
<!-- 显示图标 -->
<div id="show_icon">
<img src="<?php echo empty( $link['font_icon'] ) ? 'static/images/white64.png' : $link['font_icon']."?random=".rand(); ?>" alt="">
</div>
<!-- 显示图标 -->
<div class="layui-form-mid layui-word-aux" style = "float:right;">图标最小尺寸建议为 64 * 64像素大小不超过100KB仅部分主题支持自定义图标</div>
</div>
</div>
</div> -->
<div class="layui-form-item">
<label class="layui-form-label">图标链接</label>
@ -111,7 +109,7 @@
</div>
<!-- 内容主题区域END -->
</div>
<script src="templates/admin/static/js/link_manage.js?v=<?php echo $version; ?>"></script>
<script>
$(document).ready(function(){
let font_icon = $("#font_icon").val();

View File

@ -28,7 +28,7 @@
<!-- 开启表格头部工具栏 -->
<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" lay-event="add_link">新增分类</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>
@ -48,7 +48,7 @@
<!-- 内容主题区域END -->
</div>
// <script>
<script>
// layui.use(['table','form'], function(){
// var table = layui.table;
// var form = layui.form;
@ -238,6 +238,6 @@
// }
// </script>
</script>
<?php include_once('footer.php'); ?>
<script src="templates/admin/static/js/link_manage.js?v=<?php echo $version; ?>"></script>

View File

@ -1,117 +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>
</div>
</div>
<!-- 说明提示框END -->
<div class="layui-col-lg12">
<!-- 链接 表格 -->
<table id="category_list_tree" lay-filter="myCategoryTree"></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>
<!-- 表头工具栏 -->
<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>
<!-- 表头工具栏END -->
</div>
<!-- 内容主题区域END -->
</div>
<?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(myCategoryTree)', 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':
add_category();
break;
case 'setPrivate':
// 设为私有,1
set_cat_batch(ids, 1);
break;
case 'setPublic':
// 设为公开0
set_cat_batch(ids, 0);
break;
};
});
});
function add_category() {
layui.use(function () {
var layer = layui.layer;
// 绑定按钮点击事件
add_category_layer = layer.open({
id: 1502,
type: 2,
title: "新增分类",
shadeClose: true,
maxmin: true, //开启最大化最小化按钮
area: ["900px", "660px"],
content:
"/index.php?c=admin&page=add_category",
});
console.log(add_category_layer)
});
}
//设置分类属性,
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>

View File

@ -1,63 +0,0 @@
<!DOCTYPE html>
<html lang="zh-cn" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>OneNav后台登录</title>
<meta name="generator" content="EverEdit" />
<meta name="author" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel='stylesheet' href='static/layui/css/layui.css'>
<link rel='stylesheet' href='templates/admin/static/style.css'>
<style>
body{
/* background:url(templates/admin/static/bg.jpg); */
background-color:rgba(0, 0, 51, 0.8);
}
</style>
</head>
<body>
<div class="layui-container">
<div class="layui-row">
<div class="login-logo">
<h1>登录OneNav</h1>
</div>
<div class="layui-col-lg4 layui-col-md-offset4" style ="margin-top:4em;">
<form class="layui-form layui-form-pane" action="">
<div class="layui-form-item">
<label class="layui-form-label"><i class="layui-icon layui-icon-username"></i></label>
<div class="layui-input-block">
<input type="text" name="user" required lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label"><i class="layui-icon layui-icon-password"></i></label>
<div class="layui-input-block">
<input type="password" name="password" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<button class="layui-btn" lay-submit lay-filter="login" style = "width:100%;">登录</button>
</div>
<div class="layui-form-item layui-hide-sm layui-hide-md layui-hide-lg">
<button class="layui-btn" lay-submit lay-filter="mobile_login" style = "width:100%;">手机登录</button>
</div>
</form>
</div>
</div>
</div>
<script src = 'static/js/jquery.min.js'></script>
<script src = 'static/layui/layui.js'></script>
<script src="templates/admin/static/embed.js"></script>
</body>
</html>

View File

@ -52,7 +52,7 @@ layui.use(["table", "layer", "form", "tree", "util"], function () {
url: uri + "link_list",
method: "post",
//开启分页
page: true,
// page: true,
toolbar: "#linktool",
cols: [
[
@ -65,11 +65,13 @@ layui.use(["table", "layer", "form", "tree", "util"], function () {
title: "ID",
width: 80,
sort: true,
hide: true,
},
{
field: "font_icon",
title: "图标",
width: 60,
hide: true,
templet: function (d) {
if (d.font_icon == null || d.font_icon == "") {
return '<img src="static/images/default.png" width="28" height="28">';
@ -86,29 +88,32 @@ layui.use(["table", "layer", "form", "tree", "util"], function () {
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;
},
hide: true,
},
{
field: "title",
title: "链接标题",
width: 140,
width: 300,
edit: "text",
},
{
field: "url",
title: "URL",
width: 150,
templet: function (d) {
var formatUrl = new URL(d.url);
var showUrl = formatUrl.host + formatUrl.pathname;
var url =
'<a target = "_blank" href = "' +
d.url +
'" title = "' +
showUrl +
'">' +
showUrl +
"</a>";
return url;
},
},
{
field: "add_time",
title: "添加时间",
@ -124,6 +129,7 @@ layui.use(["table", "layer", "form", "tree", "util"], function () {
title: "修改时间",
width: 148,
sort: true,
hide: true,
templet: function (d) {
if (d.up_time == null) {
return "";
@ -180,7 +186,7 @@ layui.use(["table", "layer", "form", "tree", "util"], function () {
ids.push(value.id);
});
switch (obj.event) {
case "addLink":
case "add_link":
layer.open({
type: 2,
title: "添加链接",
@ -190,14 +196,64 @@ layui.use(["table", "layer", "form", "tree", "util"], function () {
content: "/index.php?c=admin&page=link_add",
});
break;
case "setPrivate":
case "set_private":
console.log("set_private");
// 设为私有,1
set_cat_batch(ids, 1);
break;
case "setPublic":
case "set_public":
console.log("set_public");
// 设为公开0
set_cat_batch(ids, 0);
break;
case "reset_query":
// 重置查询
console.log("reset_query");
table.reloadData("link_list_table", {
where: {
f_id: 0,
},
scrollPos: "fixed",
});
break;
}
});
// 行监听事件
table.on("tool(link_list_table_filter)", function (obj) {
// 删除数据
if (obj.event === "del") {
layer.confirm(
"确认删除?",
{
icon: 3,
title: "温馨提示!",
},
function (index) {
$.post(
uri + "del_link",
{
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") {
layer.open({
type: 2,
title: "编辑链接",
shadeClose: true,
maxmin: true, //开启最大化最小化按钮
area: ["900px", "660px"],
content: "/index.php?c=admin&page=link_edit&id=" + obj.data.id,
});
}
});
//新增链接
@ -221,4 +277,25 @@ layui.use(["table", "layer", "form", "tree", "util"], function () {
console.log(data.field); //当前容器的全部表单字段,名值对形式:{name: value}
return false; //阻止表单跳转。如果需要表单跳转,去掉这段即可。
});
//更新链接
form.on("submit(edit_link)", function (data) {
$.post(
"/index.php?c=api&method=edit_link&type=console",
data.field,
function (data, status) {
//如果添加成功
if (data.code == 0) {
layer.msg("已更新!", { icon: 1 });
} else {
layer.msg(data.err_msg, { icon: 5 });
}
}
);
// 刷新表格
parent.layui.table.reloadData("link_list_table");
// 关闭当前 iframe 弹层
parent.layer.close(frame_layer_index);
console.log(data.field); //当前容器的全部表单字段,名值对形式:{name: value}
return false; //阻止表单跳转。如果需要表单跳转,去掉这段即可。
});
});