Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 增加配置侧边栏深色模式 #657

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/config/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ export default {
isUseTabsRouter: false,
showHeader: true,
brandTheme: '#0052D9',
sideIsDark: 'light',
};
2 changes: 1 addition & 1 deletion src/layouts/components/LayoutSideNav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
:layout="settingStore.layout"
:is-fixed="settingStore.isSidebarFixed"
:menu="sideMenu"
:theme="settingStore.displayMode"
:theme="settingStore.displaySideMode"
timi137137 marked this conversation as resolved.
Show resolved Hide resolved
:is-compact="settingStore.isSidebarCompact"
/>
</template>
Expand Down
12 changes: 11 additions & 1 deletion src/layouts/components/SideNav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,14 @@ const getLogo = () => {
};
</script>

<style lang="less" scoped></style>
<style lang="less" scoped>
.t-menu--dark {
.@{starter-prefix} {
&-side-nav-logo {
&-tdesign-logo {
color: white;
timi137137 marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
}
</style>
3 changes: 3 additions & 0 deletions src/layouts/setting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
</div>
</t-radio-group>

<t-form-item :label="$t('layout.setting.sideIsDark')" name="sideIsDark">
<t-switch v-model="formData.sideIsDark" :custom-value="['dark', 'light']" />
</t-form-item>
<t-form-item v-show="formData.layout === 'mix'" label="分割菜单(混合模式下有效)" name="splitMenu">
<t-switch v-model="formData.splitMenu" />
</t-form-item>
Expand Down
1 change: 1 addition & 0 deletions src/locales/lang/en_US/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default {
auto: 'Follow System',
},
},
sideIsDark: 'Side Menu Is Dark',
navigationLayout: 'Navigation Layout',
splitMenu: 'Split Menu(Only Mix mode)',
fixedSidebar: 'Fixed Sidebar',
Expand Down
1 change: 1 addition & 0 deletions src/locales/lang/zh_CN/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default {
auto: '跟随系统',
},
},
sideIsDark: '侧边栏深色',
navigationLayout: '导航布局',
splitMenu: '分割菜单(混合模式下有效)',
fixedSidebar: '固定侧边栏',
Expand Down
9 changes: 9 additions & 0 deletions src/store/modules/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ export const useSettingStore = defineStore('setting', {
}
return state.mode as 'dark' | 'light';
},
displaySideMode: (state): 'dark' | 'light' => {
return state.sideIsDark as 'dark' | 'light';
},
},
actions: {
async changeMode(mode: 'dark' | 'light' | 'auto') {
Expand Down Expand Up @@ -71,6 +74,9 @@ export const useSettingStore = defineStore('setting', {
insertThemeStylesheet(brandTheme, colorMap, mode as 'light' | 'dark');
document.documentElement.setAttribute('theme-color', brandTheme);
},
changeSideTheme(sideTheme: string) {
this.sideIsDark = sideTheme;
},
updateConfig(payload: Partial<TState>) {
for (const key in payload) {
if (payload[key as TStateKey] !== undefined) {
Expand All @@ -82,6 +88,9 @@ export const useSettingStore = defineStore('setting', {
if (key === 'brandTheme') {
this.changeBrandTheme(payload[key]);
}
if (key === 'sideIsDark') {
this.changeSideTheme(payload[key]);
}
}
},
},
Expand Down
Loading