Skip to content

Commit a07d016

Browse files
authored
fix: Fix menu tab display issues (1Panel-dev#9838)
1 parent 9d343a9 commit a07d016

File tree

65 files changed

+326
-238
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+326
-238
lines changed

frontend/src/components/back-button/index.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
</template>
88

99
<script setup lang="ts">
10+
import { routerToName, routerToPath } from '@/utils/router';
1011
import { inject, useSlots } from 'vue';
1112
import { useRouter } from 'vue-router';
1213
@@ -25,10 +26,10 @@ function jump() {
2526
reloadPage();
2627
}
2728
if (path) {
28-
router.push(path);
29+
routerToPath(path);
2930
}
3031
if (name) {
31-
router.push({ name: name });
32+
routerToName(name);
3233
}
3334
if (to) {
3435
router.push(to);

frontend/src/components/backup/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ import {
131131
} from '@/api/modules/backup';
132132
import i18n from '@/lang';
133133
import { Backup } from '@/api/interface/backup';
134-
import router from '@/routers';
135134
import { MsgSuccess } from '@/utils/message';
136135
import TaskLog from '@/components/log/task/index.vue';
137136
import { GlobalStore } from '@/store';
137+
import { routerToFileWithPath } from '@/utils/router';
138138
const globalStore = GlobalStore();
139139
140140
const selects = ref<any>([]);
@@ -194,7 +194,7 @@ const loadBackupDir = async () => {
194194
};
195195
196196
const goFile = async () => {
197-
router.push({ name: 'File', query: { path: `${backupPath.value}/app/${name.value}/${detailName.value}` } });
197+
routerToFileWithPath(`${backupPath.value}/app/${name.value}/${detailName.value}`);
198198
};
199199
200200
const onChange = async (info: any) => {

frontend/src/components/layout-content/no-such-service.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
</template>
2121

2222
<script lang="ts" setup>
23-
import router from '@/routers';
23+
import { routerToNameWithQuery } from '@/utils/router';
2424
2525
const prop = defineProps({
2626
name: String,
2727
});
2828
2929
const toDoc = () => {
30-
router.push({ name: 'Library', query: { uncached: 'true' } });
30+
routerToNameWithQuery('Library', { uncached: 'true' });
3131
};
3232
</script>

frontend/src/components/router-button/index.vue

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
</template>
2424

2525
<script lang="ts" setup>
26+
import { routerToName, routerToPath } from '@/utils/router';
2627
import { computed, onMounted, ref } from 'vue';
2728
import { useRouter } from 'vue-router';
2829
@@ -41,12 +42,6 @@ const buttonArray = computed(() => {
4142
4243
const router = useRouter();
4344
const activeName = ref('');
44-
const routerToPath = (path: string) => {
45-
router.push({ path: path });
46-
};
47-
const routerToName = (name: string) => {
48-
router.push({ name: name });
49-
};
5045
5146
const handleChange = (label: string) => {
5247
const btn = buttonArray.value.find((btn) => btn.label === label);

frontend/src/global/business.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

frontend/src/lang/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import tr from './modules/tr';
1111

1212
const i18n = createI18n({
1313
legacy: false,
14+
missingWarn: false,
1415
locale: localStorage.getItem('lang') || 'en',
1516
fallbackLocale: 'en',
1617
globalInjection: true,

frontend/src/layout/components/Sidebar/components/Collapse.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ import bus from '@/global/bus';
8888
import { logOutApi } from '@/api/modules/auth';
8989
import router from '@/routers';
9090
import { loadProductProFromDB } from '@/utils/xpack';
91+
import { routerToNameWithQuery } from '@/utils/router';
9192
9293
const filter = ref();
9394
const globalStore = GlobalStore();
@@ -178,7 +179,7 @@ const changeNode = (command: string) => {
178179
globalStore.currentNode = command || 'local';
179180
globalStore.currentNodeAddr = '';
180181
loadProductProFromDB();
181-
router.push({ name: 'home', query: { t: Date.now() } });
182+
routerToNameWithQuery('home', { t: Date.now() });
182183
return;
183184
}
184185
for (const item of nodes.value) {
@@ -198,7 +199,7 @@ const changeNode = (command: string) => {
198199
globalStore.currentNode = command || 'local';
199200
globalStore.currentNodeAddr = item.addr;
200201
loadProductProFromDB();
201-
router.push({ name: 'home', query: { t: Date.now() } });
202+
routerToNameWithQuery('home', { t: Date.now() });
202203
}
203204
}
204205
};

frontend/src/layout/components/Sidebar/components/Logo.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
</template>
2525

2626
<script setup lang="ts">
27-
import router from '@/routers';
2827
import { GlobalStore } from '@/store';
2928
import PrimaryLogo from '@/assets/images/1panel-logo.svg?component';
3029
import MenuLogo from '@/assets/images/1panel-menu-logo.svg?component';
3130
import { ref } from 'vue';
31+
import { routerToNameWithQuery } from '@/utils/router';
3232
3333
defineProps<{ isCollapse: boolean }>();
3434
@@ -37,7 +37,7 @@ const logoWithTextLoadFailed = ref(false);
3737
const globalStore = GlobalStore();
3838
3939
const goHome = () => {
40-
router.push({ name: 'home' });
40+
routerToNameWithQuery('home', { t: Date.now() });
4141
};
4242
</script>
4343

frontend/src/layout/components/Tabs/components/TabItem.vue

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@
99
@visible-change="$emit('dropdownVisibleChange', $event, tabItem.path)"
1010
>
1111
<span class="custom-tabs-label">
12-
<el-icon v-if="tabsStore.isShowTabIcon && menuIcon">
13-
<el-icon>
14-
<SvgIcon :iconName="menuIcon" />
15-
</el-icon>
16-
</el-icon>
1712
<span>{{ menuName }}</span>
1813
</span>
1914
<template #dropdown>
@@ -56,11 +51,9 @@
5651
<script setup lang="ts">
5752
import { computed, ref } from 'vue';
5853
import { TabsStore } from '@/store';
59-
import { useI18n } from 'vue-i18n';
54+
import i18n from '@/lang';
6055
import { Close, DArrowLeft, DArrowRight, More } from '@element-plus/icons-vue';
61-
import SvgIcon from '@/components/svg-icon/svg-icon.vue';
6256
63-
const i18n = useI18n();
6457
const tabsStore = TabsStore();
6558
6659
const props = defineProps({
@@ -73,12 +66,18 @@ const props = defineProps({
7366
defineEmits(['closeTab', 'closeOtherTabs', 'closeTabs', 'dropdownVisibleChange']);
7467
7568
const menuName = computed(() => {
76-
return i18n.t(props.tabItem.meta.title);
69+
let title;
70+
if (props.tabItem.meta.parent) {
71+
title = i18n.global.t(props.tabItem.meta.parent) + '-' + i18n.global.t(props.tabItem.meta.title);
72+
} else {
73+
title = i18n.global.t(props.tabItem.meta.title);
74+
}
75+
if (props.tabItem.meta.detail) {
76+
title = title + '-' + i18n.global.t(props.tabItem.meta.detail);
77+
}
78+
return title;
7779
});
7880
79-
const menuIcon = computed(() => {
80-
return props.tabItem.meta.icon;
81-
});
8281
const dropdownRef = ref();
8382
8483
defineExpose({
@@ -87,9 +86,6 @@ defineExpose({
8786
</script>
8887

8988
<style scoped>
90-
.common-tabs .custom-tabs-label .el-icon {
91-
vertical-align: middle;
92-
}
9389
.common-tabs .custom-tabs-label span {
9490
vertical-align: middle;
9591
margin-left: 4px;

frontend/src/routers/modules/app-store.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ const appStoreRouter = {
2727
meta: {
2828
activeMenu: '/apps',
2929
requiresAuth: false,
30+
parent: 'menu.app',
31+
title: 'app.all',
3032
},
3133
},
3234
{
@@ -38,6 +40,8 @@ const appStoreRouter = {
3840
meta: {
3941
activeMenu: '/apps',
4042
requiresAuth: false,
43+
parent: 'menu.app',
44+
title: 'app.installed',
4145
},
4246
},
4347
{
@@ -49,6 +53,8 @@ const appStoreRouter = {
4953
meta: {
5054
activeMenu: '/apps',
5155
requiresAuth: false,
56+
parent: 'menu.app',
57+
title: 'app.canUpgrade',
5258
},
5359
},
5460
{
@@ -60,6 +66,8 @@ const appStoreRouter = {
6066
meta: {
6167
activeMenu: '/apps',
6268
requiresAuth: false,
69+
parent: 'menu.app',
70+
title: 'commons.button.set',
6371
},
6472
},
6573
],

0 commit comments

Comments
 (0)