feat: 优化页面相关功能,新增用户注册,忘记密码,系统字体,系统样式等

This commit is contained in:
liuzhi
2025-03-18 10:28:48 +08:00
committed by Charles7c
parent 933cd6063a
commit c8a3bb5e72
54 changed files with 3551 additions and 226 deletions

View File

@@ -1,5 +1,5 @@
import { defineStore } from 'pinia'
import { computed, reactive, toRefs } from 'vue'
import { computed, reactive, toRefs, watch } from 'vue'
import { generate, getRgbStr } from '@arco-design/color'
import { type BasicConfig, listSiteOptionDict } from '@/apis'
import { getSettings } from '@/config/setting'
@@ -20,6 +20,18 @@ const storeSetup = () => {
return obj
})
// 设置字体
const setFontFamily = (font: string) => {
if (!font) return
document.documentElement.style.setProperty('--current-font-family', font)
}
// 初始化字体
const initFontFamily = () => {
if (!settingConfig.fontFamily) return
setFontFamily(settingConfig.fontFamily)
}
// 设置主题色
const setThemeColor = (color: string) => {
if (!color) return
@@ -103,6 +115,17 @@ const storeSetup = () => {
immediate: true,
})
// 监听字体变化
watch(
() => settingConfig.fontFamily,
(newFont) => {
if (newFont) {
setFontFamily(newFont)
}
},
{ immediate: true },
)
const getFavicon = () => {
return siteConfig.SITE_FAVICON
}
@@ -138,6 +161,8 @@ const storeSetup = () => {
getTitle,
getCopyright,
getForRecord,
setFontFamily,
initFontFamily,
}
}

View File

@@ -0,0 +1,37 @@
// src/stores/modules/auth.ts
import { defineStore } from 'pinia'
export const useAuthStore = defineStore('auth', {
state: () => ({
isRegister: false,
isEmailLogin: false,
isForgotPassword: false,
activeKey: '1',
}),
actions: {
toggleMode() {
if (this.isEmailLogin) {
this.isEmailLogin = !this.isEmailLogin
} else {
this.isForgotPassword = !this.isForgotPassword
}
},
toggleEmailLoginMode() {
this.isEmailLogin = !this.isEmailLogin
},
toggleRegisterMode() {
const keyMap = {
1: '3',
2: '4',
3: '1',
4: '2',
}
this.isRegister = !this.isRegister
this.isEmailLogin = false
this.activeKey = keyMap[this.activeKey]
},
onTabChange(key: string) {
this.activeKey = key
},
},
})

View File

@@ -1,11 +1,22 @@
/*
* @Author: liuzhi 1306086303@qq.com
* @Date: 2025-03-12 11:00:23
* @LastEditors: liuzhi 1306086303@qq.com
* @LastEditTime: 2025-03-12 17:26:01
* @FilePath: \continew-admin-ui\src\stores\modules\user.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import { defineStore } from 'pinia'
import { computed, reactive, ref } from 'vue'
import { useAuthStore } from './auth'
import { resetRouter } from '@/router'
import {
type AccountLoginReq,
type AccountSignupReq,
AuthTypeConstants,
type EmailLoginReq,
type PhoneLoginReq,
type PhoneSignupReq,
type UserInfo,
accountLogin as accountLoginApi,
emailLogin as emailLoginApi,
@@ -16,6 +27,7 @@ import {
} from '@/apis'
import { clearToken, getToken, setToken } from '@/utils/auth'
import { resetHasRouteFlag } from '@/router/guard'
import { signup as accountSignupApi } from '@/apis/system'
const storeSetup = () => {
const userInfo = reactive<UserInfo>({
@@ -49,7 +61,12 @@ const storeSetup = () => {
resetHasRouteFlag()
}
// 登录
// 账号注册
const accountSignup = async (req: AccountSignupReq) => {
await accountSignupApi({ ...req, clientId: import.meta.env.VITE_CLIENT_ID, authType: AuthTypeConstants.ACCOUNT })
}
// 账号登录
const accountLogin = async (req: AccountLoginReq) => {
const res = await accountLoginApi({ ...req, clientId: import.meta.env.VITE_CLIENT_ID, authType: AuthTypeConstants.ACCOUNT })
setToken(res.data.token)
@@ -63,6 +80,11 @@ const storeSetup = () => {
token.value = res.data.token
}
// 手机号注册
const phoneSignup = async (req: PhoneSignupReq) => {
await accountSignupApi({ ...req, clientId: import.meta.env.VITE_CLIENT_ID, authType: AuthTypeConstants.PHONE })
}
// 手机号登录
const phoneLogin = async (req: PhoneLoginReq) => {
const res = await phoneLoginApi({ ...req, clientId: import.meta.env.VITE_CLIENT_ID, authType: AuthTypeConstants.PHONE })
@@ -84,6 +106,11 @@ const storeSetup = () => {
pwdExpiredShow.value = true
resetToken()
resetRouter()
// useRouter().push('/login')
useAuthStore().activeKey = '3'
useAuthStore().isRegister = true
useAuthStore().isEmailLogin = true
useAuthStore().toggleRegisterMode()
}
// 退出登录
@@ -117,8 +144,10 @@ const storeSetup = () => {
roles,
permissions,
pwdExpiredShow,
accountSignup,
accountLogin,
emailLogin,
phoneSignup,
phoneLogin,
socialLogin,
logout,