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 417659c commit 4a75ec7
Show file tree
Hide file tree
Showing 33 changed files with 6,700 additions and 3 deletions.
12 changes: 9 additions & 3 deletions composables/useStaticThemeMode.ts
Expand Up @@ -27,6 +27,9 @@ import { BrowserUtil } from "zhi-device"
import { createAppLogger } from "~/common/appLogger"
import { CONSTANTS } from "~/utils/constants"
import { useRoute } from "vue-router"
import { useAuthModeFetch } from "~/composables/useAuthModeFetch"
import { JsonUtil } from "zhi-common"
import AppConfig from "~/app.config"

// 创建日志记录器
const logger = createAppLogger("use-theme-mode")
Expand All @@ -39,6 +42,7 @@ export const useStaticThemeMode = async () => {
const color = useColorMode()
// const env = useRuntimeConfig()
const { query } = useRoute()
const { fetchPublicText } = useAuthModeFetch()
const appBase = process.env.APP_BASE

// computes
Expand All @@ -63,11 +67,13 @@ export const useStaticThemeMode = async () => {
// onMounted(() => {
// })

const resText = await fetchPublicText(`static.app.config.json`)
const setting = JsonUtil.safeParse<typeof AppConfig>(resText, {} as typeof AppConfig)
const siyuanV = CONSTANTS.SIYUAN_VERSION
const hljsV = CONSTANTS.HLJS_VERSION
const siyuanLightTheme = (query.lightTheme ?? "Zhihu") as string
const siyuanDarkTheme = (query.darkTheme ?? "Zhihu") as string
const siyuanThemeV = (query.themeVersion ?? "0.1.1") as string
const siyuanLightTheme = (query.lightTheme ?? setting.theme?.lightTheme ?? "Zhihu") as string
const siyuanDarkTheme = (query.darkTheme ?? setting.theme?.darkTheme ?? "Zhihu") as string
const siyuanThemeV = (query.themeVersion ?? setting.theme?.themeVersion ?? "0.1.1") as string
const detectedMode = color.preference
const isDarkMode = detectedMode === "dark"
useHead({
Expand Down
8 changes: 8 additions & 0 deletions plugins/09.domparser.static.client.ts
Expand Up @@ -58,6 +58,14 @@ export default defineNuxtPlugin(({ vueApp }) => {
`<symbol id="iconDot" viewBox="0 0 32 32">
<path d="M22.286 16c0 3.471-2.814 6.286-6.286 6.286s-6.286-2.814-6.286-6.286c0-3.471 2.814-6.286 6.286-6.286s6.286 2.814 6.286 6.286z"></path>
</symbol>`,
// 代码块复制按钮
`<symbol id="iconCopy" viewBox="0 0 32 32">
<path d="M22.545-0h-17.455c-1.6 0-2.909 1.309-2.909 2.909v20.364h2.909v-20.364h17.455v-2.909zM26.909 5.818h-16c-1.6 0-2.909 1.309-2.909 2.909v20.364c0 1.6 1.309 2.909 2.909 2.909h16c1.6 0 2.909-1.309 2.909-2.909v-20.364c0-1.6-1.309-2.909-2.909-2.909zM26.909 29.091h-16v-20.364h16v20.364z"></path>
</symbol>`,
// 代码块更多
`<symbol id="iconMore" viewBox="0 0 32 32">
<path d="M16 10.667c1.467 0 2.667-1.2 2.667-2.667s-1.2-2.667-2.667-2.667-2.667 1.2-2.667 2.667 1.2 2.667 2.667 2.667zM16 13.333c-1.467 0-2.667 1.2-2.667 2.667s1.2 2.667 2.667 2.667 2.667-1.2 2.667-2.667-1.2-2.667-2.667-2.667zM16 21.333c-1.467 0-2.667 1.2-2.667 2.667s1.2 2.667 2.667 2.667 2.667-1.2 2.667-2.667-1.2-2.667-2.667-2.667z"></path>
</symbol>`,
])

// block ref links
Expand Down

0 comments on commit 4a75ec7

Please sign in to comment.