2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 11:27:17 +08:00

feat: optimize views

This commit is contained in:
耗子
2023-07-04 02:09:35 +08:00
parent 86d5d22209
commit a46fec9016
7 changed files with 33 additions and 28 deletions

View File

@@ -7,6 +7,7 @@ import (
"github.com/goravel/framework/facades"
"panel/app/models"
"panel/app/services"
"panel/packages/helpers"
)
@@ -63,7 +64,20 @@ func (r *InfoController) HomePlugins(ctx http.Context) {
return
}
Success(ctx, plugins)
type pluginsData struct {
models.Plugin
Name string `json:"name"`
}
var pluginsJson []pluginsData
for _, plugin := range plugins {
pluginsJson = append(pluginsJson, pluginsData{
Plugin: plugin,
Name: services.NewPluginImpl().GetBySlug(plugin.Slug).Name,
})
}
Success(ctx, pluginsJson)
}
func (r *InfoController) NowMonitor(ctx http.Context) {

View File

@@ -796,6 +796,12 @@ layui.define('view', function (exports) {
admin.events.refresh()
}
}
// 清理所有定时器
var highestTimeoutId = setTimeout('')
for (var i = 0; i < highestTimeoutId; i++) {
clearTimeout(i)
}
})
//点击事件

View File

@@ -63,10 +63,13 @@ layui.define(['laytpl', 'layer'], function (exports) {
delete options.success
delete options.error
options.data = JSON.stringify(options.data)
if (options.type === 'post' || options.type === 'put' || options.type === 'delete' || options.type === 'patch' || options.type === 'POST' || options.type === 'PUT' || options.type === 'DELETE' || options.type === 'PATCH') {
options.contentType = 'application/json'
options.data = JSON.stringify(options.data)
}
return $.ajax($.extend({
type: 'get', dataType: 'json', contentType: 'application/json', success: function (res) {
type: 'get', dataType: 'json', success: function (res) {
var statusCode = response.statusCode
//只有 response 的 code 一切正常才执行 done

View File

@@ -81,7 +81,7 @@ Date: 2023-06-22
<script type="text/html" template lay-url="/api/panel/info/homePlugins">
{{# layui.each(d.data, function(index, item){ }}
<li class="layui-col-xs4 layui-col-md2 layui-col-sm4">
<a lay-href="/plugin/{{ item.slug }}">
<a lay-href="/plugins/{{ item.slug }}">
<i class="layui-icon layui-icon-engine"></i>
<cite>{{ item.name }}</cite>
</a>
@@ -178,7 +178,6 @@ Date: 2023-06-22
</div>
<script>
var home_timer
var uptime_1 = '获取中', uptime_5 = '获取中', uptime_15 = '获取中'
var net_send = 0, net_recv = 0, net_send_last = 0, net_recv_last = 0
@@ -260,11 +259,8 @@ Date: 2023-06-22
})
}
// 先执行一次
refresh_home_info(true)
// 然后设置个定时器3s一次刷新
clearInterval(home_timer)
home_timer = setInterval(refresh_home_info, 3000)
setInterval(refresh_home_info, 3000)
// 获取系统信息,这部分信息无需更新。
layui.use(['index', 'jquery', 'admin', 'carousel'], function () {
let $ = layui.jquery

View File

@@ -1,5 +1,5 @@
<script type="text/html" template>
<link rel="stylesheet" href="/res/adminui/src/css/login.css?v={{ layui.admin.v }}" media="all">
<link rel="stylesheet" href="/panel/adminui/src/css/login.css?v={{ layui.admin.v }}" media="all">
</script>
@@ -52,14 +52,6 @@
// 设置面板名称
$('#panel-login-name').text(setter.name);
// 判断并清除定时器
if (typeof home_timer !== 'undefined') {
clearInterval(home_timer);
}
if (typeof install_plugin_timer !== 'undefined') {
clearInterval(install_plugin_timer);
}
form.render();
//提交
@@ -93,7 +85,8 @@
* 所以这里强制刷新到主页
* location.hash = search.redirect ? decodeURIComponent(search.redirect) : '/';
*/
location.href = '/';
//location.href = '/';
location.hash = search.redirect ? decodeURIComponent(search.redirect) : '/';
});
}
});

View File

@@ -1,5 +1,5 @@
<script type="text/html" template>
<link rel="stylesheet" href="/res/adminui/src/css/login.css?v={{ layui.admin.v }}" media="all">
<link rel="stylesheet" href="/panel/adminui/src/css/login.css?v={{ layui.admin.v }}" media="all">
</script>
@@ -21,13 +21,6 @@
<script>
layui.use(['admin'], function () {
let admin = layui.admin
// 判断并清除定时器
if (typeof home_timer !== 'undefined') {
clearInterval(home_timer)
}
if (typeof install_plugin_timer !== 'undefined') {
clearInterval(install_plugin_timer)
}
setTimeout(function () {
admin.exit()
window.location = '/'

View File

@@ -72,7 +72,7 @@
table.on('tool(panel-plugin)', function (obj) {
let data = obj.data
if (obj.event === 'open') {
location.hash = '/plugin/' + data.slug
location.hash = '/plugins/' + data.slug
} else if (obj.event === 'install') {
layer.confirm('确定安装该插件吗?', function (index) {
layer.close(index)