Commit a47d42d0 authored by tyyin lan's avatar tyyin lan

feat: 登录页面

parent 6934461d
...@@ -3,7 +3,7 @@ VITE_APP_ENV = 'DEV' ...@@ -3,7 +3,7 @@ VITE_APP_ENV = 'DEV'
VITE_APP_NAME = 'DIGITAL_PERSON_FE' VITE_APP_NAME = 'DIGITAL_PERSON_FE'
VITE_APP_THEME_COLOR = '#2468f2' VITE_APP_THEME_COLOR = '#2468f2'
VITE_PORT = 8848 VITE_PORT = 8848
VITE_PUBLIC_PATH = / VITE_PUBLIC_PATH = /fe
VITE_ROUTER_MODE = 'hash' VITE_ROUTER_MODE = 'h5'
VITE_VITEST = true VITE_VITEST = true
VITE_HIDE_HOME = false VITE_HIDE_HOME = false
...@@ -68,6 +68,7 @@ export default [ ...@@ -68,6 +68,7 @@ export default [
'@typescript-eslint/array-type': 'error', '@typescript-eslint/array-type': 'error',
'@unocss/order': 'off', '@unocss/order': 'off',
'unocss/order': 'off',
}, },
}, },
......
...@@ -16,13 +16,16 @@ ...@@ -16,13 +16,16 @@
"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",
"@unocss/reset": "^0.61.9", "@unocss/reset": "^0.61.9",
"@vueuse/core": "^10.11.1", "@vueuse/core": "^10.11.1",
"axios": "^1.7.7", "axios": "^1.7.7",
"nanoid": "^5.0.7", "nanoid": "^5.0.7",
"pinia": "^2.2.2", "pinia": "^2.2.2",
"vue": "^3.5.3", "spark-md5": "^3.0.2",
"validator": "^13.12.0",
"vue": "^3.5.5",
"vue-router": "^4.4.3" "vue-router": "^4.4.3"
}, },
"devDependencies": { "devDependencies": {
...@@ -30,6 +33,8 @@ ...@@ -30,6 +33,8 @@
"@commitlint/config-conventional": "^19.4.1", "@commitlint/config-conventional": "^19.4.1",
"@commitlint/types": "^19.0.3", "@commitlint/types": "^19.0.3",
"@types/node": "^20.16.5", "@types/node": "^20.16.5",
"@types/spark-md5": "^3.0.4",
"@types/validator": "^13.12.1",
"@typescript-eslint/parser": "^7.18.0", "@typescript-eslint/parser": "^7.18.0",
"@unocss/eslint-config": "^0.61.9", "@unocss/eslint-config": "^0.61.9",
"@vitejs/plugin-vue": "^4.6.2", "@vitejs/plugin-vue": "^4.6.2",
......
This diff is collapsed.
import { request } from '@/utils/request' import { request } from '@/utils/request'
export function fetchLogin<T>(payload: { username: string; password: string }) { export function fetchLogin<T>(payload: {
return request.post<T>(`/oauth/auth?username=${payload.username}&password=${payload.password}`, null, { loginChannel: 'MEMBER_PLATFOMR_SMS' | 'MEMBER_PLATFOMR_EMAIL' | 'MEMBER_PLATFOMR_PW'
ignoreErrorCheck: true, 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.
export const BASE_URLS: Record<'DEV' | 'PROD', string> = { export const BASE_URLS: Record<'DEV' | 'PROD', string> = {
DEV: '', DEV: 'https://poc-sit.gsstcloud.com',
PROD: '', PROD: '',
} }
...@@ -3,7 +3,7 @@ import { GlobalThemeOverrides } from 'naive-ui' ...@@ -3,7 +3,7 @@ import { GlobalThemeOverrides } from 'naive-ui'
export const themeOverrides: GlobalThemeOverrides = { export const themeOverrides: GlobalThemeOverrides = {
common: { common: {
primaryColor: '#2468f2', primaryColor: '#2468f2',
primaryColorHover: '#45a9bb', primaryColorHover: '#528eff',
primaryColorPressed: '#398c9b', primaryColorPressed: '#398c9b',
primaryColorSuppl: '#45a9bb', primaryColorSuppl: '#45a9bb',
}, },
......
...@@ -5,25 +5,28 @@ import { useUserStore } from '@/store/modules/user' ...@@ -5,25 +5,28 @@ import { useUserStore } from '@/store/modules/user'
const whitePathList = ['/login'] 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)) {
return true next()
return
} }
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) => {
......
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 {
account: '', memberId: null,
userAccount: '', avatarUrl: '',
userId: null, nickName: '',
userName: '用户', mobilePhone: '',
createdTime: '',
avatar: '',
} }
} }
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 {
account: string memberId: number | null
userAccount: string mobilePhone: string
userId: null | number nickName: string
userName: string avatarUrl: string
createdTime: string
avatar: string
} }
export interface UserState { export interface UserState {
...@@ -12,3 +10,9 @@ export interface UserState { ...@@ -12,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',
}
...@@ -26,7 +26,7 @@ function handleLogout() { ...@@ -26,7 +26,7 @@ function handleLogout() {
} }
const service = axios.create({ const service = axios.create({
baseURL: `${BASE_URLS[ENV]}/api`, baseURL: `${BASE_URLS[ENV]}/api/rest`,
timeout: 7000, timeout: 7000,
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
......
export const TOKEN = 'TOKEN'
export const IS_LOGIN = 'IS_LOGIN'
export const USER_INFO = 'USER_INFO'
This diff is collapsed.
...@@ -15,4 +15,20 @@ export default defineConfig({ ...@@ -15,4 +15,20 @@ export default defineConfig({
}), }),
], ],
], ],
theme: {
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