Commit b1dcc3d9 authored by tyyin lan's avatar tyyin lan

feat: 登录页面

parent e02481b6
VITE_APP_ENV = 'DEV'
VITE_APP_NAME = 'POC'
VITE_APP_THEME_COLOR = '#2468f2'
VITE_PORT = 8848
......
VITE_APP_ENV = 'PROD'
VITE_APP_NAME = 'POC'
VITE_APP_THEME_COLOR = '#2468f2'
VITE_PUBLIC_PATH = /fe
......
......@@ -2,6 +2,7 @@
export const wrapperEnv = (envConf: Recordable): ViteEnv => {
const ret: ViteEnv = {
VITE_APP_ENV: 'DEV',
VITE_APP_NAME: 'POC',
VITE_PORT: 8848,
VITE_PUBLIC_PATH: '/',
VITE_ROUTER_MODE: 'hash',
......
......@@ -16,12 +16,13 @@
"preinstall": "npx only-allow pnpm"
},
"dependencies": {
"@icon-park/vue-next": "^1.4.2",
"@iconify/vue": "^4.1.2",
"@microsoft/fetch-event-source": "^2.0.1",
"@traptitech/markdown-it-katex": "^3.6.0",
"@unocss/reset": "^0.61.3",
"@vueuse/core": "^10.11.0",
"axios": "^1.7.2",
"@unocss/reset": "^0.61.9",
"@vueuse/core": "^10.11.1",
"axios": "^1.7.7",
"clipboardy": "^4.0.0",
"dayjs": "^1.11.13",
"highlight.js": "^11.10.0",
......@@ -29,53 +30,57 @@
"markdown-it-link-attributes": "^4.0.1",
"mitt": "^3.0.1",
"nanoid": "^5.0.7",
"pinia": "^2.1.7",
"vue": "^3.4.31",
"vue-i18n": "9",
"vue-router": "^4.4.0"
"pinia": "^2.2.2",
"spark-md5": "^3.0.2",
"validator": "^13.12.0",
"vue": "^3.5.6",
"vue-i18n": "^9.14.0",
"vue-router": "^4.4.5"
},
"devDependencies": {
"@commitlint/cli": "^19.3.0",
"@commitlint/config-conventional": "^19.2.2",
"@commitlint/types": "^19.0.3",
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"@commitlint/types": "^19.5.0",
"@intlify/unplugin-vue-i18n": "^4.0.0",
"@types/markdown-it": "^14.1.2",
"@types/markdown-it-link-attributes": "^3.0.5",
"@types/node": "^20.14.10",
"@typescript-eslint/parser": "^7.15.0",
"@unocss/eslint-config": "^0.61.3",
"@types/node": "^20.16.5",
"@types/spark-md5": "^3.0.4",
"@types/validator": "^13.12.2",
"@typescript-eslint/parser": "^7.18.0",
"@unocss/eslint-config": "^0.61.9",
"@vitejs/plugin-vue": "^4.6.2",
"autoprefixer": "^10.4.19",
"eslint": "^9.6.0",
"autoprefixer": "^10.4.20",
"eslint": "^9.10.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-vue": "^9.27.0",
"globals": "^15.8.0",
"husky": "^9.0.11",
"lint-staged": "^15.2.7",
"naive-ui": "^2.38.2",
"postcss": "^8.4.39",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-vue": "^9.28.0",
"globals": "^15.9.0",
"husky": "^9.1.6",
"lint-staged": "^15.2.10",
"naive-ui": "^2.39.0",
"postcss": "^8.4.47",
"postcss-html": "^1.7.0",
"prettier": "^3.3.2",
"prettier-plugin-tailwindcss": "^0.6.5",
"prettier": "^3.3.3",
"prettier-plugin-tailwindcss": "^0.6.6",
"rollup-plugin-visualizer": "^5.12.0",
"sass": "^1.77.6",
"stylelint": "^16.6.1",
"sass": "^1.79.1",
"stylelint": "^16.9.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-standard": "^36.0.1",
"stylelint-config-standard-scss": "^13.1.0",
"stylelint-order": "^6.0.4",
"typescript": "^5.5.3",
"typescript-eslint": "^7.15.0",
"unocss": "^0.61.3",
"unplugin-auto-import": "^0.17.6",
"typescript": "^5.6.2",
"typescript-eslint": "^7.18.0",
"unocss": "^0.61.9",
"unplugin-auto-import": "^0.17.8",
"unplugin-vue-components": "^0.26.0",
"vite": "^5.3.3",
"vite-plugin-checker": "^0.7.1",
"vite": "^5.4.6",
"vite-plugin-checker": "^0.7.2",
"vue-eslint-parser": "^9.4.3",
"vue-tsc": "^2.0.26"
"vue-tsc": "^2.0.29"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0",
......
This diff is collapsed.
import { request } from '@/utils/request'
export function fetchLogin<T>(payload: { loginChannel: string; account: string; password: string }) {
return request.post<T>(`/bizMemberInfoRest/doLogin.json`, payload)
export function fetchLogin<T>(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'
import { useUserStore } from '@/store/modules/user'
/** 路由白名单 */
const whitePathList = ['/login', '/home']
const whitePathList = ['/login']
export function createRouterGuards(router: Router) {
router.beforeEach((to) => {
router.beforeEach((to, _from, next) => {
window.$loadingBar.start()
const userStore = useUserStore()
if (userStore.isLogin && to.fullPath === '/login') {
return false
if (userStore.isLogin && to.name === 'Login') {
next({ name: 'Root' })
return
}
// 白名单直接跳过
if (whitePathList.includes(to.path)) {
return true
}
//忽略校验直接跳过
if (to.meta.ignoreAuth) {
return true
if (whitePathList.includes(to.path) || to.meta.ignoreAuth) {
next()
return
}
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) => {
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()
})
......
import { defineStore } from 'pinia'
import { ss } from '@/utils/storage'
import { TOKEN, IS_LOGIN, USER_INFO } from '@/utils/storage-key'
import type { UserState, UserInfo } from '../types/user'
import { type UserState, type UserInfo, UserStoreStorageKeyEnum } from '../types/user'
function getDefaultUserInfo(): UserInfo {
function createDefaultUserInfoFactory(): UserInfo {
return {
memberId: 0,
memberId: null,
avatarUrl: '',
nickName: '',
mobilePhone: '',
avatarUrl: 'https://gsst-poe-sit.gz.bcebos.com/data/20240910/1725952917468.png',
}
}
export const useUserStore = defineStore('user-store', {
state: (): UserState => ({
isLogin: ss.get(IS_LOGIN),
token: ss.get(TOKEN) || '',
userInfo: ss.get(USER_INFO) || getDefaultUserInfo(),
isLogin: ss.get(UserStoreStorageKeyEnum.isLogin),
token: ss.get(UserStoreStorageKeyEnum.token) || '',
userInfo: ss.get(UserStoreStorageKeyEnum.userInfo) || createDefaultUserInfoFactory(),
}),
actions: {
async logout() {
this.isLogin = false
this.token = ''
this.userInfo = getDefaultUserInfo()
this.userInfo = createDefaultUserInfoFactory()
ss.remove(IS_LOGIN)
ss.remove(TOKEN)
ss.remove(USER_INFO)
},
updateIsLogin(status: boolean) {
this.isLogin = status
ss.set(IS_LOGIN, status)
ss.remove(UserStoreStorageKeyEnum.isLogin)
ss.remove(UserStoreStorageKeyEnum.token)
ss.remove(UserStoreStorageKeyEnum.userInfo)
},
updateToken(token: string) {
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) {
this.userInfo = userInfo
ss.set(USER_INFO, userInfo)
ss.set(UserStoreStorageKeyEnum.userInfo, userInfo)
},
},
})
export interface UserInfo {
memberId: number
memberId: number | null
mobilePhone: string
nickName: string
avatarUrl: string
mobilePhone: string
}
export interface UserState {
......@@ -10,3 +10,9 @@ export interface UserState {
token: string
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' {
interface RouteMeta {
rank: number
title: string
ignoreAuth?: boolean
hiddenTitle?: boolean
}
}
......@@ -2,6 +2,7 @@
declare interface ViteEnv {
readonly VITE_APP_ENV: 'DEV' | 'PROD'
readonly VITE_APP_NAME: string
readonly VITE_PORT: number
readonly VITE_PUBLIC_PATH: string
......
......@@ -22,5 +22,19 @@ export default defineConfig({
navbar: '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