From 5a8d6db43eb3ef431c55d7b9ae0304dfc3e91bb0 Mon Sep 17 00:00:00 2001 From: Langel Date: Mon, 15 Apr 2024 15:10:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E6=A0=87=E7=AD=BE=E9=A1=B5=E5=8A=9F=E8=83=BD=20(#3267)=20(#451?= =?UTF-8?q?0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/dto/setting.go | 1 + backend/init/migration/migrate.go | 1 + backend/init/migration/migrations/v_1_10.go | 10 ++ frontend/src/api/interface/setting.ts | 1 + frontend/src/lang/modules/en.ts | 4 + frontend/src/lang/modules/tw.ts | 4 + frontend/src/lang/modules/zh.ts | 4 + frontend/src/layout/components/AppMain.vue | 11 +- .../src/layout/components/Sidebar/index.vue | 17 ++- .../components/Tabs/components/TabItem.vue | 97 ++++++++++++ frontend/src/layout/components/Tabs/index.vue | 83 ++++++++++ frontend/src/layout/components/index.ts | 1 + frontend/src/layout/index.vue | 26 +++- frontend/src/store/index.ts | 3 +- frontend/src/store/interface/index.ts | 1 + frontend/src/store/modules/global.ts | 4 + frontend/src/store/modules/tabs.ts | 142 ++++++++++++++++++ frontend/src/views/log/operation/index.vue | 3 + .../src/views/login/components/login-form.vue | 5 +- frontend/src/views/setting/panel/index.vue | 16 ++ 20 files changed, 423 insertions(+), 11 deletions(-) create mode 100644 frontend/src/layout/components/Tabs/components/TabItem.vue create mode 100644 frontend/src/layout/components/Tabs/index.vue create mode 100644 frontend/src/store/modules/tabs.ts diff --git a/backend/app/dto/setting.go b/backend/app/dto/setting.go index 9788bc7aa..13dc156f9 100644 --- a/backend/app/dto/setting.go +++ b/backend/app/dto/setting.go @@ -19,6 +19,7 @@ type SettingInfo struct { BindAddress string `json:"bindAddress"` PanelName string `json:"panelName"` Theme string `json:"theme"` + MenuTabs string `json:"menuTabs"` Language string `json:"language"` DefaultNetwork string `json:"defaultNetwork"` LastCleanTime string `json:"lastCleanTime"` diff --git a/backend/init/migration/migrate.go b/backend/init/migration/migrate.go index 0850ec7e8..3858dd631 100644 --- a/backend/init/migration/migrate.go +++ b/backend/init/migration/migrate.go @@ -80,6 +80,7 @@ func Init() { migrations.NewMonitorDB, migrations.AddNoAuthSetting, migrations.UpdateXpackHideMenu, + migrations.AddMenuTabsSetting, }) if err := m.Migrate(); err != nil { global.LOG.Error(err) diff --git a/backend/init/migration/migrations/v_1_10.go b/backend/init/migration/migrations/v_1_10.go index d7ae96cf9..0687c288f 100644 --- a/backend/init/migration/migrations/v_1_10.go +++ b/backend/init/migration/migrations/v_1_10.go @@ -128,3 +128,13 @@ var UpdateXpackHideMenu = &gormigrate.Migration{ return nil }, } + +var AddMenuTabsSetting = &gormigrate.Migration{ + ID: "20240415-add-menu-tabs-setting", + Migrate: func(tx *gorm.DB) error { + if err := tx.Create(&model.Setting{Key: "MenuTabs", Value: "disable"}).Error; err != nil { + return err + } + return nil + }, +} diff --git a/frontend/src/api/interface/setting.ts b/frontend/src/api/interface/setting.ts index 6e101e79f..6afd77c29 100644 --- a/frontend/src/api/interface/setting.ts +++ b/frontend/src/api/interface/setting.ts @@ -16,6 +16,7 @@ export namespace Setting { panelName: string; theme: string; + menuTabs: string; language: string; defaultNetwork: string; lastCleanTime: string; diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 7e3eb5296..9c05257a1 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -352,6 +352,9 @@ const message = { tabs: { more: 'More', hide: 'Hide', + close: 'Close', + closeLeft: 'Close left', + closeRight: 'Close right', closeCurrent: 'Close current', closeOther: 'Close other', closeAll: 'Close All', @@ -1228,6 +1231,7 @@ const message = { portChange: 'Port change', portChangeHelper: 'Modify the service port and restart the service. Do you want to continue?', theme: 'Theme', + menuTabs: 'Menu tabs', dark: 'Dark', light: 'Light', auto: 'Follow System', diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index 867eae81c..88f449ca3 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -348,6 +348,9 @@ const message = { tabs: { more: '更多', hide: '收起', + close: '關閉', + closeLeft: '關閉左側', + closeRight: '關閉右側', closeCurrent: '關閉當前', closeOther: '關閉其它', closeAll: '關閉所有', @@ -1165,6 +1168,7 @@ const message = { portChange: '端口修改', portChangeHelper: '服務端口修改需要重啟服務,是否繼續?', theme: '主題顏色', + menuTabs: '菜單標簽頁', componentSize: '組件大小', dark: '暗色', light: '亮色', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 2bd32afc4..cd1f4c762 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -348,6 +348,9 @@ const message = { tabs: { more: '更多', hide: '收起', + close: '关闭', + closeLeft: '关闭左侧', + closeRight: '关闭右侧', closeCurrent: '关闭当前', closeOther: '关闭其它', closeAll: '关闭所有', @@ -1166,6 +1169,7 @@ const message = { portChange: '端口修改', portChangeHelper: '服务端口修改需要重启服务,是否继续?', theme: '主题颜色', + menuTabs: '菜单标签页', componentSize: '组件大小', dark: '暗色', light: '亮色', diff --git a/frontend/src/layout/components/AppMain.vue b/frontend/src/layout/components/AppMain.vue index d9e3d79c7..c00a0ede4 100644 --- a/frontend/src/layout/components/AppMain.vue +++ b/frontend/src/layout/components/AppMain.vue @@ -1,7 +1,7 @@ + + diff --git a/frontend/src/layout/components/Tabs/index.vue b/frontend/src/layout/components/Tabs/index.vue new file mode 100644 index 000000000..18ddc5578 --- /dev/null +++ b/frontend/src/layout/components/Tabs/index.vue @@ -0,0 +1,83 @@ + + + + + diff --git a/frontend/src/layout/components/index.ts b/frontend/src/layout/components/index.ts index a4bb820e9..d3a36e64b 100644 --- a/frontend/src/layout/components/index.ts +++ b/frontend/src/layout/components/index.ts @@ -2,3 +2,4 @@ export { default as Sidebar } from './Sidebar/index.vue'; export { default as Footer } from './AppFooter.vue'; export { default as AppMain } from './AppMain.vue'; export { default as MobileHeader } from './MobileHeader.vue'; +export { default as Tabs } from '@/layout/components/Tabs/index.vue'; diff --git a/frontend/src/layout/index.vue b/frontend/src/layout/index.vue index 7da0b7c79..1991ee4b9 100644 --- a/frontend/src/layout/index.vue +++ b/frontend/src/layout/index.vue @@ -2,13 +2,13 @@
- +
- - + +
@@ -16,17 +16,21 @@