diff --git a/class/Api.php b/class/Api.php
index e89c763..9aef3e1 100755
--- a/class/Api.php
+++ b/class/Api.php
@@ -156,9 +156,26 @@ class Api {
$count = $this->db->count("on_links", [
"fid" => $id
]);
+
+ // 获取分类信息
+ $category = $this->db->get("on_categorys", ["id", "fid"], ["id" => $id]);
+
+ // 如果分类不存在
+ if (empty($category)) {
+ $this->err_msg(-1007, 'The category does not exist!');
+ }
+
+ //检查该分类下是否还存在子分类
+ $sub_category_count = $this->db->count("on_categorys", [
+ "fid" => $id
+ ]);
+ //如果存在子分类,则不允许删除
+ if($sub_category_count > 0) {
+ $this->err_msg(-2000,'请先删除下面的子分类!');
+ }
//如果分类目录下存在数据,则不允许删除
if($count > 0) {
- $this->err_msg(-1006,'The category is not empty and cannot be deleted!');
+ $this->err_msg(-1006,'此分类下存在链接,不允许删除!');
}
else{
$data = $this->db->delete('on_categorys',[ 'id' => $id] );
diff --git a/controller/admin.php b/controller/admin.php
index a44fd75..9bd6b9f 100755
--- a/controller/admin.php
+++ b/controller/admin.php
@@ -39,7 +39,7 @@ if( $page == 'index' ) {
}
//如果页面是修改edit_category
-if ( ($page == 'edit_category') || ($page == 'edit_category_new') ) {
+if ( ($page == 'edit_category') || ($page == 'edit_category_new') || ($page == 'add_category_new') ) {
//获取id
$id = intval($_GET['id']);
//查询单条分类信息
@@ -137,7 +137,7 @@ if ( $page == "link_list" ) {
}
//如果页面是添加链接页面
-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') || ($page == "add_link_new") ) {
//查询所有分类信息
$categorys = $db->select('on_categorys','*',[ 'ORDER' => ['weight' => 'DESC'] ]);
//checked按钮
diff --git a/data/update.log b/data/update.log
index ed4ee20..d292829 100755
--- a/data/update.log
+++ b/data/update.log
@@ -1,3 +1,9 @@
+2025.05.15
+1. 【后台 - 分类列表】,添加了添加分类按钮
+2. 删除分类时,如果下面存在子分类,则不允许删除
+3. 分类列表现在支持批量删除操作
+4. 我的链接页面新增了添加分类和添加链接按钮
+
2025.03.07
1. 搜索支持Ctrl + Enter提交
2. 新增缓存函数
diff --git a/templates/admin/add_category_new.php b/templates/admin/add_category_new.php
new file mode 100755
index 0000000..64046ef
--- /dev/null
+++ b/templates/admin/add_category_new.php
@@ -0,0 +1,107 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/templates/admin/add_link_new.php b/templates/admin/add_link_new.php
new file mode 100755
index 0000000..8be94e1
--- /dev/null
+++ b/templates/admin/add_link_new.php
@@ -0,0 +1,106 @@
+
+
+
+
+
+
+
+
+
1. 权重越大,排序越靠前
+
2. 识别功能可以自动获取链接标题和描述信息,但不确保一定成功
+
3. 仅 default2/5iux/heimdall/tushan2/webstack 支持自定义图标,其余主题均自动获取链接图标。
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/templates/admin/category_list.php b/templates/admin/category_list.php
index 7efc6f4..88602ca 100755
--- a/templates/admin/category_list.php
+++ b/templates/admin/category_list.php
@@ -22,8 +22,10 @@
@@ -58,6 +60,63 @@ layui.use(['table','layer','form'], function(){
case 'setPublic':
// 设为公开,0
set_cat_batch(ids,0);
+ case 'addCategory':
+ // 添加分类
+ layer.open({
+ type: 2,
+ title: '添加分类',
+ shadeClose: true,
+ shade: 0.8,
+ area: ['700px', '780px'],
+ content: '/index.php?c=admin&page=add_category_new',
+ end: function(index, layero){
+ // 刷新分类数据页面
+ table.reloadData('category_list', {
+ where: {
+ abc: '123456',
+ },
+ scrollPos: 'fixed', // 保持滚动条位置不变 - v2.7.3 新增
+ });
+ layer.close(index);
+ }
+ });
+ case 'delSelect':
+
+ // 删除选中
+ if( ids.length === 0 ) {
+ layer.msg("请先选择分类!",{icon:5});
+ }
+
+ else{
+ let msg = `
+ 确认删除选中的分类吗?
+
+ 此操作只会删除空分类!
+ 如果分类下存在链接会删除失败!
+ 如果分类下存在子分类会删除失败!
+
+ `;
+ layer.confirm(msg,{icon: 3, title:'温馨提示!'}, function(index){
+ for (let i = 0; i < data.length; i++) {
+
+ $.ajax({
+ 'url': '/index.php?c=api&method=del_category',
+ 'type': 'POST',
+ 'async': false,
+ 'data':{'id':ids[i]}
+ });
+
+ }
+ layer.open({
+ title: '温馨提醒'
+ ,content: '选中分类已删除!',
+ yes: function(index, layero){
+ window.location.reload();
+ layer.close(index); //如果设定了yes回调,需进行手工关闭
+ }
+ });
+ });
+ }
break;
};
});
diff --git a/templates/admin/link_list.php b/templates/admin/link_list.php
index 9520616..03c2e3e 100755
--- a/templates/admin/link_list.php
+++ b/templates/admin/link_list.php
@@ -79,6 +79,8 @@
设为私有
设为公有
重置查询
+
添加分类
+
添加链接
diff --git a/templates/admin/static/embed.js b/templates/admin/static/embed.js
index 90b0fd0..bfdc1bb 100755
--- a/templates/admin/static/embed.js
+++ b/templates/admin/static/embed.js
@@ -124,7 +124,7 @@ layui.use(['element','table','layer','form','upload','iconHhysFa'], function(){
obj.del();
}
else{
- layer.msg(data.err_msg);
+ layer.msg(data.err_msg,{icon:5});
}
});
layer.close(index);
@@ -319,6 +319,38 @@ layui.use(['element','table','layer','form','upload','iconHhysFa'], function(){
//调用函数设为公有
set_link_attribute(ids,0);
break;
+ case "addCategory":
+ //用户点击添加分类按钮,打开一个弹窗操作
+ // 添加分类
+ layer.open({
+ type: 2,
+ title: '添加分类',
+ shadeClose: true,
+ shade: 0.8,
+ area: ['700px', '780px'],
+ content: '/index.php?c=admin&page=add_category_new'
+ });
+ break;
+ case "addLink":
+ layer.open({
+ type: 2,
+ title: '添加链接',
+ shadeClose: true,
+ shade: 0.8,
+ area: ['1200px', '780px'],
+ content: '/index.php?c=admin&page=add_link_new',
+ end: function(index, layero){
+ // 刷新分类数据页面
+ table.reloadData('link_list', {
+ where: {
+ abc: '123456',
+ },
+ scrollPos: 'fixed', // 保持滚动条位置不变 - v2.7.3 新增
+ });
+ layer.close(index);
+ }
+ });
+ break;
case 'isAll':
layer.msg(checkStatus.isAll ? '全选': '未全选');
break;
diff --git a/version.txt b/version.txt
index 47ff858..9b44705 100755
--- a/version.txt
+++ b/version.txt
@@ -1 +1 @@
-v1.1.2-20250307
\ No newline at end of file
+v1.1.3-20250515
\ No newline at end of file