Skip to content

Commit

Permalink
feat: adapt savor theme
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Apr 22, 2024
1 parent 9fdfe20 commit 417659c
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ const formData = reactive({
value: "Zhihu",
label: "Zhihu",
},
{
value: "Savor",
label: "写未",
},
],
dark: [
{
Expand All @@ -63,10 +67,20 @@ const formData = reactive({
value: "Zhihu",
label: "Zhihu",
},
{
value: "Savor",
label: "写未",
},
],
},
lightTheme: setting?.theme?.lightTheme ?? "Zhihu",
darkTheme: setting?.theme?.darkTheme ?? "Zhihu",
versionMap: {
midlight: "3.0.10",
daylight: "3.0.10",
Zhihu: "0.1.1",
Savor: "3.9.2",
} as any,
})

// methods
Expand All @@ -77,6 +91,7 @@ const onSubmit = async () => {
setting.theme ||= {}
setting.theme.lightTheme = formData.lightTheme
setting.theme.darkTheme = formData.darkTheme
setting.theme.themeVersion = formData.versionMap[toRaw(setting.theme.lightTheme)] ?? "0.1.1"
await updateSetting(setting)
ElMessage.success(t("main.opt.success"))
} catch (e) {
Expand Down
File renamed without changes.
File renamed without changes.
9 changes: 5 additions & 4 deletions composables/useStaticThemeMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import { BrowserUtil } from "zhi-device"
import { createAppLogger } from "~/common/appLogger"
import { CONSTANTS } from "~/utils/constants"
import { useRoute } from "vue-router"

// 创建日志记录器
const logger = createAppLogger("use-theme-mode")
Expand All @@ -37,7 +38,7 @@ export const useStaticThemeMode = async () => {
// 获取颜色模式和运行时配置
const color = useColorMode()
// const env = useRuntimeConfig()

const { query } = useRoute()
const appBase = process.env.APP_BASE

// computes
Expand All @@ -64,9 +65,9 @@ export const useStaticThemeMode = async () => {

const siyuanV = CONSTANTS.SIYUAN_VERSION
const hljsV = CONSTANTS.HLJS_VERSION
const siyuanLightTheme = "Zhihu" as string
const siyuanDarkTheme = "Zhihu" as string
const siyuanThemeV = "0.1.1"
const siyuanLightTheme = (query.lightTheme ?? "Zhihu") as string
const siyuanDarkTheme = (query.darkTheme ?? "Zhihu") as string
const siyuanThemeV = (query.themeVersion ?? "0.1.1") as string
const detectedMode = color.preference
const isDarkMode = detectedMode === "dark"
useHead({
Expand Down
1 change: 1 addition & 0 deletions locales/en_US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export default {
"siyuan.theme": "Theme",
"siyuan.theme.light": "Light theme",
"siyuan.theme.dark": "Dark theme",
"siyuan.theme.version": "Theme version",
"siyuan.theme.select": "Select theme",
"share.to.web": "Share to web",
"share.to.web.before.tip": "Publish and share link to everyone",
Expand Down
1 change: 1 addition & 0 deletions locales/zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default {
"theme.mode.choose": "切换模式",
"theme.mode.dark": "暗黑模式",
"theme.mode.light": "浅色模式",
"siyuan.theme.version": "主题版本",
"setting.conf.export": "导出配置",
"setting.conf.import": "导入配置",
"setting.conf.clear": "清空配置",
Expand Down
6 changes: 3 additions & 3 deletions pages/setting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ definePageMeta({
<div class="setting-body">
<el-tabs tab-position="left">
<el-tab-pane :label="t('setting.basic')">
<default-setting-basic />
<setting-basic />
</el-tab-pane>
<el-tab-pane :label="t('setting.preference')">
<default-setting-preference />
<setting-preference />
</el-tab-pane>
<el-tab-pane :label="t('setting.system')">
<default-setting-change-local />
<setting-change-local />
</el-tab-pane>
</el-tabs>

Expand Down

0 comments on commit 417659c

Please sign in to comment.