From be1cd9e5b30097ca427a9c2b7b054b28854e410a Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期三, 11 三月 2026 13:21:36 +0800
Subject: [PATCH] #
---
src/main/webapp/views/index.html | 788 ++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 594 insertions(+), 194 deletions(-)
diff --git a/src/main/webapp/views/index.html b/src/main/webapp/views/index.html
index 37d2110..37d8d39 100644
--- a/src/main/webapp/views/index.html
+++ b/src/main/webapp/views/index.html
@@ -37,12 +37,25 @@
}
.layout-aside {
+ position: relative;
+ flex-shrink: 0;
display: flex;
flex-direction: column;
overflow: hidden;
border-radius: 16px;
background: linear-gradient(180deg, #16324d 0%, #0d2237 100%);
box-shadow: 0 14px 32px rgba(22, 50, 77, 0.18);
+ transform: translateZ(0);
+ backface-visibility: hidden;
+ will-change: width;
+ transition: width 0.22s cubic-bezier(0.22, 1, 0.36, 1),
+ box-shadow 0.22s ease;
+ -webkit-user-select: none;
+ user-select: none;
+ }
+
+ .layout-aside.is-animating {
+ pointer-events: none;
}
.layout-panel {
@@ -55,6 +68,8 @@
background: #f5f7fa;
box-shadow: 0 14px 32px rgba(83, 104, 129, 0.12);
border: 1px solid #e4eaf2;
+ transform: translateZ(0);
+ backface-visibility: hidden;
}
.aside-logo {
@@ -66,6 +81,8 @@
box-sizing: border-box;
color: #fff;
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
+ transition: min-height 0.22s cubic-bezier(0.22, 1, 0.36, 1),
+ padding 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
.aside-logo-image {
@@ -74,6 +91,8 @@
max-width: 178px;
height: auto;
object-fit: contain;
+ transform: translateZ(0);
+ transition: max-width 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
.aside-logo.is-collapse {
@@ -90,12 +109,25 @@
box-sizing: border-box;
}
+ .aside-fade-enter-active,
+ .aside-fade-leave-active {
+ transition: opacity 0.14s ease, transform 0.18s ease;
+ }
+
+ .aside-fade-enter,
+ .aside-fade-leave-to {
+ opacity: 0;
+ transform: translate3d(-10px, 0, 0);
+ }
+
.aside-search .el-input__inner {
height: 36px;
line-height: 36px;
border: 1px solid rgba(255, 255, 255, 0.10);
background: rgba(255, 255, 255, 0.08);
color: #fff;
+ -webkit-user-select: text;
+ user-select: text;
}
.aside-search .el-input__inner::placeholder {
@@ -109,6 +141,7 @@
.aside-scroll {
flex: 1;
min-height: 0;
+ transform: translateZ(0);
}
.aside-scroll .el-scrollbar__wrap {
@@ -118,6 +151,7 @@
.side-menu {
border-right: none;
background: transparent;
+ transform: translateZ(0);
}
.side-menu .el-submenu__title,
@@ -127,6 +161,7 @@
margin: 0 10px 6px;
border-radius: 10px;
box-sizing: border-box;
+ backface-visibility: hidden;
}
.side-menu .el-submenu__title:hover,
@@ -340,6 +375,10 @@
flex-shrink: 0;
}
+ .lang-select {
+ width: 160px;
+ }
+
.header-right .el-tag {
border-radius: 999px;
}
@@ -380,6 +419,8 @@
background: #fff;
border-bottom: 1px solid #e8edf5;
box-sizing: border-box;
+ -webkit-user-select: none;
+ user-select: none;
}
.page-tabs {
@@ -398,6 +439,8 @@
.page-tabs .el-tabs__item {
height: 38px;
line-height: 38px;
+ -webkit-user-select: none;
+ user-select: none;
}
.tabs-tools {
@@ -406,6 +449,8 @@
gap: 8px;
padding-bottom: 6px;
flex-shrink: 0;
+ -webkit-user-select: none;
+ user-select: none;
}
.content-main {
@@ -464,45 +509,10 @@
word-break: break-word;
}
- @keyframes slideInRight {
- from {
- transform: translate3d(100%, 0, 0);
- opacity: 0;
- }
-
- to {
- transform: translate3d(0, 0, 0);
- opacity: 1;
- }
- }
-
- @keyframes slideOutRight {
- from {
- transform: translate3d(0, 0, 0);
- opacity: 1;
- }
-
- to {
- transform: translate3d(100%, 0, 0);
- opacity: 0;
- }
- }
-
@keyframes asideSkeletonShimmer {
100% {
transform: translateX(100%);
}
- }
-
- .ai-drawer-layer {
- box-shadow: -8px 0 24px rgba(0, 0, 0, 0.15) !important;
- border-radius: 8px 0 0 8px !important;
- overflow: hidden;
- animation: slideInRight 0.5s cubic-bezier(0.16, 1, 0.3, 1);
- }
-
- .ai-drawer-layer-close {
- animation: slideOutRight 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
}
.ai-assistant-btn {
@@ -511,6 +521,87 @@
bottom: 40px;
z-index: 9999;
cursor: pointer;
+ }
+
+ .ai-assistant-mask {
+ position: fixed;
+ inset: 0;
+ z-index: 9997;
+ background: rgba(15, 23, 42, 0.10);
+ backdrop-filter: blur(3px);
+ }
+
+ .ai-assistant-drawer {
+ position: fixed;
+ top: 0;
+ right: 0;
+ z-index: 9998;
+ width: min(600px, 100vw);
+ height: 100vh;
+ display: flex;
+ flex-direction: column;
+ background: #fff;
+ border-radius: 12px 0 0 12px;
+ box-shadow: -10px 0 28px rgba(15, 23, 42, 0.18);
+ overflow: hidden;
+ }
+
+ .ai-drawer-header {
+ height: 54px;
+ padding: 0 16px 0 20px;
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ border-bottom: 1px solid rgba(226, 232, 240, 0.92);
+ background: rgba(248, 251, 255, 0.96);
+ color: #243447;
+ font-size: 15px;
+ font-weight: 700;
+ box-sizing: border-box;
+ }
+
+ .ai-drawer-close {
+ width: 32px;
+ height: 32px;
+ border: none;
+ border-radius: 10px;
+ background: transparent;
+ color: #5f7084;
+ cursor: pointer;
+ font-size: 16px;
+ }
+
+ .ai-drawer-close:hover {
+ background: rgba(236, 243, 249, 0.92);
+ color: #24405c;
+ }
+
+ .ai-drawer-frame {
+ flex: 1;
+ width: 100%;
+ border: none;
+ background: #fff;
+ }
+
+ .ai-mask-enter-active,
+ .ai-mask-leave-active {
+ transition: opacity .22s ease;
+ }
+
+ .ai-mask-enter,
+ .ai-mask-leave-to {
+ opacity: 0;
+ }
+
+ .ai-panel-enter-active,
+ .ai-panel-leave-active {
+ transition: transform .28s cubic-bezier(0.22, 1, 0.36, 1), opacity .22s ease;
+ }
+
+ .ai-panel-enter,
+ .ai-panel-leave-to {
+ transform: translate3d(100%, 0, 0);
+ opacity: 0;
}
@media (max-width: 1440px) {
@@ -529,20 +620,25 @@
<body>
<div id="app" v-cloak>
<el-container class="shell-container">
- <el-aside class="layout-aside" :width="asideWidth">
- <div class="aside-logo" :class="{ 'is-collapse': isCollapse }">
+ <el-aside
+ class="layout-aside"
+ :class="{ 'is-animating': collapseAnimating }"
+ :width="asideWidth">
+ <div class="aside-logo" :class="{ 'is-collapse': asideCompact }">
<img class="aside-logo-image" src="../static/images/zy-logo.png" alt="娴欐睙涓壃">
</div>
- <div class="aside-search" v-show="!isCollapse">
- <el-input
- v-model.trim="menuKeyword"
- size="small"
- clearable
- prefix-icon="el-icon-search"
- placeholder="鎼滅储鑿滃崟">
- </el-input>
- </div>
+ <transition name="aside-fade">
+ <div class="aside-search" v-show="showAsideExtras">
+ <el-input
+ v-model.trim="menuKeyword"
+ size="small"
+ clearable
+ prefix-icon="el-icon-search"
+ :placeholder="t('index.searchMenu')">
+ </el-input>
+ </div>
+ </transition>
<el-scrollbar class="aside-scroll">
<div v-if="menuLoading" class="aside-loading" aria-hidden="true">
@@ -558,7 +654,7 @@
ref="sideMenu"
class="side-menu"
:default-active="activeMenuKey"
- :collapse="isCollapse"
+ :collapse="menuCollapse"
:collapse-transition="false"
:default-openeds="defaultOpeneds"
unique-opened
@@ -586,25 +682,27 @@
<div class="aside-empty" v-if="filteredMenus.length === 0">
<el-empty
:image-size="80"
- :description="menuKeyword ? '娌℃湁鍖归厤鑿滃崟' : '褰撳墠璐﹀彿娌℃湁鍙敤鑿滃崟'">
+ :description="menuKeyword ? t('index.noMatchedMenu') : t('index.noAvailableMenu')">
</el-empty>
</div>
</template>
</el-scrollbar>
- <div class="aside-footer" v-show="!isCollapse">
- <div class="aside-footer-copy">漏 2026 娴欐睙涓壃绔嬪簱鎶�鏈湁闄愬叕鍙�</div>
- <div class="aside-footer-version">
- <span class="aside-footer-version-text">{{ versionText }}</span>
- <el-tag
- v-if="versionType"
- size="mini"
- :type="versionTagType"
- effect="dark">
- {{ versionTypeTag }}
- </el-tag>
+ <transition name="aside-fade">
+ <div class="aside-footer" v-show="showAsideExtras">
+ <div class="aside-footer-copy">漏 2026 {{ t('app.company') }}</div>
+ <div class="aside-footer-version">
+ <span class="aside-footer-version-text">{{ versionText }}</span>
+ <el-tag
+ v-if="versionType"
+ size="mini"
+ :type="versionTagType"
+ effect="dark">
+ {{ versionTypeTag }}
+ </el-tag>
+ </div>
</div>
- </div>
+ </transition>
</el-aside>
<el-container class="layout-panel">
@@ -627,7 +725,7 @@
size="mini"
:type="licenseTagType"
effect="dark">
- 涓存椂璁稿彲璇佹湁鏁堟湡锛歿{ licenseDays }}澶�
+ {{ t('index.licenseDays', [licenseDays]) }}
</el-tag>
<el-tag
v-if="fakeVisible"
@@ -636,8 +734,20 @@
:type="fakeRunning ? 'danger' : 'info'"
effect="dark"
@click.native="toggleFakeSystem">
- {{ fakeRunning ? '浠跨湡杩愯涓�' : '浠跨湡鏈繍琛�' }}
+ {{ fakeRunning ? t('index.fakeRunning') : t('index.fakeStopped') }}
</el-tag>
+ <el-select
+ v-model="currentLocale"
+ size="mini"
+ class="lang-select"
+ @change="handleLocaleChange">
+ <el-option
+ v-for="item in localeOptions"
+ :key="item.tag"
+ :label="item.label"
+ :value="item.tag">
+ </el-option>
+ </el-select>
<el-button circle size="mini" icon="el-icon-refresh" @click="refreshActiveTab"></el-button>
<el-button circle size="mini" icon="el-icon-full-screen" @click="toggleFullScreen"></el-button>
@@ -648,8 +758,8 @@
<i class="el-icon-arrow-down"></i>
</span>
<el-dropdown-menu slot="dropdown">
- <el-dropdown-item command="profile">鍩烘湰璧勬枡</el-dropdown-item>
- <el-dropdown-item command="logout" divided>閫�鍑虹櫥褰�</el-dropdown-item>
+ <el-dropdown-item command="profile">{{ t('common.profile') }}</el-dropdown-item>
+ <el-dropdown-item command="logout" divided>{{ t('common.logout') }}</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
@@ -671,10 +781,10 @@
</el-tabs>
<div class="tabs-tools">
- <el-tooltip content="鍏抽棴鍏朵粬椤电" placement="top">
+ <el-tooltip :content="t('common.closeOtherTabs')" placement="top">
<el-button size="mini" icon="el-icon-close" @click="closeOtherTabs"></el-button>
</el-tooltip>
- <el-tooltip content="杩斿洖鎺у埗涓績" placement="top">
+ <el-tooltip :content="t('common.backHome')" placement="top">
<el-button size="mini" type="primary" icon="el-icon-house" @click="openHomeTab"></el-button>
</el-tooltip>
</div>
@@ -691,6 +801,7 @@
v-for="tab in tabs"
:key="'frame-' + tab.name"
class="page-frame"
+ :data-tab-name="tab.name"
v-show="activeTab === tab.name"
:src="tab.currentSrc"
@load="handleFrameLoad(tab.name)">
@@ -701,27 +812,52 @@
</el-container>
<el-dialog
- title="璁稿彲璇佸嵆灏嗚繃鏈�"
+ :title="t('index.licenseExpiring')"
:visible.sync="licenseDialogVisible"
width="420px"
:close-on-click-modal="false">
<div class="license-dialog-text">{{ licenseDialogText }}</div>
<span slot="footer">
- <el-button type="primary" @click="licenseDialogVisible = false">鐭ラ亾浜�</el-button>
+ <el-button type="primary" @click="licenseDialogVisible = false">{{ t('common.ok') }}</el-button>
</span>
</el-dialog>
- <div
- id="ai-assistant-btn"
- class="ai-assistant-btn"
- @mouseenter="showAiTip"
- @mouseleave="hideAiTip"
- @click="openAiAssistant">
- </div>
+ <el-tooltip :content="t('common.aiAssistant')" placement="left">
+ <div
+ id="ai-assistant-btn"
+ class="ai-assistant-btn"
+ @click="openAiAssistant">
+ </div>
+ </el-tooltip>
+
+ <transition name="ai-mask">
+ <div
+ v-if="aiAssistantVisible"
+ class="ai-assistant-mask"
+ @click="closeAiAssistant">
+ </div>
+ </transition>
+
+ <transition name="ai-panel">
+ <div
+ v-if="aiAssistantVisible"
+ class="ai-assistant-drawer">
+ <div class="ai-drawer-header">
+ <span>{{ t('common.aiAssistant') }}</span>
+ <button type="button" class="ai-drawer-close" @click="closeAiAssistant">
+ <i class="el-icon-close"></i>
+ </button>
+ </div>
+ <iframe
+ v-if="aiAssistantMounted"
+ class="ai-drawer-frame"
+ :src="aiAssistantSrc">
+ </iframe>
+ </div>
+ </transition>
</div>
<script type="text/javascript" src="../static/js/jquery/jquery-3.3.1.min.js"></script>
-<script type="text/javascript" src="../static/js/layer/layer.js"></script>
<script type="text/javascript" src="../static/js/common.js"></script>
<script type="text/javascript" src="../static/vue/js/vue.min.js"></script>
<script type="text/javascript" src="../static/vue/element/element.js"></script>
@@ -740,17 +876,59 @@
group: "璐︽埛涓績",
menuKey: ""
};
+ var SIDEBAR_TRANSITION_MS = 220;
+ var SIDEBAR_EXPAND_CONTENT_DELAY = 180;
var TAB_STORAGE_KEY = "wcs-element-home-tabs";
var USER_STORAGE_KEY = "username";
+ var INDEX_I18N_FALLBACKS = {
+ "app.title": "娴欐睙涓壃 - 鑷姩鍖栫珛浣撲粨搴� - WCS",
+ "app.company": "娴欐睙涓壃绔嬪簱鎶�鏈湁闄愬叕鍙�",
+ "common.loadingPage": "姝e湪鍔犺浇椤甸潰...",
+ "common.loadingTab": "姝e湪鍔犺浇 鈥渰0}鈥� ...",
+ "common.refreshingTab": "姝e湪鍒锋柊 鈥渰0}鈥� ...",
+ "common.ok": "鐭ラ亾浜�",
+ "common.prompt": "鎻愮ず",
+ "common.profile": "鍩烘湰璧勬枡",
+ "common.logout": "閫�鍑虹櫥褰�",
+ "common.closeOtherTabs": "鍏抽棴鍏朵粬椤电",
+ "common.backHome": "杩斿洖鎺у埗涓績",
+ "common.aiAssistant": "AI鍔╂墜",
+ "common.workPage": "宸ヤ綔椤甸潰",
+ "common.businessPage": "涓氬姟椤甸潰",
+ "index.searchMenu": "鎼滅储鑿滃崟",
+ "index.noMatchedMenu": "娌℃湁鍖归厤鑿滃崟",
+ "index.noAvailableMenu": "褰撳墠璐﹀彿娌℃湁鍙敤鑿滃崟",
+ "index.licenseDays": "涓存椂璁稿彲璇佹湁鏁堟湡锛歿0}澶�",
+ "index.fakeRunning": "浠跨湡杩愯涓�",
+ "index.fakeStopped": "浠跨湡鏈繍琛�",
+ "index.licenseExpiring": "璁稿彲璇佸嵆灏嗚繃鏈�",
+ "index.homeTab": "鎺у埗涓績",
+ "index.homeGroup": "瀹炴椂鐩戞帶",
+ "index.profileGroup": "璐︽埛涓績",
+ "index.versionLoading": "Version loading...",
+ "index.licenseExpireAt": "璁稿彲璇佸皢浜� {0} 杩囨湡锛屽墿浣欐湁鏁堟湡锛歿1} 澶┿��",
+ "index.confirmStopFake": "纭畾瑕佸仠姝豢鐪熸ā鎷熷悧锛�",
+ "index.confirmStartFake": "纭畾瑕佸惎鍔ㄤ豢鐪熸ā鎷熷悧锛�",
+ "index.fakeStoppedSuccess": "浠跨湡妯℃嫙宸插仠姝�",
+ "index.fakeStartedSuccess": "浠跨湡妯℃嫙宸插惎鍔�",
+ "index.operationFailed": "鎿嶄綔澶辫触",
+ "index.menuLoadFailed": "鑿滃崟鍔犺浇澶辫触",
+ "index.menuLoadFailedDetail": "鑿滃崟鍔犺浇澶辫触锛岃妫�鏌ユ帴鍙g姸鎬�"
+ };
new Vue({
el: "#app",
data: function () {
return {
isCollapse: false,
+ asideCompact: false,
+ menuCollapse: false,
+ showAsideExtras: true,
+ collapseAnimating: false,
+ collapseTimer: null,
menuLoading: true,
pageLoading: true,
- loadingText: "姝e湪鍔犺浇椤甸潰...",
+ loadingText: window.WCS_I18N ? window.WCS_I18N.tl("姝e湪鍔犺浇椤甸潰...") : "姝e湪鍔犺浇椤甸潰...",
menuKeyword: "",
menus: [],
defaultOpeneds: [],
@@ -762,19 +940,22 @@
licenseDays: null,
licenseDialogVisible: false,
licenseDialogText: "",
+ currentLocale: window.WCS_I18N ? window.WCS_I18N.getLocale() : "zh-CN",
+ localeOptions: [],
fakeVisible: false,
fakeRunning: false,
fakeStatusInterval: null,
menuSyncVersion: 0,
menuSyncTimer: null,
- userName: localStorage.getItem(USER_STORAGE_KEY) || "绠$悊鍛�",
- aiLayerIndex: null,
- aiTipIndex: null
+ userName: localStorage.getItem(USER_STORAGE_KEY) || (window.WCS_I18N ? window.WCS_I18N.tl("绠$悊鍛�") : "绠$悊鍛�"),
+ aiAssistantVisible: false,
+ aiAssistantMounted: false,
+ aiAssistantSrc: baseUrl + "/views/ai/diagnosis.html"
};
},
computed: {
asideWidth: function () {
- return this.isCollapse ? "72px" : "248px";
+ return this.asideCompact ? "72px" : "248px";
},
filteredMenus: function () {
var keyword = (this.menuKeyword || "").toLowerCase();
@@ -819,7 +1000,7 @@
return result;
},
activeTabMeta: function () {
- return this.getTabByName(this.activeTab) || this.createTab(HOME_TAB_CONFIG);
+ return this.getTabByName(this.activeTab) || this.createTab(this.resolveHomeConfig());
},
activeTabTitle: function () {
return this.activeTabMeta.title;
@@ -829,7 +1010,7 @@
},
versionText: function () {
if (!this.version) {
- return "Version loading...";
+ return this.t("index.versionLoading");
}
return "Version " + this.version;
},
@@ -861,18 +1042,18 @@
return "info";
},
userShortName: function () {
- return (this.userName || "绠$悊鍛�").substring(0, 1);
+ return (this.userName || this.tl("绠$悊鍛�")).substring(0, 1);
}
},
watch: {
activeTab: function () {
var tab = this.getTabByName(this.activeTab);
- this.syncMenuStateByUrl(tab ? tab.url : HOME_TAB_CONFIG.url);
+ this.syncMenuStateByUrl(tab ? tab.url : this.resolveHomeConfig().url);
this.pageLoading = !!(tab && !tab.loaded);
if (this.pageLoading) {
- this.loadingText = "姝e湪鍔犺浇 鈥�" + tab.title + "鈥� ...";
+ this.loadingText = this.t("common.loadingTab", [tab.title]);
}
- document.title = (tab ? tab.title : HOME_TAB_CONFIG.title) + " - 娴欐睙涓壃 - 鑷姩鍖栫珛浣撲粨搴� - WCS";
+ this.updateDocumentTitle(tab ? tab.title : this.resolveHomeConfig().title);
this.persistTabs();
}
},
@@ -883,6 +1064,7 @@
}
this.restoreTabs();
+ this.bindI18n();
this.installCompatBridge();
this.loadSystemVersion();
this.loadMenu();
@@ -892,7 +1074,7 @@
},
mounted: function () {
$("#ai-assistant-btn").html(getAiIconHtml(60, 60));
- document.title = this.activeTabTitle + " - 娴欐睙涓壃 - 鑷姩鍖栫珛浣撲粨搴� - WCS";
+ this.updateDocumentTitle(this.activeTabTitle);
},
beforeDestroy: function () {
if (this.fakeStatusInterval) {
@@ -907,12 +1089,144 @@
clearTimeout(this.menuSyncTimer);
this.menuSyncTimer = null;
}
- if (this.aiTipIndex) {
- layer.close(this.aiTipIndex);
- this.aiTipIndex = null;
+ if (this.collapseTimer) {
+ clearTimeout(this.collapseTimer);
+ this.collapseTimer = null;
}
},
methods: {
+ t: function (key, params) {
+ var value = window.WCS_I18N ? window.WCS_I18N.t(key, params) : key;
+ if (value !== key) {
+ return value;
+ }
+ value = INDEX_I18N_FALLBACKS[key] || key;
+ if (!params) {
+ return value;
+ }
+ if (Object.prototype.toString.call(params) === "[object Array]") {
+ for (var i = 0; i < params.length; i++) {
+ value = value.replace(new RegExp("\\{" + i + "\\}", "g"), params[i]);
+ }
+ return value;
+ }
+ return value;
+ },
+ tl: function (text) {
+ return window.WCS_I18N ? window.WCS_I18N.tl(text) : text;
+ },
+ bindI18n: function () {
+ var that = this;
+ if (!window.WCS_I18N) {
+ return;
+ }
+ window.WCS_I18N.onReady(function (i18n) {
+ that.currentLocale = i18n.getLocale();
+ that.localeOptions = i18n.getLocaleOptions();
+ that.refreshI18nState();
+ });
+ },
+ refreshI18nState: function () {
+ var that = this;
+ var homeConfig = this.resolveHomeConfig();
+ var profileConfig = this.resolveProfileConfig();
+ var i;
+ HOME_TAB_CONFIG.title = homeConfig.title;
+ HOME_TAB_CONFIG.group = homeConfig.group;
+ PROFILE_TAB_CONFIG.title = profileConfig.title;
+ PROFILE_TAB_CONFIG.group = profileConfig.group;
+ for (i = 0; i < this.tabs.length; i++) {
+ this.syncTabMeta(this.tabs[i], homeConfig, profileConfig);
+ }
+ this.updateDocumentTitle(this.activeTabTitle);
+ this.persistTabs();
+ this.updateLicenseDialogText();
+ this.$nextTick(function () {
+ if (window.WCS_I18N) {
+ window.WCS_I18N.apply(document.body);
+ }
+ that.syncAllFramesI18n();
+ });
+ },
+ handleLocaleChange: function (locale) {
+ if (window.WCS_I18N) {
+ window.WCS_I18N.setLocale(locale);
+ }
+ },
+ resolveHomeConfig: function () {
+ return {
+ title: this.t("index.homeTab"),
+ url: HOME_TAB_CONFIG.url,
+ home: true,
+ group: this.t("index.homeGroup"),
+ menuKey: HOME_TAB_CONFIG.menuKey || ""
+ };
+ },
+ resolveProfileConfig: function () {
+ return {
+ title: this.t("common.profile"),
+ url: PROFILE_TAB_CONFIG.url,
+ home: false,
+ group: this.t("index.profileGroup"),
+ menuKey: PROFILE_TAB_CONFIG.menuKey || ""
+ };
+ },
+ translateTabTitle: function (title) {
+ return this.tl(title);
+ },
+ findMenuMeta: function (tab) {
+ var normalizedUrl;
+ var i;
+ var j;
+ var group;
+ var item;
+ if (!tab) {
+ return null;
+ }
+ normalizedUrl = this.resolveViewSrc(tab.url);
+ for (i = 0; i < this.menus.length; i++) {
+ group = this.menus[i];
+ for (j = 0; j < group.subMenu.length; j++) {
+ item = group.subMenu[j];
+ if ((tab.menuKey && item.tabKey === tab.menuKey) || item.url === normalizedUrl) {
+ return {
+ group: group,
+ item: item
+ };
+ }
+ }
+ }
+ return null;
+ },
+ syncTabMeta: function (tab, homeConfig, profileConfig) {
+ var menuMeta;
+ if (!tab) {
+ return;
+ }
+ if (this.isHomeTabUrl(tab.url)) {
+ tab.title = homeConfig.title;
+ tab.group = homeConfig.group;
+ tab.home = true;
+ return;
+ }
+ if (this.resolveViewSrc(tab.url) === this.resolveViewSrc(profileConfig.url)) {
+ tab.title = profileConfig.title;
+ tab.group = profileConfig.group;
+ return;
+ }
+ menuMeta = this.findMenuMeta(tab);
+ if (menuMeta) {
+ tab.title = menuMeta.item.name;
+ tab.group = menuMeta.group.menu;
+ tab.menuKey = menuMeta.item.tabKey || tab.menuKey;
+ return;
+ }
+ tab.title = this.translateTabTitle(tab.title);
+ tab.group = this.tl(tab.group);
+ },
+ updateDocumentTitle: function (title) {
+ document.title = title + " - " + this.t("app.title");
+ },
resolveMenuIcon: function (code) {
var iconMap = {
index: "el-icon-s-home",
@@ -935,7 +1249,7 @@
title: config.title,
name: config.url,
url: config.url,
- currentSrc: config.url,
+ currentSrc: this.addNonce(config.url),
home: !!config.home,
group: config.group || "",
menuKey: config.menuKey || "",
@@ -944,17 +1258,17 @@
},
normalizeStoredTab: function (tab) {
var created = this.createTab({
- title: tab.title,
+ title: this.translateTabTitle(tab.title),
url: this.resolveViewSrc(tab.url),
home: !!tab.home,
- group: tab.group || "",
+ group: this.tl(tab.group || ""),
menuKey: tab.menuKey || ""
});
created.loaded = false;
return created;
},
restoreTabs: function () {
- var homeTab = this.createTab(HOME_TAB_CONFIG);
+ var homeTab = this.createTab(this.resolveHomeConfig());
var raw = localStorage.getItem(TAB_STORAGE_KEY);
var parsed;
var tabs = [];
@@ -996,9 +1310,9 @@
this.tabs = tabs;
this.activeTab = this.hasTab(active) ? active : homeTab.name;
- this.loadingText = "姝e湪鍔犺浇 鈥�" + this.activeTabTitle + "鈥� ...";
+ this.loadingText = this.t("common.loadingTab", [this.activeTabTitle]);
this.pageLoading = true;
- document.title = this.activeTabTitle + " - 娴欐睙涓壃 - 鑷姩鍖栫珛浣撲粨搴� - WCS";
+ this.updateDocumentTitle(this.activeTabTitle);
},
persistTabs: function () {
var tabs = [];
@@ -1021,7 +1335,8 @@
return !!this.getTabByName(name);
},
isHomeTabUrl: function (url) {
- return this.resolveViewSrc(url || HOME_TAB_CONFIG.url) === this.resolveViewSrc(HOME_TAB_CONFIG.url);
+ var homeUrl = this.resolveHomeConfig().url;
+ return this.resolveViewSrc(url || homeUrl) === this.resolveViewSrc(homeUrl);
},
getTabByName: function (name) {
var i;
@@ -1054,28 +1369,29 @@
}
}
- this.loadingText = "姝e湪鍔犺浇 鈥�" + tab.title + "鈥� ...";
+ this.loadingText = this.t("common.loadingTab", [tab.title]);
this.pageLoading = !tab.loaded;
this.activeTab = tab.name;
this.syncMenuStateByUrl(tab.url);
},
openHomeTab: function () {
- this.addOrActivateTab(HOME_TAB_CONFIG);
+ this.addOrActivateTab(this.resolveHomeConfig());
},
openProfileTab: function () {
- this.addOrActivateTab(PROFILE_TAB_CONFIG);
+ this.addOrActivateTab(this.resolveProfileConfig());
},
closeAllTabs: function () {
- this.tabs = [this.createTab(HOME_TAB_CONFIG)];
- this.activeTab = HOME_TAB_CONFIG.url;
- this.syncMenuStateByUrl(HOME_TAB_CONFIG.url);
+ var homeConfig = this.resolveHomeConfig();
+ this.tabs = [this.createTab(homeConfig)];
+ this.activeTab = homeConfig.url;
+ this.syncMenuStateByUrl(homeConfig.url);
this.pageLoading = true;
- this.loadingText = "姝e湪鍔犺浇 鈥滄帶鍒朵腑蹇冣�� ...";
+ this.loadingText = this.t("common.loadingTab", [homeConfig.title]);
this.persistTabs();
},
closeOtherTabs: function () {
var active = this.getTabByName(this.activeTab);
- var homeTab = this.createTab(HOME_TAB_CONFIG);
+ var homeTab = this.createTab(this.resolveHomeConfig());
var result = [homeTab];
if (active && active.name !== homeTab.name) {
@@ -1087,7 +1403,7 @@
},
removeTab: function (name) {
var i;
- var nextTabName = HOME_TAB_CONFIG.url;
+ var nextTabName = this.resolveHomeConfig().url;
for (i = 0; i < this.tabs.length; i++) {
if (this.tabs[i].name === name) {
@@ -1104,8 +1420,8 @@
}
if (this.tabs.length === 0) {
- this.tabs.push(this.createTab(HOME_TAB_CONFIG));
- nextTabName = HOME_TAB_CONFIG.url;
+ this.tabs.push(this.createTab(this.resolveHomeConfig()));
+ nextTabName = this.resolveHomeConfig().url;
}
this.activeTab = nextTabName;
@@ -1116,6 +1432,7 @@
if (tab) {
tab.loaded = true;
}
+ this.syncFrameI18n(name);
if (this.activeTab === name) {
this.pageLoading = false;
}
@@ -1127,14 +1444,144 @@
}
tab.loaded = false;
tab.currentSrc = this.addNonce(tab.url);
- this.loadingText = "姝e湪鍒锋柊 鈥�" + tab.title + "鈥� ...";
+ this.loadingText = this.t("common.refreshingTab", [tab.title]);
this.pageLoading = true;
},
addNonce: function (url) {
return url + (url.indexOf("?") === -1 ? "?" : "&") + "_t=" + new Date().getTime();
},
+ findFrameElement: function (name) {
+ var frames;
+ var i;
+ if (!this.$el) {
+ return null;
+ }
+ frames = this.$el.querySelectorAll("iframe[data-tab-name]");
+ for (i = 0; i < frames.length; i++) {
+ if (frames[i].getAttribute("data-tab-name") === name) {
+ return frames[i];
+ }
+ }
+ return null;
+ },
+ syncFrameI18n: function (name) {
+ var that = this;
+ var frame = this.findFrameElement(name);
+ var frameWindow;
+ var frameDocument;
+ var script;
+
+ function applyFrameI18n() {
+ try {
+ if (!frameWindow.WCS_I18N || typeof frameWindow.WCS_I18N.onReady !== "function") {
+ return;
+ }
+ frameWindow.WCS_I18N.setLocale(that.currentLocale || "zh-CN", false);
+ frameWindow.WCS_I18N.onReady(function (i18n) {
+ i18n.apply(frameDocument.body || frameDocument.documentElement);
+ if (frameDocument.title) {
+ frameDocument.title = i18n.tl(frameDocument.title);
+ }
+ });
+ } catch (e) {
+ }
+ }
+
+ if (!frame) {
+ return;
+ }
+ try {
+ frameWindow = frame.contentWindow;
+ frameDocument = frameWindow.document;
+ } catch (e) {
+ return;
+ }
+ try {
+ frameWindow.localStorage.setItem("wcs_lang", this.currentLocale || "zh-CN");
+ } catch (e) {
+ }
+ if (frameDocument && frameDocument.documentElement) {
+ frameDocument.documentElement.lang = this.currentLocale || "zh-CN";
+ }
+ if (frameWindow.WCS_I18N && typeof frameWindow.WCS_I18N.onReady === "function") {
+ applyFrameI18n();
+ return;
+ }
+ if (!frameDocument || !frameDocument.head || frameDocument.getElementById("wcs-i18n-bridge-script")) {
+ return;
+ }
+ script = frameDocument.createElement("script");
+ script.id = "wcs-i18n-bridge-script";
+ script.type = "text/javascript";
+ script.src = baseUrl + "/static/js/common.js";
+ script.onload = applyFrameI18n;
+ frameDocument.head.appendChild(script);
+ },
+ syncAllFramesI18n: function () {
+ var i;
+ for (i = 0; i < this.tabs.length; i++) {
+ this.syncFrameI18n(this.tabs[i].name);
+ }
+ },
+ clearCollapseTimer: function () {
+ if (this.collapseTimer) {
+ clearTimeout(this.collapseTimer);
+ this.collapseTimer = null;
+ }
+ },
+ nextFrame: function (callback) {
+ if (window.requestAnimationFrame) {
+ window.requestAnimationFrame(function () {
+ callback();
+ });
+ return;
+ }
+ setTimeout(callback, 16);
+ },
+ finishCollapseStage: function (callback, delay) {
+ var that = this;
+ this.clearCollapseTimer();
+ this.collapseTimer = setTimeout(function () {
+ that.collapseTimer = null;
+ callback();
+ }, delay);
+ },
toggleCollapse: function () {
- this.isCollapse = !this.isCollapse;
+ var that = this;
+
+ if (this.collapseAnimating) {
+ return;
+ }
+
+ this.collapseAnimating = true;
+
+ if (this.isCollapse) {
+ this.isCollapse = false;
+ this.asideCompact = false;
+ this.nextFrame(function () {
+ that.finishCollapseStage(function () {
+ that.menuCollapse = false;
+ that.showAsideExtras = true;
+ that.collapseAnimating = false;
+ that.$nextTick(function () {
+ that.syncMenuStateByUrl(that.activeTabUrl);
+ });
+ }, SIDEBAR_EXPAND_CONTENT_DELAY);
+ });
+ return;
+ }
+
+ this.isCollapse = true;
+ this.showAsideExtras = false;
+ this.menuCollapse = true;
+ this.$nextTick(function () {
+ that.nextFrame(function () {
+ that.asideCompact = true;
+ that.finishCollapseStage(function () {
+ that.collapseAnimating = false;
+ }, SIDEBAR_TRANSITION_MS);
+ });
+ });
},
handleMenuSelect: function (group, item) {
this.addOrActivateTab({
@@ -1197,7 +1644,7 @@
item = group.subMenu[j];
subMenu.push({
id: item.id,
- name: item.name || item.code || "鏈懡鍚嶉〉闈�",
+ name: item.name || item.code || this.tl("鏈懡鍚嶉〉闈�"),
code: item.code || "",
url: this.buildMenuSrc(item.code, item.id),
tabKey: this.buildMenuSrc(item.code, item.id)
@@ -1206,7 +1653,7 @@
result.push({
menuId: group.menuId,
- menu: group.menu || "鏈懡鍚嶅垎缁�",
+ menu: group.menu || this.tl("鏈懡鍚嶅垎缁�"),
menuCode: group.menuCode || "",
subMenu: subMenu
});
@@ -1233,7 +1680,7 @@
},
resolveViewSrc: function (path) {
if (!path) {
- return HOME_TAB_CONFIG.url;
+ return this.resolveHomeConfig().url;
}
if (/^https?:\/\//.test(path) || path.indexOf(baseUrl) === 0) {
return path;
@@ -1266,7 +1713,7 @@
}
},
syncMenuStateByUrl: function (url) {
- var targetUrl = this.resolveViewSrc(url || HOME_TAB_CONFIG.url);
+ var targetUrl = this.resolveViewSrc(url || this.resolveHomeConfig().url);
var activeMenuKey = "";
var groupIndex = "";
var that = this;
@@ -1291,6 +1738,9 @@
return;
}
if (!menu) {
+ return;
+ }
+ if (that.menuCollapse) {
return;
}
openedMenus = menu.openedMenus ? menu.openedMenus.slice() : [];
@@ -1332,16 +1782,17 @@
that.menuLoading = false;
if (res.code === 200) {
that.menus = that.normalizeMenuData(res.data || []);
+ that.refreshI18nState();
that.syncMenuStateByUrl(that.activeTabUrl);
} else if (res.code === 403) {
top.location.href = baseUrl + "/login";
} else {
- that.$message.error(res.msg || "鑿滃崟鍔犺浇澶辫触");
+ that.$message.error(res.msg || that.t("index.menuLoadFailed"));
}
},
error: function () {
that.menuLoading = false;
- that.$message.error("鑿滃崟鍔犺浇澶辫触锛岃妫�鏌ユ帴鍙g姸鎬�");
+ that.$message.error(that.t("index.menuLoadFailedDetail"));
}
});
},
@@ -1388,6 +1839,7 @@
showPopup: function (days) {
var currentDate;
var expiryDate;
+ var formattedDate;
if (days === "" || days === null || typeof days === "undefined") {
this.hidePopup();
@@ -1397,9 +1849,15 @@
currentDate = new Date();
expiryDate = new Date();
expiryDate.setDate(currentDate.getDate() + Number(days) + 1);
- this.licenseDialogText = "璁稿彲璇佸皢浜� " + new Intl.DateTimeFormat("zh-CN").format(expiryDate) +
- " 杩囨湡锛屽墿浣欐湁鏁堟湡锛�" + days + " 澶┿��";
+ formattedDate = new Intl.DateTimeFormat(this.currentLocale || "zh-CN").format(expiryDate);
+ this.licenseDialogText = this.t("index.licenseExpireAt", [formattedDate, days]);
this.licenseDialogVisible = true;
+ },
+ updateLicenseDialogText: function () {
+ if (this.licenseDays === "" || this.licenseDays === null || typeof this.licenseDays === "undefined" || this.licenseDays > 15) {
+ return;
+ }
+ this.showPopup(this.licenseDays);
},
hidePopup: function () {
this.licenseDialogVisible = false;
@@ -1447,17 +1905,17 @@
if (this.fakeRunning) {
url = baseUrl + "/openapi/stopFakeSystem";
- text = "纭畾瑕佸仠姝豢鐪熸ā鎷熷悧锛�";
- successMsg = "浠跨湡妯℃嫙宸插仠姝�";
+ text = this.t("index.confirmStopFake");
+ successMsg = this.t("index.fakeStoppedSuccess");
running = false;
} else {
url = baseUrl + "/openapi/startFakeSystem";
- text = "纭畾瑕佸惎鍔ㄤ豢鐪熸ā鎷熷悧锛�";
- successMsg = "浠跨湡妯℃嫙宸插惎鍔�";
+ text = this.t("index.confirmStartFake");
+ successMsg = this.t("index.fakeStartedSuccess");
running = true;
}
- this.$confirm(text, "鎻愮ず", {
+ this.$confirm(text, this.t("common.prompt"), {
type: "warning"
}).then(function () {
$.ajax({
@@ -1469,7 +1927,7 @@
that.fakeRunning = running;
that.$message.success(successMsg);
} else {
- that.$message.error(res.msg || "鎿嶄綔澶辫触");
+ that.$message.error(res.msg || that.t("index.operationFailed"));
}
}
});
@@ -1482,72 +1940,14 @@
document.exitFullscreen();
}
},
- showAiTip: function () {
- this.hideAiTip();
- this.aiTipIndex = layer.tips("AI鍔╂墜", "#ai-assistant-btn", {
- tips: [1, "#333"],
- time: -1
- });
- },
- hideAiTip: function () {
- if (this.aiTipIndex) {
- layer.close(this.aiTipIndex);
- this.aiTipIndex = null;
- }
- },
openAiAssistant: function () {
- var that = this;
- var $layero;
- var $shade;
-
- this.hideAiTip();
-
- if (this.aiLayerIndex !== null && $("#layui-layer" + this.aiLayerIndex).length > 0) {
- $layero = $("#layui-layer" + this.aiLayerIndex);
- $shade = $("#layui-layer-shade" + this.aiLayerIndex);
-
- $shade.show().css("opacity", 0.1);
- $layero.show();
- $layero.removeClass("ai-drawer-layer-close");
- $layero.removeClass("ai-drawer-layer");
- void $layero.get(0).offsetWidth;
- $layero.addClass("ai-drawer-layer");
- return;
+ if (!this.aiAssistantMounted) {
+ this.aiAssistantMounted = true;
}
-
- layer.open({
- type: 2,
- title: false,
- closeBtn: 0,
- shadeClose: false,
- shade: 0.1,
- area: ["600px", "100%"],
- offset: "r",
- anim: -1,
- isOutAnim: false,
- skin: "ai-drawer-layer",
- content: "ai/diagnosis.html",
- success: function (layero, index) {
- var shadeId;
- var $shadeEl;
-
- that.aiLayerIndex = index;
- shadeId = layero.attr("id").replace("layui-layer", "layui-layer-shade");
- $shadeEl = $("#" + shadeId);
- $shadeEl.css({
- "backdrop-filter": "blur(3px)",
- transition: "opacity 0.8s"
- });
- $shadeEl.off("click.aiAssistant").on("click.aiAssistant", function () {
- layero.addClass("ai-drawer-layer-close");
- $shadeEl.css("opacity", 0);
- setTimeout(function () {
- layero.hide();
- $shadeEl.hide();
- }, 400);
- });
- }
- });
+ this.aiAssistantVisible = true;
+ },
+ closeAiAssistant: function () {
+ this.aiAssistantVisible = false;
},
handleUserCommand: function (command) {
if (command === "profile") {
@@ -1565,7 +1965,7 @@
startUserSync: function () {
var that = this;
this.userSyncTimer = setInterval(function () {
- that.userName = localStorage.getItem(USER_STORAGE_KEY) || "绠$悊鍛�";
+ that.userName = localStorage.getItem(USER_STORAGE_KEY) || that.tl("绠$悊鍛�");
}, 1000);
},
installCompatBridge: function () {
@@ -1588,10 +1988,10 @@
}
url = that.resolveViewSrc(param.menuPath);
that.addOrActivateTab({
- title: that.stripTags(param.menuName) || "宸ヤ綔椤甸潰",
+ title: that.stripTags(param.menuName) || that.t("common.workPage"),
url: url,
home: false,
- group: "涓氬姟椤甸潰",
+ group: that.t("common.businessPage"),
menuKey: that.findMenuKeyByUrl(url)
});
};
@@ -1603,10 +2003,10 @@
}
url = that.resolveViewSrc(param.menuPath);
that.addOrActivateTab({
- title: that.stripTags(param.menuName) || HOME_TAB_CONFIG.title,
+ title: that.stripTags(param.menuName) || that.resolveHomeConfig().title,
url: url,
home: true,
- group: HOME_TAB_CONFIG.group,
+ group: that.resolveHomeConfig().group,
menuKey: that.findMenuKeyByUrl(url)
});
};
--
Gitblit v1.9.1