fix: correct translation color in dark mode and enable Chinese punctuation input
- Fix incorrect text color of translations in dark mode - Resolve issue where Chinese punctuation could not be input
This commit is contained in:
@@ -129,8 +129,8 @@ async function refreshCDN(domain) {
|
||||
async function main() {
|
||||
const files = getAllFiles('./dist')
|
||||
console.log(`📁 共找到 ${files.length} 个文件,开始上传...`)
|
||||
// await uploadFilesWithClean(files, './dist', ['dicts', 'sound', 'libs','imgs])
|
||||
await uploadFilesWithClean(files, './dist', ['sound','libs','imgs'])
|
||||
await uploadFilesWithClean(files, './dist', ['dicts', 'sound', 'libs','imgs'])
|
||||
// await uploadFilesWithClean(files, './dist', ['sound','libs','imgs'])
|
||||
await refreshCDN('2study.top')
|
||||
await refreshCDN('typewords.cc')
|
||||
}
|
||||
|
||||
@@ -21,7 +21,11 @@ const userStore = useUserStore()
|
||||
const {setTheme} = useTheme()
|
||||
|
||||
let lastAudioFileIdList = []
|
||||
let isInitializing = true // 标记是否正在初始化
|
||||
watch(store.$state, (n: BaseState) => {
|
||||
// 如果正在初始化,不保存数据,避免覆盖
|
||||
if (isInitializing) return
|
||||
console.log('watch')
|
||||
let data = shakeCommonDict(n)
|
||||
set(SAVE_DICT_KEY.key, JSON.stringify({val: data, version: SAVE_DICT_KEY.version}))
|
||||
|
||||
@@ -52,6 +56,7 @@ watch(store.$state, (n: BaseState) => {
|
||||
})
|
||||
|
||||
watch(() => settingStore.$state, (n) => {
|
||||
if (isInitializing) return
|
||||
set(SAVE_SETTING_KEY.key, JSON.stringify({val: n, version: SAVE_SETTING_KEY.version}))
|
||||
if (AppEnv.CAN_REQUEST) {
|
||||
syncSetting(null, settingStore.$state)
|
||||
@@ -59,10 +64,12 @@ watch(() => settingStore.$state, (n) => {
|
||||
}, {deep: true})
|
||||
|
||||
async function init() {
|
||||
isInitializing = true // 开始初始化
|
||||
await userStore.init()
|
||||
await store.init()
|
||||
await settingStore.init()
|
||||
store.load = true
|
||||
isInitializing = false // 初始化完成,允许保存数据
|
||||
|
||||
setTheme(settingStore.theme)
|
||||
|
||||
|
||||
@@ -648,7 +648,7 @@ const currentPractice = inject('currentPractice', [])
|
||||
@input="handleMobileInput"
|
||||
/>
|
||||
<header class="mb-4">
|
||||
<div class="title word"><span class="font-family text-3xl">{{
|
||||
<div class="title"><span class="font-family text-3xl">{{
|
||||
store.sbook.lastLearnIndex + 1
|
||||
}}.</span>{{ props.article.title }}
|
||||
</div>
|
||||
@@ -826,7 +826,7 @@ $article-lh: 2.4;
|
||||
display: inline-block !important;
|
||||
}
|
||||
.translate{
|
||||
color:black;
|
||||
color: var(--color-reverse-black);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -245,8 +245,7 @@ let isNewHost = $ref(window.location.host === Host)
|
||||
2study.top 域名将在不久后停止使用
|
||||
</div>
|
||||
|
||||
|
||||
<div class="card flex flex-col md:flex-row gap-8">
|
||||
<div class="card flex flex-col md:flex-row gap-4">
|
||||
<div class="flex-1 w-full flex flex-col justify-between">
|
||||
<div class="flex gap-3">
|
||||
<div class="p-1 center rounded-full bg-white">
|
||||
|
||||
@@ -245,6 +245,38 @@ async function onTyping(e: KeyboardEvent) {
|
||||
} else {
|
||||
right = letter === word[input.length]
|
||||
}
|
||||
//针对中文的特殊判断
|
||||
if (e.shiftKey && (
|
||||
'!' === word[input.length] && e.code === 'Digit1' ||
|
||||
'¥' === word[input.length] && e.code === 'Digit4' ||
|
||||
'…' === word[input.length] && e.code === 'Digit6' ||
|
||||
'(' === word[input.length] && e.code === 'Digit9' ||
|
||||
'—' === word[input.length] && e.code === 'Minus' ||
|
||||
'?' === word[input.length] && e.code === 'Slash' ||
|
||||
'》' === word[input.length] && e.code === 'Period' ||
|
||||
'《' === word[input.length] && e.code === 'Comma' ||
|
||||
'“' === word[input.length] && e.code === 'Quote' ||
|
||||
':' === word[input.length] && e.code === 'Semicolon' ||
|
||||
')' === word[input.length] && e.code === 'Digit0')
|
||||
) {
|
||||
right = true
|
||||
letter = word[input.length]
|
||||
}
|
||||
if (!e.shiftKey && (
|
||||
'【' === word[input.length] && e.code === 'BracketLeft' ||
|
||||
'、' === word[input.length] && e.code === 'Slash' ||
|
||||
'。' === word[input.length] && e.code === 'Period' ||
|
||||
',' === word[input.length] && e.code === 'Comma' ||
|
||||
'‘' === word[input.length] && e.code === 'Quote' ||
|
||||
';' === word[input.length] && e.code === 'Semicolon' ||
|
||||
'【' === word[input.length] && e.code === 'BracketLeft' ||
|
||||
'】' === word[input.length] && e.code === 'BracketRight'
|
||||
)) {
|
||||
right = true
|
||||
letter = word[input.length]
|
||||
}
|
||||
console.log('e', e, e.code, e.shiftKey, word[input.length])
|
||||
|
||||
if (right) {
|
||||
input += letter
|
||||
wrong = ''
|
||||
@@ -386,6 +418,7 @@ function checkCursorPosition() {
|
||||
// 选中目标元素
|
||||
const cursorEl = document.querySelector(`.cursor`);
|
||||
const inputList = document.querySelectorAll(`.l`);
|
||||
if (!typingWordRef) return;
|
||||
const typingWordRect = typingWordRef.getBoundingClientRect();
|
||||
|
||||
if (inputList.length) {
|
||||
|
||||
@@ -129,7 +129,6 @@ export const useBaseStore = defineStore('base', {
|
||||
}
|
||||
}
|
||||
this.setState(data)
|
||||
set(SAVE_DICT_KEY.key, JSON.stringify({ val: shakeCommonDict(this.$state), version: SAVE_DICT_KEY.version }))
|
||||
} catch (e) {
|
||||
console.error('读取本地dict数据失败', e)
|
||||
}
|
||||
|
||||
@@ -37,9 +37,15 @@ export function checkAndUpgradeSaveDict(val: any) {
|
||||
} else {
|
||||
data = val
|
||||
}
|
||||
if (!data.version) return defaultState
|
||||
if (!data.version) {
|
||||
console.warn('数据缺少版本号,返回默认状态')
|
||||
return defaultState
|
||||
}
|
||||
let state: any = data.val
|
||||
if (typeof state !== 'object') return defaultState
|
||||
if (typeof state !== 'object') {
|
||||
console.warn('数据格式无效,返回默认状态')
|
||||
return defaultState
|
||||
}
|
||||
state.load = false
|
||||
let version = Number(data.version)
|
||||
// console.log('state', state)
|
||||
@@ -53,10 +59,29 @@ export function checkAndUpgradeSaveDict(val: any) {
|
||||
})
|
||||
return defaultState
|
||||
} else {
|
||||
checkRiskKey(defaultState, state)
|
||||
return defaultState
|
||||
// 版本不匹配时,尽量保留数据而不是直接返回默认状态
|
||||
console.warn(`数据版本不匹配: 当前版本 ${version}, 期望版本 ${SAVE_DICT_KEY.version},尝试保留数据`)
|
||||
try {
|
||||
checkRiskKey(defaultState, state)
|
||||
// 尝试保留 bookList 数据
|
||||
if (state.word && state.word.bookList && Array.isArray(state.word.bookList)) {
|
||||
defaultState.word.bookList = state.word.bookList.map((v: any) => {
|
||||
return getDefaultDict(checkRiskKey(getDefaultDict(), v))
|
||||
})
|
||||
}
|
||||
if (state.article && state.article.bookList && Array.isArray(state.article.bookList)) {
|
||||
defaultState.article.bookList = state.article.bookList.map((v: any) => {
|
||||
return getDefaultDict(checkRiskKey(getDefaultDict(), v))
|
||||
})
|
||||
}
|
||||
return defaultState
|
||||
} catch (upgradeError) {
|
||||
console.error('数据升级失败,返回默认状态', upgradeError)
|
||||
return defaultState
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('数据解析异常,返回默认状态', e)
|
||||
return defaultState
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user