plugins/navManager:导航 CRUD + 导航分类 CRUD(独立 blueprint) plugins/friendManager:友情链接 CRUD plugins/aboutManager:关于本站 CRUD plugins/siteStats:访问统计主页 + JSON 接口 + /site/* GET 埋点 + nav 卡片点击埋点 applications/view/public/nav.py:导航聚合页 / 分类详情 / JSON 接口,支持 visit_count 注入 applications/view/public/about.py:关于本站公开页 applications/view/public/friend.py:友情链接公开页 templates/public/base.html:响应式首页(搜索框 / 分类抽屉 / 5 主题切换 / footer 隐私小字) templates/public/index.html / category.html:卡片右下角访问次数 templates/public/about.html / friend.html:关于 + 友链前台页 docs/plugins-development.md:插件开发完整指南(生命周期 + 4 个示例 + FAQ + framework 迁移) scripts/:探针与端到端验证脚本(probe_*/verify_*/test_*)
172 lines
6.3 KiB
HTML
172 lines
6.3 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>友情链接</title>
|
|
{% include 'system/common/header.html' %}
|
|
</head>
|
|
<body class="pear-container">
|
|
<div class="layui-card">
|
|
<div class="layui-card-body">
|
|
<form class="layui-form" action="" lay-filter="friend-query-form">
|
|
<div class="layui-form-item" style="margin-bottom: unset;">
|
|
<label class="layui-form-label">关键词</label>
|
|
<div class="layui-input-inline">
|
|
<input type="text" name="keyword" placeholder="名称/链接/简介" class="layui-input">
|
|
</div>
|
|
<label class="layui-form-label">分类</label>
|
|
<div class="layui-input-inline">
|
|
<input type="text" name="category" placeholder="按分组过滤" class="layui-input">
|
|
</div>
|
|
<button class="layui-btn layui-btn-md" lay-submit lay-filter="friend-query">
|
|
<i class="layui-icon layui-icon-search"></i> 查询
|
|
</button>
|
|
<button type="reset" class="layui-btn layui-btn-primary layui-btn-md">
|
|
<i class="layui-icon layui-icon-refresh"></i> 重置
|
|
</button>
|
|
<button type="button" class="layui-btn layui-btn-normal layui-btn-md" id="btn-add">
|
|
<i class="layui-icon layui-icon-add-1"></i> 新增友链
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="layui-card">
|
|
<div class="layui-card-body">
|
|
<table id="friend-table" lay-filter="friend-table"></table>
|
|
</div>
|
|
</div>
|
|
|
|
{% include 'system/common/footer.html' %}
|
|
{% raw %}
|
|
<script type="text/html" id="col-friend-status">
|
|
{{# if(d.enable === 1){ }}
|
|
<span class="layui-badge layui-bg-green">启用</span>
|
|
{{# } else { }}
|
|
<span class="layui-badge layui-bg-gray">禁用</span>
|
|
{{# } }}
|
|
</script>
|
|
|
|
<script type="text/html" id="col-friend-external">
|
|
{{# if(d.is_external === 1){ }}
|
|
<span class="layui-badge layui-bg-blue">外链</span>
|
|
{{# } else { }}
|
|
<span class="layui-badge">站内</span>
|
|
{{# } }}
|
|
</script>
|
|
|
|
<script type="text/html" id="col-friend-logo">
|
|
{{# if(d.logo){ }}
|
|
<img src="{{ d.logo }}" style="height:24px;max-width:80px;" onerror="this.style.display='none'" />
|
|
{{# } else { }}
|
|
<span style="color:#999">—</span>
|
|
{{# } }}
|
|
</script>
|
|
|
|
<script type="text/html" id="col-friend-op">
|
|
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
|
|
{{# if(d.enable === 1){ }}
|
|
<a class="layui-btn layui-btn-xs layui-btn-warm" lay-event="disable">禁用</a>
|
|
{{# } else { }}
|
|
<a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="enable">启用</a>
|
|
{{# } }}
|
|
<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="remove">删除</a>
|
|
</script>
|
|
{% endraw %}
|
|
|
|
<script>
|
|
layui.use(['table', 'form', 'layer'], function(){
|
|
var table = layui.table;
|
|
var form = layui.form;
|
|
var layer = layui.layer;
|
|
var $ = layui.$;
|
|
|
|
var renderTable = function(){
|
|
var keyword = $('input[name="keyword"]').val() || '';
|
|
var category = $('input[name="category"]').val() || '';
|
|
table.render({
|
|
elem: '#friend-table',
|
|
url: '/system/friend/data',
|
|
where: { keyword: keyword, category: category },
|
|
page: true,
|
|
limit: 20,
|
|
cols: [[
|
|
{field: 'id', title: 'ID', width: 60},
|
|
{field: 'title', title: '名称', width: 180},
|
|
{field: 'logo', title: 'Logo', width: 100, templet: '#col-friend-logo'},
|
|
{field: 'url', title: '链接', minWidth: 220},
|
|
{field: 'description', title: '简介', minWidth: 200},
|
|
{field: 'category', title: '分组', width: 120},
|
|
{field: 'sort', title: '排序', width: 70},
|
|
{field: 'is_external', title: '类型', width: 80, templet: '#col-friend-external'},
|
|
{field: 'enable', title: '状态', width: 80, templet: '#col-friend-status'},
|
|
{field: 'create_at', title: '创建时间', width: 170},
|
|
{fixed: 'right', title: '操作', toolbar: '#col-friend-op', width: 220}
|
|
]],
|
|
skin: 'line',
|
|
text: {none: '暂无友情链接'},
|
|
// table_api 默认返回 {code:0, data, count, msg, limit} 与 Layui 默认 statusCode:0 兼容
|
|
});
|
|
};
|
|
|
|
renderTable();
|
|
|
|
form.on('submit(friend-query)', function(){
|
|
renderTable();
|
|
return false;
|
|
});
|
|
|
|
$('#btn-add').on('click', function(){
|
|
layer.open({
|
|
type: 2,
|
|
title: '新增友情链接',
|
|
area: ['640px', '620px'],
|
|
content: '/system/friend/add'
|
|
});
|
|
});
|
|
|
|
table.on('tool(friend-table)', function(obj){
|
|
var data = obj.data;
|
|
if (obj.event === 'edit'){
|
|
layer.open({
|
|
type: 2,
|
|
title: '编辑友情链接',
|
|
area: ['640px', '620px'],
|
|
content: '/system/friend/edit?friendId=' + data.id
|
|
});
|
|
} else if (obj.event === 'remove'){
|
|
layer.confirm('确定删除该友链吗?', function(idx){
|
|
$.ajax({
|
|
url: '/system/friend/remove/' + data.id,
|
|
type: 'DELETE',
|
|
success: function(res){
|
|
if (res.code === 0 || res.success) { layer.msg(res.msg); obj.del(); }
|
|
else layer.msg(res.msg);
|
|
}
|
|
});
|
|
layer.close(idx);
|
|
});
|
|
} else if (obj.event === 'enable'){
|
|
$.ajax({
|
|
url: '/system/friend/enable',
|
|
type: 'PUT',
|
|
contentType: 'application/json',
|
|
data: JSON.stringify({friendId: data.id}),
|
|
success: function(res){ layer.msg(res.msg); renderTable(); }
|
|
});
|
|
} else if (obj.event === 'disable'){
|
|
$.ajax({
|
|
url: '/system/friend/disable',
|
|
type: 'PUT',
|
|
contentType: 'application/json',
|
|
data: JSON.stringify({friendId: data.id}),
|
|
success: function(res){ layer.msg(res.msg); renderTable(); }
|
|
});
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|