diff --git a/.gitignore b/.gitignore index 1debbff..1731c38 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,6 @@ node_modules -*.mjs \ No newline at end of file +*.mjs + +admin \ No newline at end of file diff --git a/package.json b/package.json index c2fc191..6c097c4 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "scripts": { "dev": "vite", "build": "vite build", + "build:prod": "vite build --mode prod", "preview": "vite preview" }, "dependencies": { diff --git a/src/api/admin.js b/src/api/admin.js new file mode 100644 index 0000000..c6e6090 --- /dev/null +++ b/src/api/admin.js @@ -0,0 +1,26 @@ +import { get, post} from "@/util/request" + +export function login(body) { + return post({ + url: '/admin/login', body + }) +} + +export function self() { + return get({ + url: '/admin/self' + }) +} + + +export function adminList() { + return get({ + url: '/admin' + }) +} + +export function addAdmin(body) { + return post({ + url: '/admin', body + }) +} \ No newline at end of file diff --git a/src/api/dept.js b/src/api/dept.js index 7e5b563..da8ee1e 100644 --- a/src/api/dept.js +++ b/src/api/dept.js @@ -1,8 +1,8 @@ -import { get, post} from "@/util/request" - - +import { get } from "@/util/request" export function listSecond() { - return get('/system/dept/second/list') + return get({ + url: '/system/dept/second/list' + }) } diff --git a/src/api/detail.js b/src/api/detail.js index 6204f37..f9aa0d5 100644 --- a/src/api/detail.js +++ b/src/api/detail.js @@ -1,4 +1,7 @@ import { get, post} from "@/util/request" + export function getdetail(id) { - return post('/mailbox/detail',id) + return post({ + url: '/mailbox/detail?id=' + id + }) } diff --git a/src/api/holiday.js b/src/api/holiday.js index b717396..ea94b47 100644 --- a/src/api/holiday.js +++ b/src/api/holiday.js @@ -1,10 +1,17 @@ import { get, post} from "@/util/request" export function getholiday(search) { - return get('/outer/holiday/getholiday?search='+search) + return get({ + url: '/outer/holiday/getholiday?search='+search + }) } export function showholiday() { - return get('/outer/holiday/showholiday') + return get({ + url: '/outer/holiday/show-holiday' + }) } -export function saveholiday(search) { - return post('/outer/holiday/saveholiday',search) +export function refreshHoliday(body) { + return post({ + url: '/outer/holiday/refresh-holiday', + body + }) } diff --git a/src/api/mail.js b/src/api/mail.js index cfa63d4..255f61a 100644 --- a/src/api/mail.js +++ b/src/api/mail.js @@ -1,8 +1,7 @@ import { get, post} from "@/util/request" - - -export function addMail(body) { - return post('/mailbox/add', body) +export function listMail(query) { + return get({ + url: '/mail/list', query + }) } - diff --git a/src/api/mail12345.js b/src/api/mail12345.js new file mode 100644 index 0000000..46c018c --- /dev/null +++ b/src/api/mail12345.js @@ -0,0 +1,19 @@ +import { get, post } from "@/util/request" + +export function mail12345List(query) { + return get({ + url: '/mail12345', query + }) +} + +export function mail12345Import(body) { + return post({ + url: '/mail12345/import', body + }) +} + +export function addMail12345(body) { + return post({ + url: '/mail12345/add', body + }) +} \ No newline at end of file diff --git a/src/api/user.js b/src/api/user.js new file mode 100644 index 0000000..75e62af --- /dev/null +++ b/src/api/user.js @@ -0,0 +1,13 @@ +import { get, post} from "@/util/request" + +export function listUser(query) { + return get({ + url: '/user/list', query + }) +} + +export function delUser(id) { + return post({ + url: '/user/del?id=' + id + }) +} \ No newline at end of file diff --git a/src/assets/style/element.scss b/src/assets/style/element.scss index 9dc003e..957e5a6 100644 --- a/src/assets/style/element.scss +++ b/src/assets/style/element.scss @@ -1,8 +1,79 @@ -// @/styles/element/index.scss @forward "element-plus/theme-chalk/src/common/var.scss" with ( $colors: ( "primary": ( "base": #162582, - ) + ), + 'success': ( + 'base': #064D00, + ), + 'danger': ( + 'base': #F60000, + ), + 'warning': ( + 'base': #D05200, + ), ) -); \ No newline at end of file +); + + + +.el-date-editor.el-input__wrapper { + --el-date-editor-daterange-width: 260px; +} + +.el-select { + min-width: 80px; +} +.el-select-dropdown .el-select-dropdown__wrap { + max-height: 380px; +} + +.el-radio { + color: #333; +} + +.el-button--primary.is-link>span { + font-weight: bold; +} + +div.el-table { + --el-table-header-bg-color: #EBEEFC; + --el-table-header-text-color: var(--primary-color); + + .el-table__header .el-table__cell { + padding: 20px 0; + font-size: 15px; + } + .text-no-ellipsis .cell { + text-overflow: clip; + } +} + +div.el-card { + border: none; +} + +.el-dialog { + .el-dialog__header { + margin-right: 0; + .el-dialog__headerbtn { + font-size: 20px; + + &:hover .el-dialog__close { + color: var(--danger-color); + } + } + } + + &.dialog-header-nopadding { + &>.el-dialog__header { + padding: 0; + margin-right: 0; + } + + &>.el-dialog__body { + padding-left: 0; + padding-right: 0; + } + } +} \ No newline at end of file diff --git a/src/assets/style/style.scss b/src/assets/style/style.scss index 6f7692f..bab5095 100644 --- a/src/assets/style/style.scss +++ b/src/assets/style/style.scss @@ -1,8 +1,13 @@ +@import 'element-plus/theme-chalk/el-message.css'; +@import 'element-plus/theme-chalk/el-message-box.css'; + :root:root { - --primary-color: #184DCF; + --primary-color: #162582; --van-blue: var(--primary-color); --van-tabs-bottom-bar-width: 60px; --background-color: #ededed; + --header-height: 80px; + --aside-width: 7.3vw; } body { @@ -96,9 +101,12 @@ svg+span { .text-wrap { white-space: pre-wrap; } +.text-danger { + color: red; +} .container { - padding: 18px 36px; + padding: 20px; } .pointer:hover { @@ -137,6 +145,9 @@ svg+span { margin-right: 20px; } +.mt-4 { + margin-top: 4px; +} .mt-8 { margin-top: 8px; } @@ -160,6 +171,9 @@ svg+span { .mb-20 { margin-bottom: 20px; } +.mb-24 { + margin-bottom: 24px; +} .mb-40 { margin-bottom: 40px; @@ -208,4 +222,11 @@ svg+span { height: 100vh; background-color: var(--background-color); overflow: auto; +} + +.row { + display: flex; + .col-12 { + width: 50%; + } } \ No newline at end of file diff --git a/src/components/AddMail.vue b/src/components/AddMail.vue index 3084364..3ad6063 100644 --- a/src/components/AddMail.vue +++ b/src/components/AddMail.vue @@ -1,178 +1,158 @@ \ No newline at end of file diff --git a/src/components/LoginView.vue b/src/components/LoginView.vue deleted file mode 100644 index baa0d36..0000000 --- a/src/components/LoginView.vue +++ /dev/null @@ -1,140 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/components/MailEtl.vue b/src/components/MailEtl.vue index ee02f4c..0012548 100644 --- a/src/components/MailEtl.vue +++ b/src/components/MailEtl.vue @@ -1,216 +1,239 @@ - - \ No newline at end of file + id: "", + mailId: "", + success: "", + }; +}; + \ No newline at end of file diff --git a/src/components/ManageMail.vue b/src/components/ManageMail.vue deleted file mode 100644 index cbadd57..0000000 --- a/src/components/ManageMail.vue +++ /dev/null @@ -1,275 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/components/ManageUser.vue b/src/components/ManageUser.vue deleted file mode 100644 index b206bd2..0000000 --- a/src/components/ManageUser.vue +++ /dev/null @@ -1,281 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/layout/Index.vue b/src/layout/Index.vue index 86e98b0..d9ca599 100644 --- a/src/layout/Index.vue +++ b/src/layout/Index.vue @@ -1,43 +1,58 @@ \ No newline at end of file diff --git a/src/main.js b/src/main.js index 61ee9ba..e9cbcc7 100644 --- a/src/main.js +++ b/src/main.js @@ -10,9 +10,11 @@ import piniaPersist from 'pinia-plugin-persist' import './assets/style/style.scss' import 'element-plus/theme-chalk/src/message.scss' -createApp(App) - .use(router) +const app = createApp(App); +const p = createPinia().use(piniaPersist) + +app.use(router) .use(ElementPlus, { locale: zhCn }) - .use(createPinia().use(piniaPersist)) + .use(p) .component('Icon', IconComponent) .mount('#app') diff --git a/src/router/index.js b/src/router/index.js index b95e4be..303fb95 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -2,7 +2,6 @@ import { createRouter, createWebHashHistory } from 'vue-router' import { getActivePinia } from 'pinia'; import { useTokenStore } from "@/stores/useTokenStore"; -import Home from '@/views/Home.vue' import Layout from '@/layout/Index.vue' import NotFound from '@/views/error/404.vue' @@ -16,33 +15,29 @@ const constantRoutes = [ children: [ { path: '/', - component: () => import('@/components/ManageMail.vue'), + component: () => import('@/views/Mail12345.vue'), }, { - path: '/mailbox', - component: () => import('@/components/ManageMail.vue'), + path: '/mail', + component: () => import('@/views/ManageMail.vue') }, { - path: '/mailbox/detail/:id', - component: () => import('@/components/MailDetail.vue') + path: '/admin', + component: () => import('@/views/Admin.vue') }, { path: '/user', - component: () => import('@/components/ManageUser.vue') + component: () => import('@/views/ManageUser.vue') }, { path: '/holiday', component: () => import('@/components/HolidayList.vue') - }, - { - path: '/mail_etl', - component: () => import('@/components/MailEtl.vue') } ] }, { path: '/login', - component: () => import('@/components/LoginView.vue') + component: () => import('@/views/Login.vue') }, { path: '/:catchAll(.*)', @@ -59,14 +54,6 @@ const router = createRouter({ }); router.beforeEach((to, from, next) => { - const data = sessionStorage.getItem('token'); - console.log(data); - const tokens = useTokenStore(getActivePinia()); - const refreshToken = tokens.refresh_token; - if (!refreshToken && to.path !== '/login') { - next('/login'); - } else { - next(); - } + next(); }); -export default router; +export default router; \ No newline at end of file diff --git a/src/stores/useTokenStore.js b/src/stores/useTokenStore.js index 3a6ada2..7f47b82 100644 --- a/src/stores/useTokenStore.js +++ b/src/stores/useTokenStore.js @@ -22,7 +22,7 @@ export const useTokenStore = defineStore('token', { strategies: [ { storage: localStorage, - key: 'token' + key: 'admin_token' } ] } diff --git a/src/util/cache.js b/src/util/cache.js new file mode 100644 index 0000000..f7e6335 --- /dev/null +++ b/src/util/cache.js @@ -0,0 +1,22 @@ +const cache = { + //设置缓存(expire为缓存时效) + set(key, value) { + try { + window.localStorage.setItem(key, value) + } catch (e) { + + } + }, + get(key) { + try { + return window.localStorage.getItem(key) + } catch (e) { + return null + } + }, + remove(key) { + window.localStorage.removeItem(key) + } +} + +export default cache diff --git a/src/util/request.js b/src/util/request.js index b17c8fe..9d1a515 100644 --- a/src/util/request.js +++ b/src/util/request.js @@ -1,54 +1,97 @@ -const basePath = '/api' -export function post(url, data) { - return new Promise((resolve, reject) => { - fetch(`${basePath}${url}`, { - method: 'POST', - body: data ? JSON.stringify(data) : '', - }) - // .then(res => { - // return res.json(); - // }).then(res => { - // if (res.ok()) { - // resolve(res) - // } else { - // reject(res) - // } - // }) - .then(res => { - resolve(res); - }).catch(e => { - console.error("请求失败了,详细信息:" + JSON.stringify(e)); - reject(e); - }) - }) + +import { + ElMessage, + ElMessageBox +} from 'element-plus' +import { getToken } from './token' + +const BASE_PATH = '/admin-api' +export function get(options) { + options.method = 'GET'; + return ajax(options.url, options) +} + +export function post(options) { + options.method = 'POST'; + return ajax(options.url, options) +} + +function put(options) { + options.method = 'PUT'; + return ajax(options.url, options) +} + +function del(options) { + options.method = 'DELETE'; + return ajax(options.url, options) } -export function get(url) { + +let isRelogin = false; +function ajax(url, options) { + const headers = { + "Content-Type": "application/json", + "Authorization": getToken() + }; + + let body; + if (options?.params && Object.keys(options.params).length > 0) { + if (options.method === 'GET') { + options.query = options.params; + } else { + body = JSON.stringify(options.params); + } + } + if (options?.query) { + url += (url.indexOf('?') > -1 ? '' : '?') + new URLSearchParams(options.query).toString(); + } + if (options?.body) { + if (options.body === 'string' || options.body instanceof FormData) { + body = options.body; + } else { + if (Object.keys(options.body).length > 0) { + body = JSON.stringify(options.body); + } + } + } return new Promise((resolve, reject) => { - fetch(`${basePath}${url}`, { - method: 'GET', + fetch(`${BASE_PATH}${url}`, { + method: options.method, + body: body, + headers: { ...headers, ...options.headers } + }).then(response => { + if (response.status === 413) { + + return; + } + return response.json(); + }).then(res => { + if (res.code === 200) { + resolve(res.data) + } else { + let message = res.msg; + if (res.code === 401) { + if (url === '/admin/self') { + feedback.msgError('登录状态已过期') + reject(res) + return + } + if (!isRelogin) { + isRelogin = true + ElMessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '温馨提示', { confirmButtonText: '重新登录', cancelButtonText: '取消', type: 'warning' }).then(() => { + isRelogin = false; + // 调整登录 + location.href = process.env.VITE_BASE + "#/login"; + }).catch(() => { + isRelogin = false; + }); + } + reject(res) + return + } + ElMessage.error(message || '系统异常') + reject(res) + } + }) - .then(res => { - let data = res.text();//转成字符串判断 - return data.then(r => { - if (r.length === 0) return null; - else return JSON.parse(r); - }) - }) - // .then(res => { - // return res.json(); - // }) - // .then(res => { - // if (res.ok()) { - // resolve(res) - // } else { - // reject(res) - // } - // }) - .then(res => { - resolve(res); - }).catch(e => { - console.error("请求失败了,详细信息:" + JSON.stringify(e)); - reject(e); - }) }) } \ No newline at end of file diff --git a/src/util/token.js b/src/util/token.js new file mode 100644 index 0000000..55efdcd --- /dev/null +++ b/src/util/token.js @@ -0,0 +1,10 @@ +import cache from './cache' + +const TOKEN_KEY = 'token'; +export function getToken() { + return cache.get(TOKEN_KEY) +} + +export function setToken(val) { + return cache.set(TOKEN_KEY, val) +} \ No newline at end of file diff --git a/src/views/Admin.vue b/src/views/Admin.vue new file mode 100644 index 0000000..790ae73 --- /dev/null +++ b/src/views/Admin.vue @@ -0,0 +1,153 @@ + + + \ No newline at end of file diff --git a/src/views/Login.vue b/src/views/Login.vue new file mode 100644 index 0000000..d29aa53 --- /dev/null +++ b/src/views/Login.vue @@ -0,0 +1,126 @@ + + + + + \ No newline at end of file diff --git a/src/views/Mail12345.vue b/src/views/Mail12345.vue new file mode 100644 index 0000000..578cd3c --- /dev/null +++ b/src/views/Mail12345.vue @@ -0,0 +1,325 @@ + + + \ No newline at end of file diff --git a/src/views/ManageMail.vue b/src/views/ManageMail.vue new file mode 100644 index 0000000..7a905be --- /dev/null +++ b/src/views/ManageMail.vue @@ -0,0 +1,302 @@ + + + \ No newline at end of file diff --git a/src/views/ManageUser.vue b/src/views/ManageUser.vue new file mode 100644 index 0000000..0c81695 --- /dev/null +++ b/src/views/ManageUser.vue @@ -0,0 +1,152 @@ + + + \ No newline at end of file diff --git a/vite.config.js b/vite.config.js index 839ca10..3c756fc 100644 --- a/vite.config.js +++ b/vite.config.js @@ -51,6 +51,8 @@ export default ({ mode }) => { host: '0.0.0.0', proxy: { '/admin-api': { + // http://118.253.151.67:8989/admin-api + // http://127.0.0.1:8083 target: 'http://127.0.0.1:8083', changeOrigin: true, rewrite: (p) => p.replace(/^\/admin-api/, '')