feat: mv profile to footer
This commit is contained in:
@@ -8,4 +8,6 @@ export interface UserSettings extends Model<DataType.UserSettings> {
|
||||
fontSize?: string
|
||||
chosenFontSize?: string
|
||||
backlink?: boolean
|
||||
chosenTitleFont?: string
|
||||
chosenBodyFont?: string
|
||||
}
|
||||
|
||||
@@ -104,7 +104,16 @@ export const getUserSettingsContent = async (
|
||||
return null
|
||||
}
|
||||
|
||||
return JSON.parse(atob(content)) as UserSettings
|
||||
const raw = JSON.parse(atob(content)) as UserSettings & {
|
||||
t?: string
|
||||
p?: string
|
||||
}
|
||||
const { t, p, ...rest } = raw
|
||||
return {
|
||||
...rest,
|
||||
chosenTitleFont: t,
|
||||
chosenBodyFont: p
|
||||
}
|
||||
}
|
||||
|
||||
export const queryFileContent = async (
|
||||
|
||||
@@ -81,6 +81,14 @@ export const useUserRepoStore = defineStore("USER_REPO_STATE", {
|
||||
: userSettings?.fontFamily
|
||||
const chosenFontSize =
|
||||
this.userSettings?.chosenFontSize ?? userSettings?.fontSize
|
||||
const chosenTitleFont =
|
||||
this.userSettings?.chosenTitleFont ??
|
||||
userSettings?.chosenTitleFont ??
|
||||
chosenFontFamily
|
||||
const chosenBodyFont =
|
||||
this.userSettings?.chosenBodyFont ??
|
||||
userSettings?.chosenBodyFont ??
|
||||
chosenFontFamily
|
||||
this.userSettings = userSettings
|
||||
|
||||
if (!this.userSettings) {
|
||||
@@ -91,6 +99,8 @@ export const useUserRepoStore = defineStore("USER_REPO_STATE", {
|
||||
chosenFontFamily ?? this.userSettings.fontFamily
|
||||
this.userSettings.chosenFontSize =
|
||||
chosenFontSize ?? this.userSettings.fontSize
|
||||
this.userSettings.chosenTitleFont = chosenTitleFont
|
||||
this.userSettings.chosenBodyFont = chosenBodyFont
|
||||
|
||||
data.update<DataType.UserSettings, UserSettings>({
|
||||
...this.userSettings,
|
||||
@@ -156,6 +166,30 @@ export const useUserRepoStore = defineStore("USER_REPO_STATE", {
|
||||
}
|
||||
this.userSettings.chosenFontSize = fontSize
|
||||
|
||||
const userSettingsId = `UserSetting-${this.user}-${this.repo}`
|
||||
data.update<DataType.UserSettings, UserSettings>({
|
||||
...this.userSettings,
|
||||
_id: userSettingsId
|
||||
})
|
||||
},
|
||||
setTitleFont(font: string) {
|
||||
if (!this.userSettings) {
|
||||
return
|
||||
}
|
||||
this.userSettings.chosenTitleFont = font
|
||||
|
||||
const userSettingsId = `UserSetting-${this.user}-${this.repo}`
|
||||
data.update<DataType.UserSettings, UserSettings>({
|
||||
...this.userSettings,
|
||||
_id: userSettingsId
|
||||
})
|
||||
},
|
||||
setBodyFont(font: string) {
|
||||
if (!this.userSettings) {
|
||||
return
|
||||
}
|
||||
this.userSettings.chosenBodyFont = font
|
||||
|
||||
const userSettingsId = `UserSetting-${this.user}-${this.repo}`
|
||||
data.update<DataType.UserSettings, UserSettings>({
|
||||
...this.userSettings,
|
||||
|
||||
@@ -12,10 +12,15 @@ export const useUserSettings = () => {
|
||||
watchEffect(() => {
|
||||
const root = document.documentElement
|
||||
|
||||
const fontFamily = store.userSettings?.chosenFontFamily
|
||||
const fontSize = store.userSettings?.chosenFontSize
|
||||
const bodyFont = store.userSettings?.chosenBodyFont
|
||||
const titleFont = store.userSettings?.chosenTitleFont
|
||||
|
||||
downloadFont(fontFamily || DEFAULT_FONT_POLICY)
|
||||
downloadFont(bodyFont || DEFAULT_FONT_POLICY, "--font-family")
|
||||
downloadFont(
|
||||
titleFont || bodyFont || DEFAULT_FONT_POLICY,
|
||||
"--title-font-family"
|
||||
)
|
||||
root.style.setProperty("--font-size", fontSize || DEFAULT_FONT_SIZE)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user