feat: 适配5.x后端,重构前端架构
主要变更: 1. 重构API目录结构,采用模块化设计,适配5.x后端接口规范 2. 优化布局组件,提升用户界面体验 3. 增强国际化支持,完善多语言配置 4. 新增权限控制功能,支持前端路由权限管理 5. 优化认证流程,支持JWT认证机制 6. 新增中间件和插件,提升系统扩展性 7. 优化状态管理,采用更清晰的模块化设计 8. 新增搜索框、广告等组件,丰富页面功能 9. 更改包管理工具从npm到pnpm,提升依赖管理效率 10. 完善配置系统,支持多环境配置 适配5.x后端特性: - 采用新的API接口规范 - 支持JWT认证机制 - 适配后端权限控制体系 - 支持后端国际化接口 - 优化数据交互方式
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { hasAuth } from '~/plugins/permission'
|
||||
|
||||
/**
|
||||
* 权限检查组合式函数
|
||||
*/
|
||||
export function useAuth() {
|
||||
return {
|
||||
/**
|
||||
* 检查用户是否有权限
|
||||
* @param permissions 权限码或权限码数组
|
||||
* @returns 是否有权限
|
||||
*/
|
||||
hasAuth,
|
||||
|
||||
/**
|
||||
* 检查用户是否没有权限
|
||||
* @param permissions 权限码或权限码数组
|
||||
* @returns 是否没有权限
|
||||
*/
|
||||
lacksAuth: (permissions: string | string[]) => !hasAuth(permissions)
|
||||
}
|
||||
}
|
||||
+21
-10
@@ -1,24 +1,33 @@
|
||||
import { ref } from 'vue'
|
||||
import { getCaptchaImage } from '@/api/system'
|
||||
|
||||
interface formData {
|
||||
captcha_code: string,
|
||||
interface CaptchaFormData {
|
||||
captcha_code: string
|
||||
captcha_key: string
|
||||
}
|
||||
|
||||
export function useCaptcha(formData: formData) {
|
||||
interface CaptchaResponse {
|
||||
code: number
|
||||
msg: string
|
||||
data: {
|
||||
uuid: string
|
||||
base64: string
|
||||
}
|
||||
}
|
||||
|
||||
export function useCaptcha(formData: CaptchaFormData) {
|
||||
const image = ref('')
|
||||
|
||||
const refresh = async () => {
|
||||
try {
|
||||
await getCaptchaImage().then((res: any) => {
|
||||
if (res.code == 1) {
|
||||
formData.captcha_key = res.data.captcha_key
|
||||
formData.captcha_code = ''
|
||||
image.value = res.data.img.replace(/\r\n/g, '')
|
||||
}
|
||||
})
|
||||
const res = await getCaptchaImage() as CaptchaResponse
|
||||
if (res.code === 0 && res.data) {
|
||||
formData.captcha_key = res.data.uuid
|
||||
formData.captcha_code = ''
|
||||
image.value = res.data.base64.replace(/\r\n/g, '')
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('获取验证码失败:', e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,3 +36,5 @@ export function useCaptcha(formData: formData) {
|
||||
refresh
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { useRoute } from 'vue-router'
|
||||
import Language from '~/utils/language'
|
||||
|
||||
export function t(message: string) {
|
||||
const i18n = useNuxtApp().$getI18n()
|
||||
const route = useRoute()
|
||||
const file = new Language(i18n).getFileKey((route?.meta.plugin || 'app'), route?.path || '')
|
||||
const key = `${file}.${message}`
|
||||
return i18n.global.t(key) != key ? i18n.global.t(key) : i18n.global.t(message)
|
||||
const nuxtApp: any = useNuxtApp()
|
||||
const i18nInstance = nuxtApp.$getI18n()
|
||||
|
||||
// 直接使用 i18n 的 t 方法,让它自动根据 locale 选择对应的翻译
|
||||
return i18nInstance.global.t(message)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user