diff --git a/frontend/assets/dashboard.svg b/frontend/assets/dashboard.svg index 25e6bfa..b6f49ab 100644 --- a/frontend/assets/dashboard.svg +++ b/frontend/assets/dashboard.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/frontend/assets/favicon.svg b/frontend/assets/favicon.svg index a7fc8fc..8189c6e 100644 --- a/frontend/assets/favicon.svg +++ b/frontend/assets/favicon.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/frontend/assets/styles.css b/frontend/assets/styles.css index cd2862a..3fd370c 100644 --- a/frontend/assets/styles.css +++ b/frontend/assets/styles.css @@ -538,8 +538,8 @@ input[type="date"]::-webkit-calendar-picker-indicator:hover{ /* Dashboard icon - SVG */ .icon-dashboard { - width: 20px; - height: 20px; + width: 30px; + height: 30px; display: inline-block; background-image: url('../assets/dashboard.svg'); background-size: contain; diff --git a/frontend/js/api.js b/frontend/js/api.js index 4b53321..2c7f9ba 100644 --- a/frontend/js/api.js +++ b/frontend/js/api.js @@ -155,6 +155,7 @@ const API = (() => { adminUsers: () => request('/admin/users'), resetPassword: (username, new_password) => request('/admin/reset-password', { method: 'POST', body: JSON.stringify({ username, new_password }) }), changePassword: (username, new_password) => request('/admin/change-password', { method: 'POST', body: JSON.stringify({ username, new_password }) }), + deleteUser: username => request('/admin/delete-user', { method: 'POST', body: JSON.stringify({ username }) }), clearModule: module => request('/admin/clear', { method: 'POST', body: JSON.stringify({ module }) }), getNotifications: () => requestQuiet('/notifications'), getUnreadCount: () => requestQuiet('/notifications/unread-count'), diff --git a/frontend/js/components/dashboard.js b/frontend/js/components/dashboard.js index 2afe826..96e42cf 100644 --- a/frontend/js/components/dashboard.js +++ b/frontend/js/components/dashboard.js @@ -35,6 +35,11 @@ const Dashboard = (() => { window.removeEventListener('resize', window.__dashboardResizeHandler); window.__dashboardResizeHandler = null; } + // 清理主题切换监听器 + if(window.__dashboardThemeHandler){ + window.removeEventListener('themeChanged', window.__dashboardThemeHandler); + window.__dashboardThemeHandler = null; + } // 清理全局变量 window.__auditBusy = false; window.__pddParams = null; @@ -271,9 +276,30 @@ const Dashboard = (() => { ctx.fillText('圆通', padding.left + 98, 15); }; + // 初始化缓存数据 + window.__auditCache = window.__auditCache || {pdd: [], yt: []}; + if(pdd.list && pdd.list.length > 0) window.__auditCache.pdd = pdd.list; + if(yt.list && yt.list.length > 0) window.__auditCache.yt = yt.list; + // 初始绘制 drawTrendChart(pdd.list, yt.list); + // 监听主题切换事件,立即重绘图表 + const themeChangeHandler = () => { + // 使用缓存数据或初始数据 + const pddData = (window.__auditCache && window.__auditCache.pdd && window.__auditCache.pdd.length > 0) + ? window.__auditCache.pdd + : pdd.list; + const ytData = (window.__auditCache && window.__auditCache.yt && window.__auditCache.yt.length > 0) + ? window.__auditCache.yt + : yt.list; + drawTrendChart(pddData, ytData); + }; + window.addEventListener('themeChanged', themeChangeHandler); + + // 保存监听器引用以便清理 + window.__dashboardThemeHandler = themeChangeHandler; + // 添加鼠标悬停事件 const canvas = document.getElementById('trend-chart'); const tooltip = document.getElementById('chart-tooltip'); @@ -361,8 +387,7 @@ const Dashboard = (() => { }; } - // 资源管理:缓存数据(已禁用自动清理) - window.__auditCache = window.__auditCache || {pdd: [], yt: []}; + // 资源管理:缓存数据(已在初始化时创建) // 优化的刷新函数:一次请求同时更新趋势图和列表 const refreshAll = async() => { diff --git a/frontend/js/components/settings.js b/frontend/js/components/settings.js index 6457261..d7bd048 100644 --- a/frontend/js/components/settings.js +++ b/frontend/js/components/settings.js @@ -1,7 +1,7 @@ Router.register('/settings', async () => { const me = await API.me().catch(()=>({})); const users = (me && me.role === 'superadmin') ? await API.adminUsers().catch(()=>({list:[]})) : {list:[]}; - const userList = (users.list||[]).map(u=>`