From fc3d0f0762f5a2900ea54018904d340cfe72d1d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=90=BE=E7=AB=8B?= Date: Wed, 19 Jun 2024 16:56:59 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E5=88=87=E6=8D=A2=E8=AF=AD=E8=A8=80?= =?UTF-8?q?=E4=B8=8D=E6=B8=85=E7=A9=BA=20tabs=20=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web-vue/src/i18n/index.ts | 8 ++--- web-vue/src/i18n/locales/en_us.json | 2 +- web-vue/src/i18n/locales/zh_cn.json | 3 +- web-vue/src/i18n/locales/zh_hk.json | 2 +- web-vue/src/i18n/locales/zh_tw.json | 2 +- web-vue/src/main.ts | 4 --- web-vue/src/pages/layout/user-header.vue | 2 +- web-vue/src/stores/app.ts | 7 +++- web-vue/src/stores/guide.ts | 7 +--- web-vue/src/stores/menu2.ts | 43 ++++++++++++++++++------ web-vue/src/utils/const.ts | 6 ++-- 11 files changed, 52 insertions(+), 34 deletions(-) diff --git a/web-vue/src/i18n/index.ts b/web-vue/src/i18n/index.ts index cba48040d..1a8855719 100644 --- a/web-vue/src/i18n/index.ts +++ b/web-vue/src/i18n/index.ts @@ -27,14 +27,14 @@ export const langDict: { [key: string]: LangType } = { local: () => import(/* @vite-ignore */ './locales/zh_cn.json') }, 'zh-hk': { - // 🇭🇰 - label: '\u7e41\u4f53\u4e2d\u6587\uff08\u4e2d\u56fd\u9999\u6e2f\uff09', + // 🇭🇰 繁體中文(中國香港) + label: '\u7e41\u9ad4\u4e2d\u6587\uff08\u4e2d\u570b\u9999\u6e2f\uff09', antd: () => import(/* @vite-ignore */ 'ant-design-vue/es/locale/zh_HK'), local: () => import(/* @vite-ignore */ './locales/zh_hk.json') }, 'zh-tw': { - // 🇨🇳 - label: '\u7e41\u4f53\u4e2d\u6587\uff08\u4e2d\u56fd\u53f0\u6e7e\uff09', + // 🇨🇳 繁體中文(中國臺灣) + label: '\u7e41\u9ad4\u4e2d\u6587\uff08\u4e2d\u570b\u81fa\u7063\uff09', antd: () => import(/* @vite-ignore */ 'ant-design-vue/es/locale/zh_TW'), local: () => import(/* @vite-ignore */ './locales/zh_tw.json') }, diff --git a/web-vue/src/i18n/locales/en_us.json b/web-vue/src/i18n/locales/en_us.json index 92abbe350..67639f25e 100644 --- a/web-vue/src/i18n/locales/en_us.json +++ b/web-vue/src/i18n/locales/en_us.json @@ -1594,7 +1594,6 @@ "i18n_9014d6d289":"backup list", "i18n_90154854b6":"Please enter host", "i18n_901de97cdb":"Mode Request interface parameters are passed into the request body ContentType Please use: text/plain", - "i18n_9030cebe31":"After switching the language, the page will automatically refresh, and the already opened tab menu (tab) will be cleared together", "i18n_903b25f64e":"unknown state", "i18n_904615588b":"File type does not have console functionality", "i18n_9057ac9664":"Please select the trigger type", @@ -1623,6 +1622,7 @@ "i18n_92e3a830ae":"help", "i18n_92f0744426":"Container building refers to the use of docker containers to execute builds, which can be isolated from the host environment without installing a dependent environment", "i18n_92f3fdb65f":"Warehouse:", + "i18n_92f9a3c474":"The page will automatically refresh after switching languages", "i18n_9300692fac":"Markup Reference", "i18n_9302bc7838":"Please enter the port to check", "i18n_930882bb0a":"a", diff --git a/web-vue/src/i18n/locales/zh_cn.json b/web-vue/src/i18n/locales/zh_cn.json index c5877f06d..92d947116 100644 --- a/web-vue/src/i18n/locales/zh_cn.json +++ b/web-vue/src/i18n/locales/zh_cn.json @@ -1594,7 +1594,7 @@ "i18n_9014d6d289": "备份列表", "i18n_90154854b6": "请输入host", "i18n_901de97cdb": "方式请求接口参数传入到请求体 ContentType 请使用:text/plain", - "i18n_9030cebe31": "切换语言后页面将自动刷新,已经打开的标签菜单(选项卡)将一并清空", + "i18n_903b25f64e": "未知状态", "i18n_904615588b": "文件类型没有控制台功能", "i18n_9057ac9664": "请选择触发类型", @@ -1623,6 +1623,7 @@ "i18n_92e3a830ae": "帮助", "i18n_92f0744426": "容器构建是指使用 docker 容器执行构建,这样可以达到和宿主机环境隔离不用安装依赖环境", "i18n_92f3fdb65f": "仓库:", + "i18n_92f9a3c474": "切换语言后页面将自动刷新", "i18n_9300692fac": "标记引用", "i18n_9302bc7838": "请输入要检查的端口", "i18n_930882bb0a": "个", diff --git a/web-vue/src/i18n/locales/zh_hk.json b/web-vue/src/i18n/locales/zh_hk.json index a7f376490..abfcf5cab 100644 --- a/web-vue/src/i18n/locales/zh_hk.json +++ b/web-vue/src/i18n/locales/zh_hk.json @@ -1594,7 +1594,6 @@ "i18n_9014d6d289":"備份列表", "i18n_90154854b6":"請輸入host", "i18n_901de97cdb":"方式請求接口參數傳入到請求體 ContentType 請使用:text/plain", - "i18n_9030cebe31":"切換語言後頁面將自動刷新,已經打開的標籤菜單(選項卡)將一併清空", "i18n_903b25f64e":"未知狀態", "i18n_904615588b":"文件類型沒有控制枱功能", "i18n_9057ac9664":"請選擇觸發類型", @@ -1623,6 +1622,7 @@ "i18n_92e3a830ae":"幫助", "i18n_92f0744426":"容器構建是指使用 docker 容器執行構建,這樣可以達到和宿主機環境隔離不用安裝依賴環境", "i18n_92f3fdb65f":"倉庫:", + "i18n_92f9a3c474":"切換語言後頁面將自動刷新", "i18n_9300692fac":"標記引用", "i18n_9302bc7838":"請輸入要檢查的端口", "i18n_930882bb0a":"個", diff --git a/web-vue/src/i18n/locales/zh_tw.json b/web-vue/src/i18n/locales/zh_tw.json index 6903d6dbd..32cecd5fd 100644 --- a/web-vue/src/i18n/locales/zh_tw.json +++ b/web-vue/src/i18n/locales/zh_tw.json @@ -1594,7 +1594,6 @@ "i18n_9014d6d289":"備份列表", "i18n_90154854b6":"請輸入host", "i18n_901de97cdb":"方式請求介面引數傳入到請求體 ContentType 請使用:text/plain", - "i18n_9030cebe31":"切換語言後頁面將自動重新整理,已經開啟的標籤選單(選項卡)將一併清空", "i18n_903b25f64e":"未知狀態", "i18n_904615588b":"檔案型別沒有控制檯功能", "i18n_9057ac9664":"請選擇觸發型別", @@ -1623,6 +1622,7 @@ "i18n_92e3a830ae":"幫助", "i18n_92f0744426":"容器構建是指使用 docker 容器執行構建,這樣可以達到和宿主機環境隔離不用安裝依賴環境", "i18n_92f3fdb65f":"倉庫:", + "i18n_92f9a3c474":"切換語言後頁面將自動重新整理", "i18n_9300692fac":"標記引用", "i18n_9302bc7838":"請輸入要檢查的埠", "i18n_930882bb0a":"個", diff --git a/web-vue/src/main.ts b/web-vue/src/main.ts index e7ceffcb3..918c358df 100644 --- a/web-vue/src/main.ts +++ b/web-vue/src/main.ts @@ -13,7 +13,6 @@ import '@/assets/reset.less' import App from './App.vue' import router from './router' import '@/router/auth' -import CustomModal from '@/components/customModal/index.vue' import i18n from './i18n' import { changeLang, defaultLocale } from './i18n' @@ -27,9 +26,6 @@ changeLang(defaultLocale).then(() => { app.use(pinia) app.use(i18n) - // 增加弹窗全局引入 - app.component('CustomModal', CustomModal) - app.mount('#app') }) //console.log('app done', new Date().getTime()) diff --git a/web-vue/src/pages/layout/user-header.vue b/web-vue/src/pages/layout/user-header.vue index c5a655b18..dfc595431 100644 --- a/web-vue/src/pages/layout/user-header.vue +++ b/web-vue/src/pages/layout/user-header.vue @@ -456,7 +456,7 @@ /> - + {{ diff --git a/web-vue/src/stores/app.ts b/web-vue/src/stores/app.ts index 0b647b816..b3798df73 100644 --- a/web-vue/src/stores/app.ts +++ b/web-vue/src/stores/app.ts @@ -16,6 +16,7 @@ import { getHashQuery } from '@/utils/utils' import { RouteLocationNormalized } from 'vue-router' import { executionRequest } from '@/api/external' import { parseTime, pageBuildInfo } from '@/utils/const' +import { useGuideStore } from '@/stores/guide' export const useAppStore = defineStore('app', { state: () => ({ @@ -50,7 +51,11 @@ export const useAppStore = defineStore('app', { this.isShowInfo = true // 控制台输出版本号信息 const buildInfo = pageBuildInfo() - executionRequest('https://jpom.top/docs/versions.show', { ...buildInfo, p: to.path }) + executionRequest('https://jpom.top/docs/versions.show', { + ...buildInfo, + p: to.path, + l: useGuideStore().getLocale() + }) .then((data) => { console.log( '\n %c ' + parseTime(buildInfo.t) + ' %c vs %c ' + buildInfo.v + ' %c vs %c ' + data, diff --git a/web-vue/src/stores/guide.ts b/web-vue/src/stores/guide.ts index 18195fc22..f28dbd71f 100644 --- a/web-vue/src/stores/guide.ts +++ b/web-vue/src/stores/guide.ts @@ -8,7 +8,7 @@ /// See the Mulan PSL v2 for more details. /// import { t, defaultLocale, normalLang } from '@/i18n' -import { useAllMenuStore } from './menu2' + /** * 引导相关 store * @@ -144,11 +144,6 @@ export const useGuideStore = defineStore('guide', { cache.locale = locale || 'zh-cn' this.setGuideCache(cache) // - //清空本地 tabs - const menuStore = useAllMenuStore() - // 调用其他 action - menuStore.clearTabs('normal', { key: 'all' }) - menuStore.clearTabs('management', { key: 'all' }) location.reload() } }, diff --git a/web-vue/src/stores/menu2.ts b/web-vue/src/stores/menu2.ts index 551a912fd..fe65f3dd5 100644 --- a/web-vue/src/stores/menu2.ts +++ b/web-vue/src/stores/menu2.ts @@ -1,3 +1,4 @@ +import { path } from 'node:path' /// /// Copyright (c) 2019 Of Him Code Technology Studio /// Jpom is licensed under Mulan PSL v2. @@ -13,6 +14,7 @@ import { MANAGEMENT_ACTIVE_TAB_KEY, MANAGEMENT_TAB_LIST_KEY, MANAGEMENT_ACTIVE_M import { getMenu, getSystemMenu } from '@/api/menu' import routeMenuMap from '@/router/route-menu' +import { title } from 'process' const api: any = { normal: getMenu, @@ -123,18 +125,37 @@ export const useAllMenuStore = defineStore('menu2', { }) let tabList = this[mode + '_tabList'] || [] // 过滤已经不能显示的菜单 - tabList = tabList.filter((item: any) => { - return ( - menus.filter((menu: any) => { - return ( - menu.path == item.path || - menu.childs?.filter((subMenu: any) => { + tabList = tabList + .map((item: any) => { + const newTitle = menus + .map((menu: any) => { + // console.log(menu) + if (menu.path == item.path) { + return menu.title + } + const findSub = menu.childs?.find((subMenu: any) => { return subMenu.path === item.path - }).length > 0 - ) - }).length > 0 - ) - }) + }) + if (findSub) { + return findSub.title + } + }) + .find((title: any) => title) + + return { ...item, title: newTitle } + }) + .filter((item: any) => { + return ( + menus.filter((menu: any) => { + return ( + menu.path == item.path || + menu.childs?.filter((subMenu: any) => { + return subMenu.path === item.path + }).length > 0 + ) + }).length > 0 + ) + }) this.setTabList(mode, tabList) if (!currentMenu) { diff --git a/web-vue/src/utils/const.ts b/web-vue/src/utils/const.ts index e4182af7a..bf9a2f32e 100644 --- a/web-vue/src/utils/const.ts +++ b/web-vue/src/utils/const.ts @@ -429,9 +429,9 @@ export function compareVersion(version1: string, version2: string) { // 当前页面构建信息 export function pageBuildInfo() { - const htmlVersion = document.head.querySelector('[name~=jpom-version][content]')?.content - const buildTime = document.head.querySelector('[name~=build-time][content]')?.content - const buildEnv = document.head.querySelector('[name~=build-env][content]')?.content + const htmlVersion = (document.head.querySelector('[name~=jpom-version][content]') as any)?.content + const buildTime = (document.head.querySelector('[name~=build-time][content]') as any)?.content + const buildEnv = (document.head.querySelector('[name~=build-env][content]') as any)?.content return { v: htmlVersion, t: buildTime,