diff --git a/frontend/.env.development b/frontend/.env.development index ff01826..072e0f8 100644 --- a/frontend/.env.development +++ b/frontend/.env.development @@ -1,3 +1,2 @@ NODE_ENV='development' VITE_TITLE="" -VITE_URL="http://localhost:8081" \ No newline at end of file diff --git a/frontend/.env.production b/frontend/.env.production index d3cfdcc..444ec20 100644 --- a/frontend/.env.production +++ b/frontend/.env.production @@ -1,3 +1,2 @@ NODE_ENV='production' VITE_TITLE="" -VITE_URL="http://www.test.com" \ No newline at end of file diff --git a/frontend/package.json b/frontend/package.json index f46e7b9..809d047 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -15,6 +15,7 @@ "dependencies": { "@element-plus/icons-vue": "^2.3.1", "axios": "^1.7.3", + "crypto-js": "^4.2.0", "element-plus": "^2.7.8", "pinia": "^2.2.1", "pinia-plugin-persistedstate": "^3.2.1", @@ -33,6 +34,7 @@ "eslint-plugin-vue": "^9.23.0", "npm-run-all2": "^6.2.0", "postcss": "^8.4.41", + "sass": "^1.77.8", "tailwindcss": "^3.4.7", "typescript": "~5.4.0", "vite": "^5.3.1", diff --git a/frontend/src/api/user/index.ts b/frontend/src/api/user/index.ts index 0ccd9d3..15531ec 100644 --- a/frontend/src/api/user/index.ts +++ b/frontend/src/api/user/index.ts @@ -1,4 +1,4 @@ -import request from '@/utils/http' +import createAxios from '@/utils/http' import { useUserInfoStore } from '@/stores/user' import { sm3Digest } from '@/assets/commjs/sm3.js' import { sm2, encrypt } from '@/assets/commjs/sm2.js' @@ -11,7 +11,7 @@ export const publicKey = (params?: any) => { loginName: encrypt(userInfo.loginName), } } - return request({ + return createAxios({ url: '/user/generateSm2Key', method: 'get', params, @@ -30,7 +30,7 @@ export const pwdSm3 = async (pwd: any, loginName?: string) => { export const login = async (params: any) => { params.password = await pwdSm3(params.password, params.username) params.username = encrypt(params.username) - return request({ + return createAxios({ url: '/pqs-auth/oauth/token', method: 'post', params, @@ -40,7 +40,7 @@ export const login = async (params: any) => { //获取用户信息 export const getUserById = () => { const userInfo = useUserInfoStore() - return request({ + return createAxios({ url: '/user-boot/user/getUserById?id=' + userInfo.userIndex, method: 'get', }) diff --git a/frontend/src/assets/font/DongFangDaKai-Regular.woff b/frontend/src/assets/font/DongFangDaKai-Regular.woff new file mode 100644 index 0000000..ac40fe6 Binary files /dev/null and b/frontend/src/assets/font/DongFangDaKai-Regular.woff differ diff --git a/frontend/src/assets/font/DongFangDaKai-Regular.woff2 b/frontend/src/assets/font/DongFangDaKai-Regular.woff2 new file mode 100644 index 0000000..7901e46 Binary files /dev/null and b/frontend/src/assets/font/DongFangDaKai-Regular.woff2 differ diff --git a/frontend/src/assets/font/MFBanHei.ttf b/frontend/src/assets/font/MFBanHei.ttf new file mode 100644 index 0000000..fa1d281 Binary files /dev/null and b/frontend/src/assets/font/MFBanHei.ttf differ diff --git a/frontend/src/assets/images/login/background.png b/frontend/src/assets/images/login/background.png new file mode 100644 index 0000000..be0d12b Binary files /dev/null and b/frontend/src/assets/images/login/background.png differ diff --git a/frontend/src/assets/styles/tailMain.css b/frontend/src/assets/styles/tailMain.css index bd6213e..855175a 100644 --- a/frontend/src/assets/styles/tailMain.css +++ b/frontend/src/assets/styles/tailMain.css @@ -1,3 +1,19 @@ @tailwind base; @tailwind components; -@tailwind utilities; \ No newline at end of file +@tailwind utilities; + + +/* 申明字体为东方大楷 */ +@font-face { + font-family: 'DongFangDaKai'; + src: url('@/assets/font/DongFangDaKai-Regular.woff') format('woff'), + url('@/assets/font/DongFangDaKai-Regular.woff2') format('woff2'); + font-weight: normal; + font-style: normal; +} + +@font-face { + font-family: "MFBanHei"; /* Project id 1513211 */ + src: url('@/assets/font/MFBanHei.ttf?t=1643094287456') format('truetype'); +} + diff --git a/frontend/src/constants/localStore.ts b/frontend/src/constants/localStore.ts deleted file mode 100644 index b8ceb35..0000000 --- a/frontend/src/constants/localStore.ts +++ /dev/null @@ -1 +0,0 @@ -/*文件说明:本文件用来定义一些本地缓存的key*/ diff --git a/frontend/src/stores/constant/cacheKey.ts b/frontend/src/constants/storeKey.ts similarity index 100% rename from frontend/src/stores/constant/cacheKey.ts rename to frontend/src/constants/storeKey.ts diff --git a/frontend/src/constants/user.ts b/frontend/src/constants/user.ts new file mode 100644 index 0000000..b785286 --- /dev/null +++ b/frontend/src/constants/user.ts @@ -0,0 +1,6 @@ +/** + * 用户相关的一些常量 + */ + +// 请求头token拼接的前缀 +export const TOKEN_PREFIX = 'bearer ' \ No newline at end of file diff --git a/frontend/src/main.ts b/frontend/src/main.ts index 5408e61..9562623 100644 --- a/frontend/src/main.ts +++ b/frontend/src/main.ts @@ -1,15 +1,14 @@ import { createApp } from 'vue' +import App from './App.vue' + // element-plus import ElementPlus from 'element-plus' import 'element-plus/dist/index.css' - // 使用pinia import pinia from '@/stores' - -import App from './App.vue' +// 导入路由 import Router from './router/index' - -// 引入tailwindcss +// 引入项目主CSS import '@/assets/styles/tailMain.css' // 导入全局注册的组件 diff --git a/frontend/src/stores/interface/index.ts b/frontend/src/stores/interface/index.ts deleted file mode 100644 index bbb80bc..0000000 --- a/frontend/src/stores/interface/index.ts +++ /dev/null @@ -1,95 +0,0 @@ -// 变量名对应含义请在 /stores/* 里边找 -import type { RouteRecordRaw, RouteLocationNormalized } from 'vue-router' - -export interface Layout { - showDrawer: boolean - shrink: boolean - layoutMode: string - mainAnimation: string - isDark: boolean - menuWidth: number - menuDefaultIcon: string - menuCollapse: boolean - menuUniqueOpened: boolean - menuShowTopBar: boolean - elementUiPrimary: string[] - tableHeaderBackground: string[] - tableHeaderColor: string[] - tableCurrent: string[] - menuBackground: string[] - menuColor: string[] - menuActiveBackground: string[] - menuActiveColor: string[] - menuTopBarBackground: string[] - headerBarTabColor: string[] - headerBarBackground: string[] - headerBarHoverBackground: string[] - headerBarTabActiveBackground: string[] - headerBarTabActiveColor: string[] -} - -export interface NavTabs { - activeIndex: number - activeRoute: RouteLocationNormalized | null - tabsView: RouteLocationNormalized[] - tabFullScreen: boolean - tabsViewRoutes: RouteRecordRaw[] - authNode: Map -} - -// 用户信息 -export interface UserInfo { - access_token: string - token_type: string - refresh_token: string - expires_in: number - scope: string - nickname: string - userType: number - deptIndex: string - userIndex: string - client_id: string - headSculpture: any - jti: string - name: string - deptId: string - phone: string - email: string - limitIpStart: string - limitIpEnd: string - limitTime: string - casualUser: number - type: number - smsNotice: number - emailNotice: number - role: string[] - devCode: any - id: string - loginName: string - state: number - registerTime: string - loginTime: string - deptName: string - areaId: string - areaName: string - deptLevel: number - roleList: string[] - roleCode: string[] -} - -// 字典数据 -export interface DictData { - basic: BasicDictData[] - area: BasicDictData[] - areaTree: BasicDictData[] - userList: string[] -} - -export interface BasicDictData { - name: string - id: string - code: string - value: null - sort: number | null - children?: BasicDictData[] -} diff --git a/frontend/src/stores/user.ts b/frontend/src/stores/user/index.ts similarity index 72% rename from frontend/src/stores/user.ts rename to frontend/src/stores/user/index.ts index c75b9ce..d655c69 100644 --- a/frontend/src/stores/user.ts +++ b/frontend/src/stores/user/index.ts @@ -1,6 +1,9 @@ import { defineStore } from 'pinia' -import { USER_INFO } from '@/stores/constant/cacheKey' -import type { UserInfo } from '@/stores/interface' +import { USER_INFO } from '@/constants/storeKey' +import { TOKEN_PREFIX } from '@/constants/user' +import type { UserInfo } from '@/types/user' +import { getUserById } from '@/api/user' +import { createPersistedState } from 'pinia-plugin-persistedstate' export const useUserInfoStore = defineStore('userInfo', { // 行为 @@ -8,6 +11,9 @@ export const useUserInfoStore = defineStore('userInfo', { dataFill(state: UserInfo) { this.$state = { ...this.$state, ...state } }, + async initUserInfo() { + this.dataFill(await getUserById()) + }, removeToken() { this.access_token = '' this.refresh_token = '' @@ -18,8 +24,8 @@ export const useUserInfoStore = defineStore('userInfo', { }, getToken(type: 'auth' | 'refresh' = 'auth') { if (type === 'auth') { - if (this.token_type && this.access_token) { - return this.token_type + ' ' + this.access_token + if (this.access_token) { + return `${TOKEN_PREFIX}${this.access_token}` } else { return '' } @@ -32,7 +38,6 @@ export const useUserInfoStore = defineStore('userInfo', { state: (): UserInfo => { return { access_token: '', - token_type: '', refresh_token: '', expires_in: 0, scope: '', @@ -69,7 +74,10 @@ export const useUserInfoStore = defineStore('userInfo', { roleCode: [], } }, - persist: { - key: USER_INFO, - }, + plugins: [ + createPersistedState({ + key: USER_INFO, + storage: window.localStorage + }), + ], }) diff --git a/frontend/src/types/dict/index.ts b/frontend/src/types/dict/index.ts new file mode 100644 index 0000000..9eb761f --- /dev/null +++ b/frontend/src/types/dict/index.ts @@ -0,0 +1,16 @@ +// 字典数据 +export interface DictData { + basic: BasicDictData[] + area: BasicDictData[] + areaTree: BasicDictData[] + userList: string[] +} + +export interface BasicDictData { + name: string + id: string + code: string + value: null + sort: number | null + children?: BasicDictData[] +} diff --git a/frontend/src/types/user/index.ts b/frontend/src/types/user/index.ts new file mode 100644 index 0000000..15329fa --- /dev/null +++ b/frontend/src/types/user/index.ts @@ -0,0 +1,39 @@ + +// 用户信息 +export interface UserInfo { + access_token: string + refresh_token: string + expires_in: number + scope: string + nickname: string + userType: number + deptIndex: string + userIndex: string + client_id: string + headSculpture: any + jti: string + name: string + deptId: string + phone: string + email: string + limitIpStart: string + limitIpEnd: string + limitTime: string + casualUser: number + type: number + smsNotice: number + emailNotice: number + role: string[] + devCode: any + id: string + loginName: string + state: number + registerTime: string + loginTime: string + deptName: string + areaId: string + areaName: string + deptLevel: number + roleList: string[] + roleCode: string[] +} \ No newline at end of file diff --git a/frontend/src/utils/http/index.ts b/frontend/src/utils/http/index.ts index 405805a..c8bcf59 100644 --- a/frontend/src/utils/http/index.ts +++ b/frontend/src/utils/http/index.ts @@ -27,7 +27,7 @@ function createAxios>( const userInfo = useUserInfoStore() const Axios = axios.create({ - baseURL: import.meta.env.VITE_URL, + baseURL: '/api', timeout: 1000 * 60 * 5, headers: {}, responseType: 'json', diff --git a/frontend/src/utils/logout/index.ts b/frontend/src/utils/logout/index.ts new file mode 100644 index 0000000..ddd2c64 --- /dev/null +++ b/frontend/src/utils/logout/index.ts @@ -0,0 +1,9 @@ +import { useUserInfoStore } from '@/stores/user' +import { USER_INFO } from '@/constants/storeKey' + +export function clearUserInfo() { + const userInfo = useUserInfoStore() + userInfo.$reset() + // 清除用户信息缓存 + localStorage.removeItem(USER_INFO) +} diff --git a/frontend/src/views/Login.vue b/frontend/src/views/Login.vue index adba4a7..b3fe48b 100644 --- a/frontend/src/views/Login.vue +++ b/frontend/src/views/Login.vue @@ -1,26 +1,119 @@ - - - diff --git a/frontend/vite-env.d.ts b/frontend/vite-env.d.ts new file mode 100644 index 0000000..360011f --- /dev/null +++ b/frontend/vite-env.d.ts @@ -0,0 +1,9 @@ +interface ImportMetaEnv { + readonly NODE_ENV: string; + readonly VITE_TITLE: string; + // ... 其他环境变量 +} + +interface ImportMeta { + readonly env: ImportMetaEnv; +} diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 270f742..fd178d6 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -4,12 +4,7 @@ import vue from '@vitejs/plugin-vue' import path from 'path' -// https://vitejs.dev/config/ export default defineConfig((config) => { - // 根据当前工作目录中的 `mode` 加载 .env 文件 - // 设置第三个参数为 '' 来加载所有环境变量,而不管是否有 `VITE_` 前缀。 - const {command, mode} = config - const env = loadEnv(mode, process.cwd(), '') return { plugins: [ vue(), @@ -52,5 +47,16 @@ export default defineConfig((config) => { }, }, }, + server: { + host: '0.0.0.0', + open: false, + proxy: { + '/api': { + target: 'http://192.168.1.125:18092', //hsw + changeOrigin: true, + rewrite: path => path.replace(/^\/api/, '') //路径重写,把'/api'替换为'' + } + } + }, } })