Commit c283d2a1 authored by nick zheng's avatar nick zheng

Merge branch 'master' of https://gitlab.gsstcloud.com/poc/poc-fe

parents f03284ec b1dcc3d9
VITE_APP_ENV = 'DEV' VITE_APP_ENV = 'DEV'
VITE_APP_NAME = 'POC'
VITE_APP_THEME_COLOR = '#2468f2' VITE_APP_THEME_COLOR = '#2468f2'
VITE_PORT = 8848 VITE_PORT = 8848
......
VITE_APP_ENV = 'PROD' VITE_APP_ENV = 'PROD'
VITE_APP_NAME = 'POC'
VITE_APP_THEME_COLOR = '#2468f2' VITE_APP_THEME_COLOR = '#2468f2'
VITE_PUBLIC_PATH = /fe VITE_PUBLIC_PATH = /fe
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
export const wrapperEnv = (envConf: Recordable): ViteEnv => { export const wrapperEnv = (envConf: Recordable): ViteEnv => {
const ret: ViteEnv = { const ret: ViteEnv = {
VITE_APP_ENV: 'DEV', VITE_APP_ENV: 'DEV',
VITE_APP_NAME: 'POC',
VITE_PORT: 8848, VITE_PORT: 8848,
VITE_PUBLIC_PATH: '/', VITE_PUBLIC_PATH: '/',
VITE_ROUTER_MODE: 'hash', VITE_ROUTER_MODE: 'hash',
......
...@@ -16,12 +16,13 @@ ...@@ -16,12 +16,13 @@
"preinstall": "npx only-allow pnpm" "preinstall": "npx only-allow pnpm"
}, },
"dependencies": { "dependencies": {
"@icon-park/vue-next": "^1.4.2",
"@iconify/vue": "^4.1.2", "@iconify/vue": "^4.1.2",
"@microsoft/fetch-event-source": "^2.0.1", "@microsoft/fetch-event-source": "^2.0.1",
"@traptitech/markdown-it-katex": "^3.6.0", "@traptitech/markdown-it-katex": "^3.6.0",
"@unocss/reset": "^0.61.3", "@unocss/reset": "^0.61.9",
"@vueuse/core": "^10.11.0", "@vueuse/core": "^10.11.1",
"axios": "^1.7.2", "axios": "^1.7.7",
"clipboardy": "^4.0.0", "clipboardy": "^4.0.0",
"dayjs": "^1.11.13", "dayjs": "^1.11.13",
"highlight.js": "^11.10.0", "highlight.js": "^11.10.0",
...@@ -29,53 +30,57 @@ ...@@ -29,53 +30,57 @@
"markdown-it-link-attributes": "^4.0.1", "markdown-it-link-attributes": "^4.0.1",
"mitt": "^3.0.1", "mitt": "^3.0.1",
"nanoid": "^5.0.7", "nanoid": "^5.0.7",
"pinia": "^2.1.7", "pinia": "^2.2.2",
"vue": "^3.4.31", "spark-md5": "^3.0.2",
"vue-i18n": "9", "validator": "^13.12.0",
"vue-router": "^4.4.0" "vue": "^3.5.6",
"vue-i18n": "^9.14.0",
"vue-router": "^4.4.5"
}, },
"devDependencies": { "devDependencies": {
"@commitlint/cli": "^19.3.0", "@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.2.2", "@commitlint/config-conventional": "^19.5.0",
"@commitlint/types": "^19.0.3", "@commitlint/types": "^19.5.0",
"@intlify/unplugin-vue-i18n": "^4.0.0", "@intlify/unplugin-vue-i18n": "^4.0.0",
"@types/markdown-it": "^14.1.2", "@types/markdown-it": "^14.1.2",
"@types/markdown-it-link-attributes": "^3.0.5", "@types/markdown-it-link-attributes": "^3.0.5",
"@types/node": "^20.14.10", "@types/node": "^20.16.5",
"@typescript-eslint/parser": "^7.15.0", "@types/spark-md5": "^3.0.4",
"@unocss/eslint-config": "^0.61.3", "@types/validator": "^13.12.2",
"@typescript-eslint/parser": "^7.18.0",
"@unocss/eslint-config": "^0.61.9",
"@vitejs/plugin-vue": "^4.6.2", "@vitejs/plugin-vue": "^4.6.2",
"autoprefixer": "^10.4.19", "autoprefixer": "^10.4.20",
"eslint": "^9.6.0", "eslint": "^9.10.0",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3", "eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-vue": "^9.27.0", "eslint-plugin-vue": "^9.28.0",
"globals": "^15.8.0", "globals": "^15.9.0",
"husky": "^9.0.11", "husky": "^9.1.6",
"lint-staged": "^15.2.7", "lint-staged": "^15.2.10",
"naive-ui": "^2.38.2", "naive-ui": "^2.39.0",
"postcss": "^8.4.39", "postcss": "^8.4.47",
"postcss-html": "^1.7.0", "postcss-html": "^1.7.0",
"prettier": "^3.3.2", "prettier": "^3.3.3",
"prettier-plugin-tailwindcss": "^0.6.5", "prettier-plugin-tailwindcss": "^0.6.6",
"rollup-plugin-visualizer": "^5.12.0", "rollup-plugin-visualizer": "^5.12.0",
"sass": "^1.77.6", "sass": "^1.79.1",
"stylelint": "^16.6.1", "stylelint": "^16.9.0",
"stylelint-config-recess-order": "^4.6.0", "stylelint-config-recess-order": "^4.6.0",
"stylelint-config-recommended-scss": "^14.0.0", "stylelint-config-recommended-scss": "^14.1.0",
"stylelint-config-recommended-vue": "^1.5.0", "stylelint-config-recommended-vue": "^1.5.0",
"stylelint-config-standard": "^36.0.1", "stylelint-config-standard": "^36.0.1",
"stylelint-config-standard-scss": "^13.1.0", "stylelint-config-standard-scss": "^13.1.0",
"stylelint-order": "^6.0.4", "stylelint-order": "^6.0.4",
"typescript": "^5.5.3", "typescript": "^5.6.2",
"typescript-eslint": "^7.15.0", "typescript-eslint": "^7.18.0",
"unocss": "^0.61.3", "unocss": "^0.61.9",
"unplugin-auto-import": "^0.17.6", "unplugin-auto-import": "^0.17.8",
"unplugin-vue-components": "^0.26.0", "unplugin-vue-components": "^0.26.0",
"vite": "^5.3.3", "vite": "^5.4.6",
"vite-plugin-checker": "^0.7.1", "vite-plugin-checker": "^0.7.2",
"vue-eslint-parser": "^9.4.3", "vue-eslint-parser": "^9.4.3",
"vue-tsc": "^2.0.26" "vue-tsc": "^2.0.29"
}, },
"engines": { "engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0", "node": "^18.18.0 || ^20.9.0 || >=21.1.0",
......
This diff is collapsed.
import { request } from '@/utils/request' import { request } from '@/utils/request'
export function fetchLogin<T>(payload: { loginChannel: string; account: string; password: string }) { export function fetchLogin<T>(payload: {
return request.post<T>(`/bizMemberInfoRest/doLogin.json`, payload) loginChannel: 'MEMBER_PLATFOMR_SMS' | 'MEMBER_PLATFOMR_EMAIL' | 'MEMBER_PLATFOMR_PW'
account: string
password?: string
authCode?: string
}) {
return request.post<T>('/bizMemberInfoRest/doLogin.json', payload)
}
export function fetchSMSCode<T>(phoneNumber: string) {
return request.post<T>(`/smsRest/smsDelivered.json?phone=${phoneNumber}`)
}
export function fetchEmailCode<T>(emailAddress: string) {
return request.post<T>(`/sendEmailRest/sendEmailCode.json?emailAddress=${emailAddress}`)
} }
This diff is collapsed.
...@@ -2,36 +2,41 @@ import type { Router } from 'vue-router' ...@@ -2,36 +2,41 @@ import type { Router } from 'vue-router'
import { useUserStore } from '@/store/modules/user' import { useUserStore } from '@/store/modules/user'
/** 路由白名单 */ /** 路由白名单 */
const whitePathList = ['/login', '/home'] const whitePathList = ['/login']
export function createRouterGuards(router: Router) { export function createRouterGuards(router: Router) {
router.beforeEach((to) => { router.beforeEach((to, _from, next) => {
window.$loadingBar.start() window.$loadingBar.start()
const userStore = useUserStore() const userStore = useUserStore()
if (userStore.isLogin && to.fullPath === '/login') { if (userStore.isLogin && to.name === 'Login') {
return false next({ name: 'Root' })
return
} }
// 白名单直接跳过 // 白名单直接跳过
if (whitePathList.includes(to.path)) { if (whitePathList.includes(to.path) || to.meta.ignoreAuth) {
return true next()
} return
//忽略校验直接跳过
if (to.meta.ignoreAuth) {
return true
} }
if (!userStore.isLogin && !whitePathList.includes(to.fullPath)) { if (!userStore.isLogin && !whitePathList.includes(to.fullPath)) {
return { path: '/login', query: { redirect: encodeURIComponent(to.fullPath) } } next({ path: '/login', query: { redirect: encodeURIComponent(to.fullPath) } })
return
} }
return true next()
}) })
router.afterEach((to) => { router.afterEach((to) => {
document.title = to.meta.hiddenTitle ? '' : (to.meta.title as string) || document.title if (to.meta.hiddenTitle) {
document.title = ''
} else if (to.meta.title) {
document.title = `${import.meta.env.VITE_APP_NAME}-${to.meta.title}`
} else {
document.title = import.meta.env.VITE_APP_NAME
}
window.$loadingBar.finish() window.$loadingBar.finish()
}) })
......
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
import { ss } from '@/utils/storage' import { ss } from '@/utils/storage'
import { TOKEN, IS_LOGIN, USER_INFO } from '@/utils/storage-key' import { type UserState, type UserInfo, UserStoreStorageKeyEnum } from '../types/user'
import type { UserState, UserInfo } from '../types/user'
function getDefaultUserInfo(): UserInfo { function createDefaultUserInfoFactory(): UserInfo {
return { return {
memberId: 0, memberId: null,
avatarUrl: '',
nickName: '', nickName: '',
mobilePhone: '', mobilePhone: '',
avatarUrl: 'https://gsst-poe-sit.gz.bcebos.com/data/20240910/1725952917468.png',
} }
} }
export const useUserStore = defineStore('user-store', { export const useUserStore = defineStore('user-store', {
state: (): UserState => ({ state: (): UserState => ({
isLogin: ss.get(IS_LOGIN), isLogin: ss.get(UserStoreStorageKeyEnum.isLogin),
token: ss.get(TOKEN) || '', token: ss.get(UserStoreStorageKeyEnum.token) || '',
userInfo: ss.get(USER_INFO) || getDefaultUserInfo(), userInfo: ss.get(UserStoreStorageKeyEnum.userInfo) || createDefaultUserInfoFactory(),
}), }),
actions: { actions: {
async logout() { async logout() {
this.isLogin = false this.isLogin = false
this.token = '' this.token = ''
this.userInfo = getDefaultUserInfo() this.userInfo = createDefaultUserInfoFactory()
ss.remove(IS_LOGIN) ss.remove(UserStoreStorageKeyEnum.isLogin)
ss.remove(TOKEN) ss.remove(UserStoreStorageKeyEnum.token)
ss.remove(USER_INFO) ss.remove(UserStoreStorageKeyEnum.userInfo)
},
updateIsLogin(status: boolean) {
this.isLogin = status
ss.set(IS_LOGIN, status)
}, },
updateToken(token: string) { updateToken(token: string) {
this.token = token this.token = token
ss.set(TOKEN, token) ss.set(UserStoreStorageKeyEnum.token, token)
if (token) {
this.isLogin = true
ss.set(UserStoreStorageKeyEnum.isLogin, true)
} else {
this.isLogin = false
ss.set(UserStoreStorageKeyEnum.isLogin, false)
}
}, },
updateUserInfo(userInfo: UserInfo) { updateUserInfo(userInfo: UserInfo) {
this.userInfo = userInfo this.userInfo = userInfo
ss.set(USER_INFO, userInfo) ss.set(UserStoreStorageKeyEnum.userInfo, userInfo)
}, },
}, },
}) })
export interface UserInfo { export interface UserInfo {
memberId: number memberId: number | null
mobilePhone: string
nickName: string nickName: string
avatarUrl: string avatarUrl: string
mobilePhone: string
} }
export interface UserState { export interface UserState {
...@@ -10,3 +10,9 @@ export interface UserState { ...@@ -10,3 +10,9 @@ export interface UserState {
token: string token: string
userInfo: UserInfo userInfo: UserInfo
} }
export enum UserStoreStorageKeyEnum {
userInfo = 'USER_INFO',
token = 'TOKEN',
isLogin = 'IS_LOGIN',
}
export const TOKEN = 'TOKEN'
export const IS_LOGIN = 'IS_LOGIN'
export const USER_INFO = 'USER_INFO'
This diff is collapsed.
...@@ -6,5 +6,7 @@ declare module 'vue-router' { ...@@ -6,5 +6,7 @@ declare module 'vue-router' {
interface RouteMeta { interface RouteMeta {
rank: number rank: number
title: string title: string
ignoreAuth?: boolean
hiddenTitle?: boolean
} }
} }
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
declare interface ViteEnv { declare interface ViteEnv {
readonly VITE_APP_ENV: 'DEV' | 'PROD' readonly VITE_APP_ENV: 'DEV' | 'PROD'
readonly VITE_APP_NAME: string
readonly VITE_PORT: number readonly VITE_PORT: number
readonly VITE_PUBLIC_PATH: string readonly VITE_PUBLIC_PATH: string
......
...@@ -22,5 +22,19 @@ export default defineConfig({ ...@@ -22,5 +22,19 @@ export default defineConfig({
navbar: '56px', navbar: '56px',
content: 'calc(100% - 56px)', content: 'calc(100% - 56px)',
}, },
animation: {
keyframes: {
'card-reverse': `{ 0% { transform: rotateY(0deg); } 100% { transform: rotateY(1turn); } }`,
},
durations: {
'card-reverse': '1s',
},
timingFns: {
'card-reverse': 'ease-in-out',
},
counts: {
'card-reverse': '1',
},
},
}, },
}) })
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment