mirror of
				https://github.com/pure-admin/vue-pure-admin.git
				synced 2025-11-03 13:44:47 +08:00 
			
		
		
		
	perf: tags
This commit is contained in:
		
							parent
							
								
									cec5af55d9
								
							
						
					
					
						commit
						a8a3e5b303
					
				@ -11,7 +11,7 @@ import { unref, watch, getCurrentInstance } from "vue";
 | 
			
		||||
import { deviceDetection } from "/@/utils/deviceDetection";
 | 
			
		||||
import screenfull from "../components/screenfull/index.vue";
 | 
			
		||||
import globalization from "/@/assets/svg/globalization.svg";
 | 
			
		||||
import { transformI18n } from "/@/utils/i18n";
 | 
			
		||||
import { transformI18n } from "/@/plugins/i18n";
 | 
			
		||||
 | 
			
		||||
const instance =
 | 
			
		||||
  getCurrentInstance().appContext.config.globalProperties.$storage;
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
<script setup lang="ts">
 | 
			
		||||
import { ref, watch } from "vue";
 | 
			
		||||
import { useRoute, useRouter, RouteLocationMatched } from "vue-router";
 | 
			
		||||
import { transformI18n } from "/@/utils/i18n";
 | 
			
		||||
import { transformI18n } from "/@/plugins/i18n";
 | 
			
		||||
 | 
			
		||||
const levelList = ref([]);
 | 
			
		||||
const route = useRoute();
 | 
			
		||||
 | 
			
		||||
@ -4,7 +4,7 @@ import { PropType, ref, nextTick, getCurrentInstance } from "vue";
 | 
			
		||||
import { childrenType } from "../../types";
 | 
			
		||||
import { useAppStoreHook } from "/@/store/modules/app";
 | 
			
		||||
import Icon from "/@/components/ReIcon/src/Icon.vue";
 | 
			
		||||
import { transformI18n } from "/@/utils/i18n";
 | 
			
		||||
import { transformI18n } from "/@/plugins/i18n";
 | 
			
		||||
import { findIconReg } from "/@/components/ReIcon";
 | 
			
		||||
const instance = getCurrentInstance().appContext.app.config.globalProperties;
 | 
			
		||||
const menuMode = instance.$storage.layout?.layout === "vertical";
 | 
			
		||||
 | 
			
		||||
@ -18,7 +18,7 @@ import closeOther from "/@/assets/svg/close_other.svg";
 | 
			
		||||
import closeRight from "/@/assets/svg/close_right.svg";
 | 
			
		||||
 | 
			
		||||
import { emitter } from "/@/utils/mitt";
 | 
			
		||||
import { transformI18n } from "/@/utils/i18n";
 | 
			
		||||
import { transformI18n } from "/@/plugins/i18n";
 | 
			
		||||
import { storageLocal } from "/@/utils/storage";
 | 
			
		||||
import { useRoute, useRouter } from "vue-router";
 | 
			
		||||
import { RouteConfigs, tagsViewsType } from "../../types";
 | 
			
		||||
 | 
			
		||||
@ -13,3 +13,27 @@ export const i18n = createI18n({
 | 
			
		||||
export function usI18n(app: App) {
 | 
			
		||||
  app.use(i18n);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 国际化转换工具函数
 | 
			
		||||
 * @param message message
 | 
			
		||||
 * @param isI18n  如果true,获取对应的消息,否则返回本身
 | 
			
		||||
 * @returns message
 | 
			
		||||
 */
 | 
			
		||||
export function transformI18n(message: string | object = "", isI18n = false) {
 | 
			
		||||
  if (!message) {
 | 
			
		||||
    return "";
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // 处理存储动态路由的title,格式 {zh:"",en:""}
 | 
			
		||||
  if (typeof message === "object") {
 | 
			
		||||
    return message[i18n.global?.locale];
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (isI18n) {
 | 
			
		||||
    //@ts-ignore
 | 
			
		||||
    return i18n.global.tc.call(i18n.global, message);
 | 
			
		||||
  } else {
 | 
			
		||||
    return message;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -27,7 +27,7 @@ import flowChartRouter from "./modules/flowchart";
 | 
			
		||||
import componentsRouter from "./modules/components";
 | 
			
		||||
// 动态路由
 | 
			
		||||
import { getAsyncRoutes } from "/@/api/routes";
 | 
			
		||||
import { transformI18n } from "../utils/i18n";
 | 
			
		||||
import { transformI18n } from "/@/plugins/i18n";
 | 
			
		||||
 | 
			
		||||
// https://cn.vitejs.dev/guide/features.html#glob-import
 | 
			
		||||
const modulesRoutes = import.meta.glob("/src/views/*/*/*.vue");
 | 
			
		||||
 | 
			
		||||
@ -1,23 +1,13 @@
 | 
			
		||||
import { storageLocal } from "/@/utils/storage";
 | 
			
		||||
import { deviceDetection } from "/@/utils/deviceDetection";
 | 
			
		||||
import { defineStore } from "pinia";
 | 
			
		||||
import { store } from "/@/store";
 | 
			
		||||
import { appType } from "./types";
 | 
			
		||||
import { defineStore } from "pinia";
 | 
			
		||||
import { getConfig } from "/@/config";
 | 
			
		||||
 | 
			
		||||
interface AppState {
 | 
			
		||||
  sidebar: {
 | 
			
		||||
    opened: boolean;
 | 
			
		||||
    withoutAnimation: boolean;
 | 
			
		||||
    // 判断是否手动点击Hamburger
 | 
			
		||||
    isClickHamburger: boolean;
 | 
			
		||||
  };
 | 
			
		||||
  layout: string;
 | 
			
		||||
  device: string;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export const useAppStore = defineStore({
 | 
			
		||||
  id: "pure-app",
 | 
			
		||||
  state: (): AppState => ({
 | 
			
		||||
  state: (): appType => ({
 | 
			
		||||
    sidebar: {
 | 
			
		||||
      opened: storageLocal.getItem("sidebarStatus")
 | 
			
		||||
        ? !!+storageLocal.getItem("sidebarStatus")
 | 
			
		||||
 | 
			
		||||
@ -1,15 +1,8 @@
 | 
			
		||||
import { defineStore } from "pinia";
 | 
			
		||||
import { store } from "/@/store";
 | 
			
		||||
import { getConfig } from "/@/config";
 | 
			
		||||
import { positionType } from "./types";
 | 
			
		||||
import { storageLocal } from "/@/utils/storage";
 | 
			
		||||
 | 
			
		||||
interface Itag {
 | 
			
		||||
  path: string;
 | 
			
		||||
  parentPath: string;
 | 
			
		||||
  name: string;
 | 
			
		||||
  meta: any;
 | 
			
		||||
}
 | 
			
		||||
import { multiType, positionType } from "./types";
 | 
			
		||||
 | 
			
		||||
export const useMultiTagsStore = defineStore({
 | 
			
		||||
  id: "pure-multiTags",
 | 
			
		||||
@ -43,16 +36,16 @@ export const useMultiTagsStore = defineStore({
 | 
			
		||||
    },
 | 
			
		||||
    handleTags<T>(
 | 
			
		||||
      mode: string,
 | 
			
		||||
      value?: T | Itag,
 | 
			
		||||
      value?: T | multiType,
 | 
			
		||||
      position?: positionType
 | 
			
		||||
    ): any {
 | 
			
		||||
    ): T {
 | 
			
		||||
      switch (mode) {
 | 
			
		||||
        case "equal":
 | 
			
		||||
          this.multiTags = value;
 | 
			
		||||
          break;
 | 
			
		||||
        case "push":
 | 
			
		||||
          {
 | 
			
		||||
            const tagVal = value as Itag;
 | 
			
		||||
            const tagVal = value as multiType;
 | 
			
		||||
            // 判断tag是否已存在:
 | 
			
		||||
            const tagHasExits = this.multiTags.some(tag => {
 | 
			
		||||
              return tag.path === tagVal?.path;
 | 
			
		||||
 | 
			
		||||
@ -1,16 +1,11 @@
 | 
			
		||||
import { defineStore } from "pinia";
 | 
			
		||||
import { store } from "/@/store";
 | 
			
		||||
import { setType } from "./types";
 | 
			
		||||
import { getConfig } from "/@/config";
 | 
			
		||||
 | 
			
		||||
interface SettingState {
 | 
			
		||||
  title: string;
 | 
			
		||||
  fixedHeader: boolean;
 | 
			
		||||
  hiddenSideBar: boolean;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export const useSettingStore = defineStore({
 | 
			
		||||
  id: "pure-setting",
 | 
			
		||||
  state: (): SettingState => ({
 | 
			
		||||
  state: (): setType => ({
 | 
			
		||||
    title: getConfig().Title,
 | 
			
		||||
    fixedHeader: getConfig().FixedHeader,
 | 
			
		||||
    hiddenSideBar: getConfig().HiddenSideBar
 | 
			
		||||
 | 
			
		||||
@ -9,3 +9,27 @@ export type positionType = {
 | 
			
		||||
  startIndex?: number;
 | 
			
		||||
  length?: number;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export type appType = {
 | 
			
		||||
  sidebar: {
 | 
			
		||||
    opened: boolean;
 | 
			
		||||
    withoutAnimation: boolean;
 | 
			
		||||
    // 判断是否手动点击Hamburger
 | 
			
		||||
    isClickHamburger: boolean;
 | 
			
		||||
  };
 | 
			
		||||
  layout: string;
 | 
			
		||||
  device: string;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export type multiType = {
 | 
			
		||||
  path: string;
 | 
			
		||||
  parentPath: string;
 | 
			
		||||
  name: string;
 | 
			
		||||
  meta: any;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export type setType = {
 | 
			
		||||
  title: string;
 | 
			
		||||
  fixedHeader: boolean;
 | 
			
		||||
  hiddenSideBar: boolean;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -1,19 +0,0 @@
 | 
			
		||||
import { i18n } from "../plugins/i18n";
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 消息转换
 | 
			
		||||
 * @param message message
 | 
			
		||||
 * @param isI18n  如果true,获取对应的消息,否则返回this
 | 
			
		||||
 * @returns message
 | 
			
		||||
 */
 | 
			
		||||
export function transformI18n(message = "", isI18n = false) {
 | 
			
		||||
  if (!message) {
 | 
			
		||||
    return "";
 | 
			
		||||
  }
 | 
			
		||||
  if (isI18n) {
 | 
			
		||||
    //@ts-ignore
 | 
			
		||||
    return i18n.global.tc.call(i18n.global, message);
 | 
			
		||||
  } else {
 | 
			
		||||
    return message;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user