#
Junjie
2024-07-12 46d2d574d02f426522a2b5765d3bea7da52697c7
zy-asrs-admin/src/views/IndexView.vue
@@ -15,10 +15,11 @@
  TranslationOutlined,
  ApartmentOutlined,
} from "@ant-design/icons-vue";
import { formatMessage } from '@/utils/localeUtils.js';
import { formatMessage, loadData } from '@/utils/localeUtils.js';
const globalState = inject('globalState');
const selectedKeys = ref([]);
let openKeys = ref([]);
const collapsed = ref(false);
const router = useRouter();
let routerCache = ref([]);
@@ -143,11 +144,17 @@
  currentCache.value = item.name;
  selectedKeys.value = [item.key]
  // open menu
  let arr = item.key.split("/");
  let key = '/' + arr[1];
  openKeys.value = [key]
}
const switchLocale = (locale) => {
const switchLocale = async (locale) => {
  globalState.locale = locale;
  localStorage.setItem('locale', locale)
  loadData(locale);
  reloadTabs()
}
@@ -194,29 +201,31 @@
<template>
  <a-layout class="main">
    <a-layout-sider v-model:collapsed="collapsed" :trigger="null" collapsible>
    <a-layout-sider v-model:collapsed="collapsed" :trigger="null" collapsible theme="dark">
      <div class="logo" />
      <a-menu v-for="(item, index) in menuCache" :key="index" v-model:selectedKeys="selectedKeys" @select="menuSelect"
        theme="dark" mode="inline">
      <a-menu v-model:openKeys="openKeys" v-model:selectedKeys="selectedKeys" @select="menuSelect" theme="dark" mode="inline">
        <div>
          <a-menu-item key="/" name="主页">
            <HomeOutlined /> {{ formatMessage('common.home', '主页') }}
          </a-menu-item>
        </div>
        <a-sub-menu v-if="item.type == 0">
          <template #title>
            <span>
              <component :is="components[ref(item.icon).value]" />
              {{ formatMessage(item.languageId, item.name) }}
            </span>
          </template>
          <div v-for="(child, idx) in item.children">
            <a-menu-item v-if="child.status == 1" :key="child.route" :name="child.name" :languageId="child.languageId">
              {{ formatMessage(child.languageId, child.name) }}
            </a-menu-item>
          </div>
        </a-sub-menu>
        <div v-for="(item, index) in menuCache" :key="index">
          <a-sub-menu :key="item.route" v-if="item.type == 0">
            <template #title>
              <span>
                <component :is="components[ref(item.icon).value]" />
                {{ formatMessage(item.languageId, item.name) }}
              </span>
            </template>
            <div v-for="(child, idx) in item.children">
              <a-menu-item v-if="child.status == 1" :key="child.route" :name="child.name"
                :languageId="child.languageId">
                {{ formatMessage(child.languageId, child.name) }}
              </a-menu-item>
            </div>
          </a-sub-menu>
        </div>
      </a-menu>
    </a-layout-sider>
@@ -247,7 +256,7 @@
              <a-dropdown>
                <div>
                  <TranslationOutlined />
                  {{ globalState.localeList[globalState.locale].desc }}
                  {{ globalState.localeList[globalState.locale]?.desc }}
                </div>
                <template #overlay>
                  <a-menu>