diff --git a/admin/src/router/index.js b/admin/src/router/index.js index 39e5c2b9..fead9425 100644 --- a/admin/src/router/index.js +++ b/admin/src/router/index.js @@ -322,6 +322,29 @@ export const asyncRoutes = [ } ] }, + { + path: '/announcements', + component: Layout, + redirect: '/announcements/index', + alwaysShow: true, + name: 'announcements', + meta: { + title: '公告管理', + icon: 'el-icon-s-promotion', + roles: ['follow_index', 'log_index', 'editor'] + }, + children: [ + { + path: 'list', + component: () => import('@/views/announcements/list'), + name: 'list', + meta: { + title: '公告列表', + roles: ['follow_index', 'editor'] + } + } + ] + }, { path: '/icon', component: Layout, diff --git a/admin/src/styles/element-ui.scss b/admin/src/styles/element-ui.scss index 49474de3..5a29fc90 100644 --- a/admin/src/styles/element-ui.scss +++ b/admin/src/styles/element-ui.scss @@ -4,7 +4,13 @@ .el-breadcrumb__inner a { font-weight: 400 !important; } - +.opening-announcement { + .el-message-box__header { + .el-message-box__title { + color: red; + } + } +} .el-upload { input[type="file"] { display: none !important; @@ -69,7 +75,7 @@ // dropdown .el-dropdown-menu { a { - display: block + display: block; } } diff --git a/admin/src/utils/storage.js b/admin/src/utils/storage.js new file mode 100644 index 00000000..d6290053 --- /dev/null +++ b/admin/src/utils/storage.js @@ -0,0 +1,74 @@ + +import config from '../../package.json'; + +// 1、window.localStorage 浏览器永久缓存 +export const Local = { + // 查看 v2.4.3版本更新日志 + setKey(key) { + // @ts-ignore + return `${config.name}:${key}`; + }, + // 存储数据到本地缓存,设置过期时间 + setCache(key, value, expireTime) { + const now = new Date().getTime(); + const item = { + value: value, + expire: now + expireTime * 1000 // 过期时间,单位是毫秒 + }; + localStorage.setItem(Local.setKey(key), JSON.stringify(item)); + }, + + // 从本地缓存读取数据,检查是否过期 + getCache(key) { + const itemStr = localStorage.getItem(Local.setKey(key)); + if (itemStr) { + const item = JSON.parse(itemStr); + const now = new Date().getTime(); + if (now < item.expire) { + return item.value; + } else { + // 数据已过期,清除缓存 + localStorage.removeItem(key); + } + } + return null; + }, + // 设置永久缓存 + set(key, val) { + window.localStorage.setItem(Local.setKey(key), JSON.stringify(val)); + }, + // 获取永久缓存 + get(key) { + let json = window.localStorage.getItem(Local.setKey(key)); + return JSON.parse(json); + }, + // 移除永久缓存 + remove(key) { + window.localStorage.removeItem(Local.setKey(key)); + }, + // 移除全部永久缓存 + clear() { + window.localStorage.clear(); + }, +}; + +// 2、window.sessionStorage 浏览器临时缓存 +export const Session = { + // 设置临时缓存 + set(key, val) { + window.sessionStorage.setItem(Local.setKey(key), JSON.stringify(val)); + }, + // 获取临时缓存 + get(key) { + let json = window.sessionStorage.getItem(Local.setKey(key)); + return JSON.parse(json); + }, + // 移除临时缓存 + remove(key) { + window.sessionStorage.removeItem(Local.setKey(key)); + }, + // 移除全部临时缓存 + clear() { + window.sessionStorage.clear(); + }, +}; diff --git a/admin/src/views/announcements/list.vue b/admin/src/views/announcements/list.vue new file mode 100644 index 00000000..12c227c8 --- /dev/null +++ b/admin/src/views/announcements/list.vue @@ -0,0 +1,189 @@ + + + + + diff --git a/admin/src/views/dashboard/admin/index.vue b/admin/src/views/dashboard/admin/index.vue index 67762086..454808fb 100644 --- a/admin/src/views/dashboard/admin/index.vue +++ b/admin/src/views/dashboard/admin/index.vue @@ -1,9 +1,11 @@