mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2026-06-06 20:18:10 +08:00
将 v6 中直接放在本地 app 的后台与微信能力迁移为 v8 插件组件,并把运行时基础能力沉淀到独立插件包。 主要内容: - 新增 think-library、system、worker、static、install 等基础插件包。 - 新增 account、payment、wechat-client、wechat-service、wemall、wuma 等业务插件包。 - 移除 v6 的 app/admin 与 app/wechat 本地应用实现,改由插件分发接管。 - 将 Helper 能力彻底并入 System,统一为 plugin\system\helper\* 命名空间。 - 同步插件迁移发布清单与根 route 占位,保证安装发布流程可复现。
115 lines
6.6 KiB
PHP
115 lines
6.6 KiB
PHP
// +----------------------------------------------------------------------
|
||
// | Static Plugin for ThinkAdmin
|
||
// +----------------------------------------------------------------------
|
||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||
// +----------------------------------------------------------------------
|
||
// | 官方网站: https://thinkadmin.top
|
||
// +----------------------------------------------------------------------
|
||
// | 开源协议 ( https://mit-license.org )
|
||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||
// +----------------------------------------------------------------------
|
||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-static
|
||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-static
|
||
// +----------------------------------------------------------------------
|
||
|
||
layui.define(function (exports) {
|
||
|
||
let template = '<div class="padding-30 padding-bottom-0" data-queue-load="{{d.code}}"><div class="layui-elip notselect nowrap" data-message-title><b class="color-desc">...</b></div><div class="margin-top-15 layui-progress layui-progress-big" lay-showPercent="yes"><div class="layui-progress-bar transition" lay-percent="0.00%"></div></div>' + '<div class="margin-top-15"><code class="layui-textarea layui-bg-black border-0" style="resize:none;overflow:hidden;height:190px"></code></div></div>';
|
||
|
||
function Queue(code, doScript, element) {
|
||
let queue = this;
|
||
(this.doAjax = true) && (this.doReload = false) || layer.open({
|
||
type: 1, title: false, area: ['560px', '315px'], anim: 2, shadeClose: false, end: function () {
|
||
queue.doAjax = queue.doReload && doScript && $.layTable.reload(((element || {}).dataset || {}).tableId || true) && false;
|
||
}, content: laytpl(template).render({code: code}), success: function ($elem) {
|
||
new Progress($elem, code, queue, doScript);
|
||
}
|
||
});
|
||
}
|
||
|
||
function Progress($elem, code, queue, doScript) {
|
||
let that = this;
|
||
|
||
this.$box = $elem.find('[data-queue-load=' + code + ']');
|
||
if (queue.doAjax === false || this.$box.length < 1) return false;
|
||
|
||
this.$code = this.$box.find('code');
|
||
this.$title = this.$box.find('[data-message-title]');
|
||
this.$percent = this.$box.find('.layui-progress div');
|
||
|
||
// 设置数据缓存
|
||
this.SetCache = function (code, index, value) {
|
||
let ckey = code + '_' + index, ctype = 'admin-queue-script';
|
||
return value !== undefined ? layui.data(ctype, {key: ckey, value: value}) : layui.data(ctype)[ckey] || 0;
|
||
};
|
||
|
||
// 更新任务显示状态
|
||
this.SetState = function (status, message) {
|
||
if (message.indexOf('javascript:') === -1) if (status === 1) {
|
||
that.$title.html('<b class="color-text">' + message + '</b>').addClass('text-center');
|
||
that.$percent.addClass('layui-bg-blue').removeClass('layui-bg-green layui-bg-red');
|
||
} else if (status === 2) {
|
||
if (message.indexOf('>>>') > -1) {
|
||
that.$title.html('<b class="color-blue">' + message + '</b>').addClass('text-center');
|
||
} else {
|
||
that.$title.html('<b class="color-blue">正在处理:</b>' + message).removeClass('text-center');
|
||
}
|
||
that.$percent.addClass('layui-bg-blue').removeClass('layui-bg-green layui-bg-red');
|
||
} else if (status === 3) {
|
||
queue.doReload = true;
|
||
that.$title.html('<b class="color-green">' + message + '</b>').addClass('text-center');
|
||
that.$percent.addClass('layui-bg-green').removeClass('layui-bg-blue layui-bg-red');
|
||
} else if (status === 4) {
|
||
that.$title.html('<b class="color-red">' + message + '</b>').addClass('text-center');
|
||
that.$percent.addClass('layui-bg-red').removeClass('layui-bg-blue layui-bg-green');
|
||
}
|
||
};
|
||
|
||
// 读取任务进度信息
|
||
this.LoadProgress = function () {
|
||
if (queue.doAjax === false || that.$box.length < 1) return false;
|
||
$.form.load(tapiRoot + '/queue/progress', {code: code}, 'post', function (ret) {
|
||
if (parseInt(ret.code, 10) === 200) {
|
||
let data = ret && typeof ret.data === 'object' && ret.data ? ret.data : {};
|
||
let status = parseInt(data.status || '0');
|
||
let progress = parseFloat(data.progress || '0.00');
|
||
let message = typeof data.message === 'string' && data.message.length ? data.message : '>>> 等待任务状态更新 <<<';
|
||
let history = Array.isArray(data.history) ? data.history : [];
|
||
let lines = [];
|
||
for (let idx in history) {
|
||
let line = history[idx] || {}, text = String(line.message || ''), percent = '[ ' + (line.progress || '0.00') + '% ] ';
|
||
if (!text.length) {
|
||
continue;
|
||
}
|
||
if (text.indexOf('javascript:') === -1) {
|
||
lines.push(text.indexOf('>>>') > -1 ? text : percent + text);
|
||
} else if (!that.SetCache(code, idx) && doScript !== false) {
|
||
that.SetCache(code, idx, 1)
|
||
$.form.goto(text);
|
||
}
|
||
}
|
||
if (!isFinite(progress)) {
|
||
progress = 0;
|
||
}
|
||
that.$code.html(lines.length ? '<p class="layui-elip">' + lines.join('</p><p class="layui-elip">') + '</p>' : '<p class="layui-elip color-desc">暂无执行日志</p>').animate({scrollTop: that.$code[0].scrollHeight + 'px'}, 200);
|
||
if (status > 0) {
|
||
that.SetState(status, message);
|
||
that.$percent.attr('lay-percent', progress.toFixed(2) + '%') && layui.element.render();
|
||
status === 3 || status === 4 || setTimeout(that.LoadProgress, Math.floor(Math.random() * 200));
|
||
} else {
|
||
that.$title.html('<b class="color-desc">' + message + '</b>').addClass('text-center');
|
||
that.$percent.attr('lay-percent', progress.toFixed(2) + '%') && layui.element.render();
|
||
setTimeout(that.LoadProgress, Math.floor(Math.random() * 500) + 200);
|
||
}
|
||
return false;
|
||
}
|
||
}, false);
|
||
};
|
||
|
||
// 首页加载进度信息
|
||
this.LoadProgress();
|
||
}
|
||
|
||
exports('taQueue', Queue);
|
||
});
|