fix and simplify font settings
This commit is contained in:
parent
9f3c0ec60b
commit
34a7bf83b2
6 changed files with 15 additions and 15 deletions
|
|
@ -23,7 +23,7 @@
|
||||||
</div>
|
</div>
|
||||||
{{ ' ' }}
|
{{ ' ' }}
|
||||||
<div
|
<div
|
||||||
v-if="modelValue?.family"
|
v-if="modelValue"
|
||||||
class="font-input setting-item"
|
class="font-input setting-item"
|
||||||
>
|
>
|
||||||
<label
|
<label
|
||||||
|
|
@ -67,10 +67,10 @@
|
||||||
</button>
|
</button>
|
||||||
<input
|
<input
|
||||||
:id="name"
|
:id="name"
|
||||||
:model-value="modelValue.family"
|
:model-value="modelValue"
|
||||||
class="input custom-font"
|
class="input custom-font"
|
||||||
type="text"
|
type="text"
|
||||||
@update:modelValue="$emit('update:modelValue', { ...(modelValue || {}), family: $event.target.value })"
|
@update:modelValue="$emit('update:modelValue', $event.target.value)"
|
||||||
>
|
>
|
||||||
</span>
|
</span>
|
||||||
<span
|
<span
|
||||||
|
|
@ -89,9 +89,9 @@
|
||||||
</button>
|
</button>
|
||||||
<Select
|
<Select
|
||||||
:id="name + '-local-font-switcher'"
|
:id="name + '-local-font-switcher'"
|
||||||
:model-value="modelValue?.family"
|
:model-value="modelValue"
|
||||||
class="custom-font"
|
class="custom-font"
|
||||||
@update:model-value="v => $emit('update:modelValue', { ...(modelValue || {}), family: v })"
|
@update:model-value="v => $emit('update:modelValue', v)"
|
||||||
>
|
>
|
||||||
<optgroup
|
<optgroup
|
||||||
:label="$t('settings.style.themes3.font.group-builtin')"
|
:label="$t('settings.style.themes3.font.group-builtin')"
|
||||||
|
|
|
||||||
|
|
@ -635,22 +635,22 @@ export const LOCAL_DEFAULT_CONFIG_DEFINITIONS = {
|
||||||
},
|
},
|
||||||
fontInterface: {
|
fontInterface: {
|
||||||
description: 'Interface font override',
|
description: 'Interface font override',
|
||||||
type: 'object',
|
type: 'string',
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
fontInput: {
|
fontInput: {
|
||||||
description: 'Input font override',
|
description: 'Input font override',
|
||||||
type: 'object',
|
type: 'string',
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
fontPosts: {
|
fontPosts: {
|
||||||
description: 'Post font override',
|
description: 'Post font override',
|
||||||
type: 'object',
|
type: 'string',
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
fontMonospace: {
|
fontMonospace: {
|
||||||
description: 'Monospace font override',
|
description: 'Monospace font override',
|
||||||
type: 'object',
|
type: 'string',
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
themeDebug: {
|
themeDebug: {
|
||||||
|
|
|
||||||
|
|
@ -262,7 +262,7 @@ export const convertTheme2To3 = (data) => {
|
||||||
Object.keys(data.fonts || {}).forEach((key) => {
|
Object.keys(data.fonts || {}).forEach((key) => {
|
||||||
if (!fontsKeys.has(key)) return
|
if (!fontsKeys.has(key)) return
|
||||||
if (!data.fonts[key]) return
|
if (!data.fonts[key]) return
|
||||||
const originalFont = data.fonts[key].family
|
const originalFont = data.fonts[key]
|
||||||
const rule = { source: '2to3' }
|
const rule = { source: '2to3' }
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
|
|
|
||||||
|
|
@ -619,7 +619,7 @@ export const generateFonts = (input) => {
|
||||||
rules: {
|
rules: {
|
||||||
fonts: Object.entries(fonts)
|
fonts: Object.entries(fonts)
|
||||||
.filter(([, v]) => v)
|
.filter(([, v]) => v)
|
||||||
.map(([k, v]) => `--${k}Font: ${v.family}`)
|
.map(([k, v]) => `--${k}Font: ${v}`)
|
||||||
.join(';'),
|
.join(';'),
|
||||||
},
|
},
|
||||||
theme: {
|
theme: {
|
||||||
|
|
|
||||||
|
|
@ -196,7 +196,7 @@ export const useInterfaceStore = defineStore('interface', {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setFontsList(value) {
|
setFontsList(value) {
|
||||||
this.localFonts = [...new Set(value.map((font) => font.family)).values()]
|
this.localFonts = [...new Set(value.map((font) => font)).values()]
|
||||||
},
|
},
|
||||||
queryLocalFonts() {
|
queryLocalFonts() {
|
||||||
if (this.localFonts !== null) return
|
if (this.localFonts !== null) return
|
||||||
|
|
@ -654,7 +654,7 @@ export const useInterfaceStore = defineStore('interface', {
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.entries(fontMap).forEach(([font, component]) => {
|
Object.entries(fontMap).forEach(([font, component]) => {
|
||||||
const family = mergedConfig[`font${font}`]?.family
|
const family = mergedConfig[`font${font}`]
|
||||||
const variable = font === 'Monospace' ? '--monoFont' : '--font'
|
const variable = font === 'Monospace' ? '--monoFont' : '--font'
|
||||||
if (family) {
|
if (family) {
|
||||||
hacks.push({
|
hacks.push({
|
||||||
|
|
|
||||||
|
|
@ -238,8 +238,8 @@ describe('The SyncConfig store', () => {
|
||||||
store.pushSyncConfig = () => {
|
store.pushSyncConfig = () => {
|
||||||
/* no-op */
|
/* no-op */
|
||||||
}
|
}
|
||||||
store.setPreference({ path: 'simple.fontInput.family', value: 'test' })
|
store.setPreference({ path: 'simple.fontInput', value: 'test' })
|
||||||
store.unsetPreference({ path: 'simple.fontInput.family' })
|
store.unsetPreference({ path: 'simple.fontInput' })
|
||||||
store.updateCache(store, { username: 'test' })
|
store.updateCache(store, { username: 'test' })
|
||||||
expect(store.prefsStorage.simple.fontInput).to.not.have.property(
|
expect(store.prefsStorage.simple.fontInput).to.not.have.property(
|
||||||
'family',
|
'family',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue