Skip to content

Commit

Permalink
refactor(projects): 代码优化
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuangdc committed May 10, 2022
1 parent 50d7ccd commit a1c7e10
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 28 deletions.
24 changes: 11 additions & 13 deletions src/layouts/common/GlobalContent/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@
class="h-full bg-[#f6f9f8] dark:bg-[#101014] transition duration-300 ease-in-out"
>
<router-view v-slot="{ Component, route }">
<div class="h-full">
<transition
:name="theme.pageAnimateMode"
mode="out-in"
:appear="true"
@before-leave="handleBeforeLeave"
@after-enter="handleAfterEnter"
>
<keep-alive :include="routeStore.cacheRoutes">
<component :is="Component" v-if="app.reloadFlag" :key="route.path" />
</keep-alive>
</transition>
</div>
<transition
:name="theme.pageAnimateMode"
mode="out-in"
:appear="true"
@before-leave="handleBeforeLeave"
@after-enter="handleAfterEnter"
>
<keep-alive :include="routeStore.cacheRoutes">
<component :is="Component" v-if="app.reloadFlag" :key="route.path" />
</keep-alive>
</transition>
</router-view>
</div>
</template>
Expand Down
20 changes: 9 additions & 11 deletions src/layouts/common/SettingDrawer/components/DarkMode/index.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
<template>
<n-divider title-placement="center">主题</n-divider>
<n-divider title-placement="center">主题模式</n-divider>
<n-space vertical size="large">
<setting-menu label="深色主题">
<div class="flex-center">
<n-switch :value="theme.darkMode" @update:value="theme.setDarkMode">
<template #checked>
<icon-mdi-white-balance-sunny class="text-14px text-primary" />
</template>
<template #unchecked>
<icon-mdi-moon-waning-crescent class="text-14px text-primary" />
</template>
</n-switch>
</div>
<n-switch :value="theme.darkMode" @update:value="theme.setDarkMode">
<template #checked>
<icon-mdi-white-balance-sunny class="text-14px text-primary" />
</template>
<template #unchecked>
<icon-mdi-moon-waning-crescent class="text-14px text-primary" />
</template>
</n-switch>
</setting-menu>
<setting-menu label="跟随系统">
<n-switch :value="theme.followSystemTheme" @update:value="theme.setFollowSystemTheme">
Expand Down
2 changes: 1 addition & 1 deletion src/settings/theme.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"followSystemTheme": true,
"darkMode": false,
"followSystemTheme": true,
"layout": {
"minWidth": 900,
"mode": "vertical",
Expand Down
2 changes: 1 addition & 1 deletion src/settings/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ const themeColorList = [
];

const defaultThemeSetting: Theme.Setting = {
followSystemTheme: true,
darkMode: false,
followSystemTheme: true,
layout: {
minWidth: 900,
mode: 'vertical',
Expand Down
4 changes: 2 additions & 2 deletions src/typings/system.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ declare namespace Service {
declare namespace Theme {
/** 主题配置 */
interface Setting {
/** 是否自动跟随系统主题 */
followSystemTheme: boolean;
/** 暗黑模式 */
darkMode: boolean;
/** 是否自动跟随系统主题 */
followSystemTheme: boolean;
/** 布局样式 */
layout: Layout;
/** 主题颜色 */
Expand Down

1 comment on commit a1c7e10

@vercel
Copy link

@vercel vercel bot commented on a1c7e10 May 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.