Compare commits

...

4 Commits

Author SHA1 Message Date
Anyon
574427e3ec 修改文件注释 2022-03-11 14:15:01 +08:00
Anyon
a3d52b99c1 修改注释 2022-03-11 14:13:13 +08:00
Anyon
8d7411dbaa 增加后台自定义脚本及样式 2022-03-11 14:09:48 +08:00
Anyon
c7bc315d5c 优化layui.table使用 2022-03-10 19:02:50 +08:00
7 changed files with 60 additions and 16 deletions

View File

@ -12,6 +12,7 @@
<link rel="stylesheet" href="__ROOT__/static/plugs/layui/css/layui.css?at={:date('md')}">
<link rel="stylesheet" href="__ROOT__/static/theme/css/iconfont.css?at={:date('md')}">
<link rel="stylesheet" href="__ROOT__/static/theme/css/console.css?at={:date('md')}">
<link rel="stylesheet" href="__ROOT__/static/extra/style.css?at={:date('md')}">
{block name="style"}{/block}
<script>window.tapiRoot = '{:sysuri("admin/index/index",[],false)}'</script>
<script src="__ROOT__/static/plugs/jquery/pace.min.js"></script>
@ -25,6 +26,7 @@
<script src="__ROOT__/static/plugs/layui/layui.js"></script>
<script src="__ROOT__/static/plugs/require/require.js"></script>
<script src="__ROOT__/static/admin.js"></script>
<script src="__ROOT__/static/extra/script.js"></script>
{block name='script'}{/block}
</body>
</html>

View File

@ -13,6 +13,7 @@
<link rel="stylesheet" href="__ROOT__/static/plugs/layui/css/layui.css?at={:date('md')}">
<link rel="stylesheet" href="__ROOT__/static/theme/css/iconfont.css?at={:date('md')}">
<link rel="stylesheet" href="__ROOT__/static/theme/css/console.css?at={:date('md')}">
<link rel="stylesheet" href="__ROOT__/static/extra/style.css?at={:date('md')}">
{block name="style"}{/block}
<script>window.tapiRoot = '{:sysuri("admin/index/index",[],false)}'</script>
<script src="__ROOT__/static/plugs/jquery/pace.min.js"></script>
@ -54,6 +55,7 @@
<script src="__ROOT__/static/plugs/layui/layui.js"></script>
<script src="__ROOT__/static/plugs/require/require.js"></script>
<script src="__ROOT__/static/admin.js"></script>
<script src="__ROOT__/static/extra/script.js"></script>
{block name='script'}{/block}
</body>

View File

@ -29,13 +29,13 @@ return [
// 数据库类型
'type' => 'mysql',
// 服务器地址
'hostname' => '127.0.0.1',
'hostname' => 'thinkadmin.top',
// 数据库名
'database' => 'admin_v6',
// 用户名
'username' => 'admin_v6',
'username' => 'admin',
// 密码
'password' => 'FbYBHcWKr2',
'password' => '@admin123',
// 端口
'hostport' => '3306',
// 数据库连接参数

View File

@ -36,12 +36,10 @@ if (typeof Array.prototype.forEach !== 'function') {
};
}
/*! 脚本应用根路径 */
/*! 应用根路径,静态插件库路径,动态插件库路径 */
var srcs = document.scripts[document.scripts.length - 1].src.split('/');
window.appRoot = srcs.slice(0, -2).join('/') + '/';
/*! 静态插件库路径 */
window.baseRoot = srcs.slice(0, -1).join('/') + '/';
/*! 动态插件库路径 */
window.tapiRoot = window.tapiRoot || window.appRoot + "admin";
/*! 挂载 layui & jquery 对象 */
@ -247,7 +245,7 @@ $(function () {
if (this.nodeName === 'IMG') this.src = this.dataset.lazySrc;
else this.style.backgroundImage = 'url(' + this.dataset.lazySrc + ')';
}
}), $dom;
}), $body.trigger('reInit', $dom), $dom;
};
/*! 在内容区显示视图 */
this.show = function (html) {
@ -677,24 +675,34 @@ $(function () {
}
// 动态计算最大页数
option.done = function () {
layui.sessionData('pages', {key: table.id, value: this.page.curr || 1}), (table.loading = true);
$table.data('that', this);
layui.sessionData('pages', {key: table.id, value: this.page.curr || 1}), (option.loading = true);
$.form.reInit($table.next()).find('[data-load],[data-queue],[data-action],[data-iframe]').not('[data-table-id]').attr('data-table-id', table.id);
}, option.parseData = function (res) {
if (typeof params.filter === 'function') res.data = params.filter(res.data, res);
var maxp = Math.ceil(res.count / table.limit), curp = layui.sessionData('pages')[option.id] || 1;
if (curp > maxp && curp > 1) table.elem.trigger('reload', {page: {curr: maxp}});
if (!this.page || !this.page.curr) return res;
var curp = this.page.curr, maxp = Math.ceil(res.count / option.limit);
if (curp > maxp && maxp > 1) $table.trigger('reload', {page: {curr: maxp}});
return res;
};
// 实例并绑定的对象
$table.data('this', layui.table.render(bindData(option)));
// 绑定实例重载事件
$table.bind('reload render reloadData', function (evt, opts) {
opts = opts || {}, opts.loading = true;
data = $.extend({}, data, opts.where || {});
if (evt.type === 'render1' || evt.type === 'reloadData') {
layui.table.reloadData(table.id, bindData(opts || {}));
data = $.extend({}, data, (opts = opts || {}).where || {});
opts = bindData($.extend({}, opts, {loading: true}));
if (evt.type.indexOf('reload') > -1) {
var $that = $table.data('that');
if ($that && $that.page && $that.page.jump) {
$that.sort = $that.initSort = opts.initSort;
$that.where = data, $that.loading = opts.loading;
if (opts.page && opts.page.curr) $that.page.curr = opts.page.curr || 1;
$that.page.jump({curr: $that.page.curr, limit: option.limit});
} else {
layui.table.reloadData(table.id, opts);
}
} else {
layui.table.reload(table.id, bindData(opts || {}));
layui.table.reload(table.id, opts);
}
}).bind('row sort tool edit radio toolbar checkbox rowDouble', function (evt, call) {
layui.table.on(evt.type + '(' + table.dataset.id + ')', call)

View File

@ -0,0 +1,28 @@
// --------------------------------------------------
// 自定义后台扩展脚本,需要在加载 admin.js 后载入
// 使用 php think xadmin:install static 时不会更新此文件
// --------------------------------------------------
$(function () {
window.$body = $('body');
/*! 初始化异步加载的内容扩展动作 */
// $body.on('reInit', function (evt, $dom) {
// console.log('Event.reInit', $dom);
// });
/*! 追加 require 配置参数
/*! 加载的文件不能与主配置重复 */
// require.config({
// paths: {
// 'vue': ['plugs/vue/vue.min'],
// },
// shim: {
// 'vue': ['json']
// },
// });
// require(['vue'], function (vue) {
// console.log(vue)
// });
/*! 其他 javascript 脚本代码 */
});

View File

@ -0,0 +1,4 @@
/* --------------------------------------------------
/* 自定义后台扩展新式,需要在加载 console.css 后载入
/* 使用 php think xadmin:install static 时不会更新此文件
/* -------------------------------------------------- */

View File

@ -25,7 +25,7 @@ CKEDITOR.plugins.add("uimage", {
editor.ui.addButton("UploadImage", {label: "上传本地图片", command: 'uimage', icon: 'image', toolbar: 'insert,10'});
setTimeout(function () {
$('#cke_' + editor.name).find('.cke_button__uploadimage_label').parent().map(function () {
$(this).attr('data-type', 'png,jpg,gif').attr('data-file', 'mul').uploadFile(function (url) {
$(this).attr('data-type', 'png,jpg,gif,jpeg').attr('data-file', 'mul').uploadFile(function (url) {
editor.insertElement(CKEDITOR.dom.element.createFromHtml('<span><img style="max-width:100%;border:0" alt="" src="' + url + '"></span>'));
});
});