chore(font): twemoji font don't display when cors

This commit is contained in:
riolu.rs 2023-09-05 11:40:00 +08:00
parent 677f3ff042
commit 092aa41972
5 changed files with 34 additions and 0 deletions

View File

@ -9,6 +9,7 @@ import {
selectedEndpoint, selectedEndpoint,
useAutoSwitchTheme, useAutoSwitchTheme,
useProxies, useProxies,
useTwemoji,
} from '~/signals' } from '~/signals'
const Setup = lazy(() => import('~/pages/Setup')) const Setup = lazy(() => import('~/pages/Setup'))
@ -29,6 +30,20 @@ export const App = () => {
if (selectedEndpoint() && endpoint()) { if (selectedEndpoint() && endpoint()) {
void useProxies().updateProxies() void useProxies().updateProxies()
} }
const rootElement = document.querySelector(':root') as HTMLElement
if (useTwemoji()) {
rootElement.style.setProperty(
'font-family',
"'Fira Sans', 'Twemoji Mozilla', system-ui, monospace",
)
} else {
rootElement.style.setProperty(
'font-family',
"'Fira Sans', system-ui, monospace",
)
}
}) })
onMount(() => { onMount(() => {

View File

@ -42,6 +42,7 @@ export default {
proxiesPreviewType: 'Proxies preview type', proxiesPreviewType: 'Proxies preview type',
urlForLatencyTest: 'Url for latency test', urlForLatencyTest: 'Url for latency test',
autoCloseConns: 'Automatically close all connections', autoCloseConns: 'Automatically close all connections',
useTwemoji: 'Use Twemoji Mozilla Font',
autoSwitchTheme: 'Automatically switch theme', autoSwitchTheme: 'Automatically switch theme',
favDayTheme: 'Favorite light theme', favDayTheme: 'Favorite light theme',
favNightTheme: 'Favorite dark theme', favNightTheme: 'Favorite dark theme',

View File

@ -42,6 +42,7 @@ export default {
proxiesPreviewType: '节点组预览样式', proxiesPreviewType: '节点组预览样式',
urlForLatencyTest: '测速链接', urlForLatencyTest: '测速链接',
autoCloseConns: '切换代理时自动断开全部连接', autoCloseConns: '切换代理时自动断开全部连接',
useTwemoji: '使用Twemoji Mozilla字体',
autoSwitchTheme: '自动切换主题', autoSwitchTheme: '自动切换主题',
favDayTheme: '浅色主题偏好', favDayTheme: '浅色主题偏好',
favNightTheme: '深色主题偏好', favNightTheme: '深色主题偏好',

View File

@ -27,9 +27,11 @@ import {
setProxiesPreviewType, setProxiesPreviewType,
setRenderInTwoColumn, setRenderInTwoColumn,
setRenderProxiesInSamePage, setRenderProxiesInSamePage,
setTwemoji,
setUrlForLatencyTest, setUrlForLatencyTest,
urlForLatencyTest, urlForLatencyTest,
useRequest, useRequest,
useTwemoji,
} from '~/signals' } from '~/signals'
import type { DNSQuery, Config as IConfig } from '~/types' import type { DNSQuery, Config as IConfig } from '~/types'
@ -336,6 +338,17 @@ const ConfigForXd = () => {
/> />
</div> </div>
<div>
<div class="pb-4 text-lg font-semibold">{t('useTwemoji')}</div>
<input
class="toggle"
type="checkbox"
checked={useTwemoji()}
onChange={(e) => setTwemoji(e.target.checked)}
/>
</div>
<div class="flex flex-col"> <div class="flex flex-col">
<div class="pb-4 text-lg font-semibold">{t('urlForLatencyTest')}</div> <div class="pb-4 text-lg font-semibold">{t('urlForLatencyTest')}</div>

View File

@ -24,6 +24,10 @@ export const [autoCloseConns, setAutoCloseConns] = makePersisted(
createSignal(false), createSignal(false),
{ name: 'autoCloseConns', storage: localStorage }, { name: 'autoCloseConns', storage: localStorage },
) )
export const [useTwemoji, setTwemoji] = makePersisted(createSignal(false), {
name: 'useTwemoji',
storage: localStorage,
})
export const [autoSwitchTheme, setAutoSwitchTheme] = makePersisted( export const [autoSwitchTheme, setAutoSwitchTheme] = makePersisted(
createSignal(false), createSignal(false),
{ name: 'autoSwitchTheme', storage: localStorage }, { name: 'autoSwitchTheme', storage: localStorage },