#
Junjie
2025-02-14 ac4341ea6b66ae02427d39d35f41d42d78b2eb2e
zy-asrs-admin/src/views/IndexView.vue
@@ -14,8 +14,11 @@
  UserOutlined,
  TranslationOutlined,
  ApartmentOutlined,
  CaretLeftOutlined,
  CaretRightOutlined,
} from "@ant-design/icons-vue";
import { formatMessage, loadData } from '@/utils/localeUtils.js';
import AiView from '@/components/ai/index.vue'
const globalState = inject('globalState');
const selectedKeys = ref([]);
@@ -28,6 +31,7 @@
let isRouterAlive = ref(true);
const menuCache = ref([]);
const hostList = ref([]);
const tabsContent = ref(null);
const components = {
  ...Icons,
@@ -120,7 +124,7 @@
    isRouterAlive.value = false;
    nextTick(() => {
      isRouterAlive.value = true;
      message.success(formatMessage('common.success', '加载成功'));
      // message.success(formatMessage('common.success', '加载成功'));
    })
  } catch (error) {
    message.error(formatMessage('common.fail', '加载失败'));
@@ -185,7 +189,7 @@
  post('/api/license/getLicenseDays', {}).then((resp) => {
    let result = resp.data;
    let data = result.data;
    if(result.code == 200) {
    if (result.code == 200) {
      licenseDays.value = data;
    }
  })
@@ -209,13 +213,24 @@
  window.location.reload();
}
const handleScroll = (data) => {
  let position = tabsContent.value.scrollLeft;
  let offset = position * 0.1 + 30;
  if (data == 'left') {
    tabsContent.value.scrollLeft = position - offset;
  } else {
    tabsContent.value.scrollLeft = position + offset;
  }
}
</script>
<template>
  <a-layout class="main">
    <a-layout-sider class="main-sider" v-model:collapsed="collapsed" :trigger="null" collapsible theme="dark">
      <div class="logo" />
      <a-menu v-model:openKeys="openKeys" 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', '主页') }}
@@ -301,25 +316,40 @@
      </a-layout-header>
      <a-layout-content class="content-view">
        <div class="tabs-fixed">
          <div v-for="(item, index) in routerCacheList" :key="index" @click="switchTabs(item)" class="tabs-item"
            :class="currentCache == item.name ? 'tabs-item-active' : ''">
            <div :class="currentCache == item.name ? '' : 'tabs-item-reload-none'" @click="reloadTabs" @click.stop>
              <RedoOutlined />
            </div>
            <div>{{ formatMessage(item.languageId, item.name) }}</div>
            <div @click="closeTabs(item)" @click.stop>
              <CloseOutlined />
          <div class="tabs-arrow-left" @click="handleScroll('left')">
            <CaretLeftOutlined />
          </div>
          <div class="tabs-content" ref="tabsContent">
            <div class="tabs-content-item">
              <div v-for="(item, index) in routerCacheList" :key="index" @click="switchTabs(item)" class="tabs-item"
                :class="currentCache == item.name ? 'tabs-item-active' : ''">
                <div :class="currentCache == item.name ? '' : 'tabs-item-reload-none'" @click="reloadTabs" @click.stop>
                  <RedoOutlined />
                </div>
                <div>{{ formatMessage(item.languageId, item.name) }}</div>
                <div @click="closeTabs(item)" @click.stop>
                  <CloseOutlined />
                </div>
              </div>
            </div>
          </div>
          <div class="tabs-arrow-right" @click="handleScroll('right')">
            <CaretRightOutlined />
          </div>
        </div>
        <router-view v-slot="{ Component, route }" v-if="isRouterAlive">
          <keep-alive :include="routerCache">
            <component :is="Component" />
            <component :is="Component" @pageReload="reloadTabs" />
          </keep-alive>
        </router-view>
      </a-layout-content>
    </a-layout>
  </a-layout>
  <AiView />
</template>
<style scoped></style>