Browse Source

chore: update

i18n
xiaoxian521 2 years ago
parent
commit
d4c2e139a3
  1. 4
      package.json
  2. 775
      pnpm-lock.yaml
  3. 4
      src/layout/components/setting/index.vue
  4. 1
      src/layout/components/sidebar/horizontal.vue
  5. 1
      src/layout/components/sidebar/mixNav.vue
  6. 3
      src/layout/components/sidebar/vertical.vue
  7. 8
      src/layout/hooks/useTag.ts
  8. 2
      src/plugins/i18n.ts
  9. 2
      src/router/index.ts
  10. 6
      src/router/utils.ts
  11. 9
      src/store/modules/app.ts
  12. 11
      src/store/modules/epTheme.ts
  13. 15
      src/store/modules/multiTags.ts
  14. 4
      src/store/modules/user.ts
  15. 8
      src/utils/auth.ts

4
package.json

@ -31,8 +31,8 @@
"dependencies": { "dependencies": {
"@ctrl/tinycolor": "^3.4.1", "@ctrl/tinycolor": "^3.4.1",
"@pureadmin/descriptions": "^1.1.0", "@pureadmin/descriptions": "^1.1.0",
"@pureadmin/table": "^1.8.3",
"@pureadmin/utils": "^1.7.5",
"@pureadmin/table": "^1.9.0",
"@pureadmin/utils": "^1.8.2",
"@vueuse/core": "^9.6.0", "@vueuse/core": "^9.6.0",
"@vueuse/motion": "2.0.0-beta.12", "@vueuse/motion": "2.0.0-beta.12",
"animate.css": "^4.1.1", "animate.css": "^4.1.1",

775
pnpm-lock.yaml
File diff suppressed because it is too large
View File

4
src/layout/components/setting/index.vue

@ -132,8 +132,8 @@ const multiTagsCacheChange = () => {
/** 清空缓存并返回登录页 */ /** 清空缓存并返回登录页 */
function onReset() { function onReset() {
removeToken(); removeToken();
storageLocal.clear();
storageSession.clear();
storageLocal().clear();
storageSession().clear();
const { Grey, Weak, MultiTagsCache, EpThemeColor, Layout } = getConfig(); const { Grey, Weak, MultiTagsCache, EpThemeColor, Layout } = getConfig();
useAppStoreHook().setLayout(Layout); useAppStoreHook().setLayout(Layout);
setEpThemeColor(EpThemeColor); setEpThemeColor(EpThemeColor);

1
src/layout/components/sidebar/horizontal.vue

@ -135,6 +135,7 @@ watch(
:deep(.el-loading-mask) { :deep(.el-loading-mask) {
opacity: 0.45; opacity: 0.45;
} }
.translation { .translation {
::v-deep(.el-dropdown-menu__item) { ::v-deep(.el-dropdown-menu__item) {
padding: 5px 40px; padding: 5px 40px;

1
src/layout/components/sidebar/mixNav.vue

@ -168,6 +168,7 @@ watch(
:deep(.el-loading-mask) { :deep(.el-loading-mask) {
opacity: 0.45; opacity: 0.45;
} }
.translation { .translation {
::v-deep(.el-dropdown-menu__item) { ::v-deep(.el-dropdown-menu__item) {
padding: 5px 40px; padding: 5px 40px;

3
src/layout/components/sidebar/vertical.vue

@ -12,7 +12,8 @@ import { usePermissionStoreHook } from "@/store/modules/permission";
const route = useRoute(); const route = useRoute();
const showLogo = ref( const showLogo = ref(
storageLocal.getItem<StorageConfigs>("responsive-configure")?.showLogo ?? true
storageLocal().getItem<StorageConfigs>("responsive-configure")?.showLogo ??
true
); );
const { routers, device, pureApp, isCollapse, menuSelect, toggleSideBar } = const { routers, device, pureApp, isCollapse, menuSelect, toggleSideBar } =

8
src/layout/hooks/useTag.ts

@ -41,13 +41,13 @@ export function useTags() {
/** 显示模式,默认灵动模式 */ /** 显示模式,默认灵动模式 */
const showModel = ref( const showModel = ref(
storageLocal.getItem<StorageConfigs>("responsive-configure")?.showModel ||
storageLocal().getItem<StorageConfigs>("responsive-configure")?.showModel ||
"smart" "smart"
); );
/** 是否隐藏标签页,默认显示 */ /** 是否隐藏标签页,默认显示 */
const showTags = const showTags =
ref( ref(
storageLocal.getItem<StorageConfigs>("responsive-configure").hideTabs
storageLocal().getItem<StorageConfigs>("responsive-configure").hideTabs
) ?? ref("false"); ) ?? ref("false");
const multiTags: any = computed(() => { const multiTags: any = computed(() => {
return useMultiTagsStoreHook().multiTags; return useMultiTagsStoreHook().multiTags;
@ -195,11 +195,11 @@ export function useTags() {
onMounted(() => { onMounted(() => {
if (!showModel.value) { if (!showModel.value) {
const configure = storageLocal.getItem<StorageConfigs>(
const configure = storageLocal().getItem<StorageConfigs>(
"responsive-configure" "responsive-configure"
); );
configure.showModel = "card"; configure.showModel = "card";
storageLocal.setItem("responsive-configure", configure);
storageLocal().setItem("responsive-configure", configure);
} }
}); });

2
src/plugins/i18n.ts

@ -63,7 +63,7 @@ export const $t = (key: string) => key;
export const i18n: I18n = createI18n({ export const i18n: I18n = createI18n({
legacy: false, legacy: false,
locale: locale:
storageLocal.getItem<StorageConfigs>("responsive-locale")?.locale ?? "zh",
storageLocal().getItem<StorageConfigs>("responsive-locale")?.locale ?? "zh",
fallbackLocale: "en", fallbackLocale: "en",
messages: localesConfigs messages: localesConfigs
}); });

2
src/router/index.ts

@ -106,7 +106,7 @@ router.beforeEach((to: toRouteType, _from, next) => {
handleAliveRoute(newMatched); handleAliveRoute(newMatched);
} }
} }
const userInfo = storageSession.getItem<DataInfo<number>>(sessionKey);
const userInfo = storageSession().getItem<DataInfo<number>>(sessionKey);
NProgress.start(); NProgress.start();
const externalLink = isUrl(to?.name as string); const externalLink = isUrl(to?.name as string);
if (!externalLink) { if (!externalLink) {

6
src/router/utils.ts

@ -84,7 +84,7 @@ function isOneOfArray(a: Array<string>, b: Array<string>) {
/** 从sessionStorage里取出当前登陆用户的角色roles,过滤无权限的菜单 */ /** 从sessionStorage里取出当前登陆用户的角色roles,过滤无权限的菜单 */
function filterNoPermissionTree(data: RouteComponent[]) { function filterNoPermissionTree(data: RouteComponent[]) {
const currentRoles = const currentRoles =
storageSession.getItem<DataInfo<number>>(sessionKey)?.roles ?? [];
storageSession().getItem<DataInfo<number>>(sessionKey)?.roles ?? [];
const newTree = cloneDeep(data).filter((v: any) => const newTree = cloneDeep(data).filter((v: any) =>
isOneOfArray(v.meta?.roles, currentRoles) isOneOfArray(v.meta?.roles, currentRoles)
); );
@ -196,7 +196,7 @@ function initRouter() {
if (getConfig()?.CachingAsyncRoutes) { if (getConfig()?.CachingAsyncRoutes) {
// 开启动态路由缓存本地sessionStorage // 开启动态路由缓存本地sessionStorage
const key = "async-routes"; const key = "async-routes";
const asyncRouteList = storageSession.getItem(key) as any;
const asyncRouteList = storageSession().getItem(key) as any;
if (asyncRouteList && asyncRouteList?.length > 0) { if (asyncRouteList && asyncRouteList?.length > 0) {
return new Promise(resolve => { return new Promise(resolve => {
handleAsyncRoutes(asyncRouteList); handleAsyncRoutes(asyncRouteList);
@ -206,7 +206,7 @@ function initRouter() {
return new Promise(resolve => { return new Promise(resolve => {
getAsyncRoutes().then(({ data }) => { getAsyncRoutes().then(({ data }) => {
handleAsyncRoutes(cloneDeep(data)); handleAsyncRoutes(cloneDeep(data));
storageSession.setItem(key, data);
storageSession().setItem(key, data);
resolve(router); resolve(router);
}); });
}); });

9
src/store/modules/app.ts

@ -9,14 +9,14 @@ export const useAppStore = defineStore({
state: (): appType => ({ state: (): appType => ({
sidebar: { sidebar: {
opened: opened:
storageLocal.getItem<StorageConfigs>("responsive-layout")
storageLocal().getItem<StorageConfigs>("responsive-layout")
?.sidebarStatus ?? getConfig().SidebarStatus, ?.sidebarStatus ?? getConfig().SidebarStatus,
withoutAnimation: false, withoutAnimation: false,
isClickCollapse: false isClickCollapse: false
}, },
// 这里的layout用于监听容器拖拉后恢复对应的导航模式 // 这里的layout用于监听容器拖拉后恢复对应的导航模式
layout: layout:
storageLocal.getItem<StorageConfigs>("responsive-layout")?.layout ??
storageLocal().getItem<StorageConfigs>("responsive-layout")?.layout ??
getConfig().Layout, getConfig().Layout,
device: deviceDetection() ? "mobile" : "desktop" device: deviceDetection() ? "mobile" : "desktop"
}), }),
@ -30,7 +30,8 @@ export const useAppStore = defineStore({
}, },
actions: { actions: {
TOGGLE_SIDEBAR(opened?: boolean, resize?: string) { TOGGLE_SIDEBAR(opened?: boolean, resize?: string) {
const layout = storageLocal.getItem<StorageConfigs>("responsive-layout");
const layout =
storageLocal().getItem<StorageConfigs>("responsive-layout");
if (opened && resize) { if (opened && resize) {
this.sidebar.withoutAnimation = true; this.sidebar.withoutAnimation = true;
this.sidebar.opened = true; this.sidebar.opened = true;
@ -45,7 +46,7 @@ export const useAppStore = defineStore({
this.sidebar.isClickCollapse = !this.sidebar.opened; this.sidebar.isClickCollapse = !this.sidebar.opened;
layout.sidebarStatus = this.sidebar.opened; layout.sidebarStatus = this.sidebar.opened;
} }
storageLocal.setItem("responsive-layout", layout);
storageLocal().setItem("responsive-layout", layout);
}, },
async toggleSideBar(opened?: boolean, resize?: string) { async toggleSideBar(opened?: boolean, resize?: string) {
await this.TOGGLE_SIDEBAR(opened, resize); await this.TOGGLE_SIDEBAR(opened, resize);

11
src/store/modules/epTheme.ts

@ -7,10 +7,10 @@ export const useEpThemeStore = defineStore({
id: "pure-epTheme", id: "pure-epTheme",
state: () => ({ state: () => ({
epThemeColor: epThemeColor:
storageLocal.getItem<StorageConfigs>("responsive-layout")?.epThemeColor ??
getConfig().EpThemeColor,
storageLocal().getItem<StorageConfigs>("responsive-layout")
?.epThemeColor ?? getConfig().EpThemeColor,
epTheme: epTheme:
storageLocal.getItem<StorageConfigs>("responsive-layout")?.theme ??
storageLocal().getItem<StorageConfigs>("responsive-layout")?.theme ??
getConfig().Theme getConfig().Theme
}), }),
getters: { getters: {
@ -30,12 +30,13 @@ export const useEpThemeStore = defineStore({
}, },
actions: { actions: {
setEpThemeColor(newColor: string): void { setEpThemeColor(newColor: string): void {
const layout = storageLocal.getItem<StorageConfigs>("responsive-layout");
const layout =
storageLocal().getItem<StorageConfigs>("responsive-layout");
this.epTheme = layout?.theme; this.epTheme = layout?.theme;
this.epThemeColor = newColor; this.epThemeColor = newColor;
if (!layout) return; if (!layout) return;
layout.epThemeColor = newColor; layout.epThemeColor = newColor;
storageLocal.setItem("responsive-layout", layout);
storageLocal().setItem("responsive-layout", layout);
} }
} }
}); });

15
src/store/modules/multiTags.ts

@ -9,12 +9,13 @@ export const useMultiTagsStore = defineStore({
id: "pure-multiTags", id: "pure-multiTags",
state: () => ({ state: () => ({
// 存储标签页信息(路由信息) // 存储标签页信息(路由信息)
multiTags: storageLocal.getItem<StorageConfigs>("responsive-configure")
multiTags: storageLocal().getItem<StorageConfigs>("responsive-configure")
?.multiTagsCache ?.multiTagsCache
? storageLocal.getItem<StorageConfigs>("responsive-tags")
? storageLocal().getItem<StorageConfigs>("responsive-tags")
: [...routerArrays], : [...routerArrays],
multiTagsCache: storageLocal.getItem<StorageConfigs>("responsive-configure")
?.multiTagsCache
multiTagsCache: storageLocal().getItem<StorageConfigs>(
"responsive-configure"
)?.multiTagsCache
}), }),
getters: { getters: {
getMultiTagsCache() { getMultiTagsCache() {
@ -25,14 +26,14 @@ export const useMultiTagsStore = defineStore({
multiTagsCacheChange(multiTagsCache: boolean) { multiTagsCacheChange(multiTagsCache: boolean) {
this.multiTagsCache = multiTagsCache; this.multiTagsCache = multiTagsCache;
if (multiTagsCache) { if (multiTagsCache) {
storageLocal.setItem("responsive-tags", this.multiTags);
storageLocal().setItem("responsive-tags", this.multiTags);
} else { } else {
storageLocal.removeItem("responsive-tags");
storageLocal().removeItem("responsive-tags");
} }
}, },
tagsCache(multiTags) { tagsCache(multiTags) {
this.getMultiTagsCache && this.getMultiTagsCache &&
storageLocal.setItem("responsive-tags", multiTags);
storageLocal().setItem("responsive-tags", multiTags);
}, },
handleTags<T>( handleTags<T>(
mode: string, mode: string,

4
src/store/modules/user.ts

@ -14,9 +14,9 @@ export const useUserStore = defineStore({
state: (): userType => ({ state: (): userType => ({
// 用户名 // 用户名
username: username:
storageSession.getItem<DataInfo<number>>(sessionKey)?.username ?? "",
storageSession().getItem<DataInfo<number>>(sessionKey)?.username ?? "",
// 页面级别权限 // 页面级别权限
roles: storageSession.getItem<DataInfo<number>>(sessionKey)?.roles ?? []
roles: storageSession().getItem<DataInfo<number>>(sessionKey)?.roles ?? []
}), }),
actions: { actions: {
/** 存储用户名 */ /** 存储用户名 */

8
src/utils/auth.ts

@ -23,7 +23,7 @@ export function getToken(): DataInfo<number> {
// 此处与`TokenKey`相同,此写法解决初始化时`Cookies`中不存在`TokenKey`报错 // 此处与`TokenKey`相同,此写法解决初始化时`Cookies`中不存在`TokenKey`报错
return Cookies.get(TokenKey) return Cookies.get(TokenKey)
? JSON.parse(Cookies.get(TokenKey)) ? JSON.parse(Cookies.get(TokenKey))
: storageSession.getItem(sessionKey);
: storageSession().getItem(sessionKey);
} }
/** /**
@ -47,7 +47,7 @@ export function setToken(data: DataInfo<Date>) {
function setSessionKey(username: string, roles: Array<string>) { function setSessionKey(username: string, roles: Array<string>) {
useUserStoreHook().SET_USERNAME(username); useUserStoreHook().SET_USERNAME(username);
useUserStoreHook().SET_ROLES(roles); useUserStoreHook().SET_ROLES(roles);
storageSession.setItem(sessionKey, {
storageSession().setItem(sessionKey, {
refreshToken, refreshToken,
expires, expires,
username, username,
@ -60,9 +60,9 @@ export function setToken(data: DataInfo<Date>) {
setSessionKey(username, roles); setSessionKey(username, roles);
} else { } else {
const username = const username =
storageSession.getItem<DataInfo<number>>(sessionKey)?.username ?? "";
storageSession().getItem<DataInfo<number>>(sessionKey)?.username ?? "";
const roles = const roles =
storageSession.getItem<DataInfo<number>>(sessionKey)?.roles ?? [];
storageSession().getItem<DataInfo<number>>(sessionKey)?.roles ?? [];
setSessionKey(username, roles); setSessionKey(username, roles);
} }
} }

Loading…
Cancel
Save