Skip to content

Commit 09215ba

Browse files
committed
fix: add config tabs and routing for normal and system configurations
1 parent 4ff07e3 commit 09215ba

5 files changed

Lines changed: 62 additions & 28 deletions

File tree

dashboard/src/i18n/locales/en-US/core/navigation.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,9 @@
4040
"notFound": "Changelog for this version not found",
4141
"selectVersion": "Select Version",
4242
"current": "Current"
43+
},
44+
"configTabs": {
45+
"normal": "Normal Config",
46+
"system": "System Config"
4347
}
4448
}

dashboard/src/i18n/locales/zh-CN/core/navigation.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,9 @@
4040
"notFound": "未找到该版本的更新日志",
4141
"selectVersion": "选择版本",
4242
"current": "当前"
43+
},
44+
"configTabs": {
45+
"normal": "普通配置",
46+
"system": "系统配置"
4347
}
4448
}

dashboard/src/layouts/full/vertical-sidebar/sidebarItem.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,19 @@ const sidebarItem: menu[] = [
3636
{
3737
title: 'core.navigation.config',
3838
icon: 'mdi-cog',
39-
to: '/config',
39+
to: '/config#normal',
40+
children: [
41+
{
42+
title: 'core.navigation.configTabs.normal',
43+
icon: 'mdi-cog',
44+
to: '/config#normal'
45+
},
46+
{
47+
title: 'core.navigation.configTabs.system',
48+
icon: 'mdi-cog-outline',
49+
to: '/config#system'
50+
}
51+
]
4052
},
4153
{
4254
title: 'core.navigation.extension',

dashboard/src/router/MainRoutes.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ const MainRoutes = {
4141
path: '/config',
4242
component: () => import('@/views/ConfigPage.vue')
4343
},
44+
{
45+
path: '/normal',
46+
redirect: '/config#normal'
47+
},
48+
{
49+
path: '/system',
50+
redirect: '/config#system'
51+
},
4452
{
4553
name: 'Default',
4654
path: '/dashboard/default',

dashboard/src/views/ConfigPage.vue

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,17 @@
44
<div v-if="selectedConfigID || isSystemConfig" class="mt-4 config-panel"
55
style="display: flex; flex-direction: column; align-items: start;">
66

7-
<!-- 普通配置选择区域 -->
87
<div class="d-flex flex-row pr-4"
9-
style="margin-bottom: 16px; align-items: center; gap: 12px; justify-content: space-between; width: 100%;">
8+
style="margin-bottom: 16px; align-items: center; gap: 12px; width: 100%; justify-content: space-between;">
109
<div class="d-flex flex-row align-center" style="gap: 12px;">
1110
<v-select style="min-width: 130px;" v-model="selectedConfigID" :items="configSelectItems" item-title="name" :disabled="initialConfigId !== null"
1211
v-if="!isSystemConfig" item-value="id" :label="tm('configSelection.selectConfig')" hide-details density="compact" rounded="md"
1312
variant="outlined" @update:model-value="onConfigSelect">
1413
</v-select>
15-
<a style="color: inherit;" href="https://blog.astrbot.app/posts/what-is-changed-in-4.0.0/#%E5%A4%9A%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6" target="_blank"><v-btn icon="mdi-help-circle" size="small" variant="plain"></v-btn></a>
14+
<!-- <a style="color: inherit;" href="https://blog.astrbot.app/posts/what-is-changed-in-4.0.0/#%E5%A4%9A%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6" target="_blank"><v-btn icon="mdi-help-circle" size="small" variant="plain"></v-btn></a> -->
1615

1716
</div>
18-
19-
<v-btn-toggle v-model="configType" mandatory color="primary" variant="outlined" density="comfortable"
20-
rounded="md" @update:model-value="onConfigTypeToggle">
21-
<v-btn value="normal" prepend-icon="mdi-cog" size="large">
22-
{{ tm('configSelection.normalConfig') }}
23-
</v-btn>
24-
<v-btn value="system" prepend-icon="mdi-cog-outline" size="large">
25-
{{ tm('configSelection.systemConfig') }}
26-
</v-btn>
27-
</v-btn-toggle>
2817
</div>
29-
3018
<!-- <v-progress-linear v-if="!fetched" indeterminate color="primary"></v-progress-linear> -->
3119

3220
<v-slide-y-transition mode="out-in">
@@ -252,6 +240,9 @@ export default {
252240
config_data_str(val) {
253241
this.config_data_has_changed = true;
254242
},
243+
'$route.fullPath'(newVal) {
244+
this.syncConfigTypeFromHash(newVal);
245+
},
255246
initialConfigId(newVal) {
256247
if (!newVal) {
257248
return;
@@ -299,6 +290,12 @@ export default {
299290
}
300291
},
301292
mounted() {
293+
const hashConfigType = this.extractConfigTypeFromHash(
294+
this.$route?.fullPath || ''
295+
);
296+
this.configType = hashConfigType || 'normal';
297+
this.isSystemConfig = this.configType === 'system';
298+
302299
const targetConfigId = this.initialConfigId || 'default';
303300
this.getConfigInfoList(targetConfigId);
304301
// 初始化配置类型状态
@@ -323,6 +320,27 @@ export default {
323320
}
324321
},
325322
323+
},
324+
methods: {
325+
extractConfigTypeFromHash(hash) {
326+
const rawHash = String(hash || '');
327+
const lastHashIndex = rawHash.lastIndexOf('#');
328+
if (lastHashIndex === -1) {
329+
return null;
330+
}
331+
const cleanHash = rawHash.slice(lastHashIndex + 1);
332+
return cleanHash === 'system' || cleanHash === 'normal' ? cleanHash : null;
333+
},
334+
syncConfigTypeFromHash(hash) {
335+
const configType = this.extractConfigTypeFromHash(hash);
336+
if (!configType || configType === this.configType) {
337+
return false;
338+
}
339+
340+
this.configType = configType;
341+
this.onConfigTypeToggle();
342+
return true;
343+
},
326344
getConfigInfoList(abconf_id) {
327345
// 获取配置列表
328346
axios.get('/api/config/abconfs').then((res) => {
@@ -568,19 +586,7 @@ export default {
568586
// 保持向后兼容性,更新 configType
569587
this.configType = this.isSystemConfig ? 'system' : 'normal';
570588
571-
this.fetched = false; // 重置加载状态
572-
573-
if (this.isSystemConfig) {
574-
// 切换到系统配置
575-
this.getConfig();
576-
} else {
577-
// 切换回普通配置,如果有选中的配置文件则加载,否则加载default
578-
if (this.selectedConfigID) {
579-
this.getConfig(this.selectedConfigID);
580-
} else {
581-
this.getConfigInfoList("default");
582-
}
583-
}
589+
this.onConfigTypeToggle();
584590
},
585591
openTestChat() {
586592
if (!this.selectedConfigID) {

0 commit comments

Comments
 (0)