mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-06-01 06:09:47 +08:00
✨ Feature(custom): optimize i18n and platform funcs
This commit is contained in:
@@ -438,7 +438,7 @@ async function getBucketList () {
|
||||
|
||||
function transPathToUnix (filePath: string | undefined) {
|
||||
if (!filePath) return ''
|
||||
return window.electron.sendRpcSync(IRPCActionType.GET_PLATFORM) === 'win32'
|
||||
return window.electron.platform === 'win32'
|
||||
? filePath
|
||||
.split(window.node.path.sep)
|
||||
.join(window.node.path.posix.sep)
|
||||
|
||||
@@ -1417,12 +1417,12 @@ const languageList = [
|
||||
}
|
||||
]
|
||||
|
||||
const startModeList = Object.values(ISartMode).map(item => ({
|
||||
const startModeList = computed(() => Object.values(ISartMode).map(item => ({
|
||||
label: t(`SETTINGS_START_MODE_${item.toUpperCase().replace(/-/g, '_')}` as any),
|
||||
value: item
|
||||
}))
|
||||
})))
|
||||
|
||||
const manualPageOpenList = [
|
||||
const manualPageOpenList = computed(() => [
|
||||
{
|
||||
label: t('MANUAL_PAGE_OPEN_BY_BUILD_IN'),
|
||||
value: 'window'
|
||||
@@ -1431,7 +1431,7 @@ const manualPageOpenList = [
|
||||
label: t('MANUAL_PAGE_OPEN_BY_BROWSER'),
|
||||
value: 'browser'
|
||||
}
|
||||
]
|
||||
])
|
||||
|
||||
const showPicBedList = computed(
|
||||
() =>
|
||||
@@ -1676,12 +1676,12 @@ async function initData () {
|
||||
formOfSetting.value.logLevel = initArray(settings.logLevel || [], ['all'])
|
||||
formOfSetting.value.autoImportPicBed = initArray(settings.autoImportPicBed || [], [])
|
||||
currentLanguage.value = valueToOptionItem(settings.language || 'zh-CN', languageList)
|
||||
currentStartMode.value = valueToOptionItem(settings.startMode || ISartMode.QUIET, startModeList)
|
||||
currentStartMode.value = valueToOptionItem(settings.startMode || ISartMode.QUIET, startModeList.value)
|
||||
if (osGlobal.value === 'darwin' && currentStartMode.value.value === ISartMode.MINI) {
|
||||
currentStartMode.value = valueToOptionItem(ISartMode.QUIET, startModeList)
|
||||
currentStartMode.value = valueToOptionItem(ISartMode.QUIET, startModeList.value)
|
||||
saveConfig(configPaths.settings.startMode, ISartMode.QUIET)
|
||||
}
|
||||
currentManualPageOpen.value = valueToOptionItem(settings.manualPageOpen || 'window', manualPageOpenList)
|
||||
currentManualPageOpen.value = valueToOptionItem(settings.manualPageOpen || 'window', manualPageOpenList.value)
|
||||
currentShortUrlServer.value = valueToOptionItem(settings.shortUrlServer || 'c1n', shortUrlServerList)
|
||||
customLink.value = settings.customLink || ''
|
||||
proxy.value = picBed.proxy || ''
|
||||
@@ -2040,7 +2040,7 @@ function handleStartModeChange (val: ISartModeValues) {
|
||||
if (val === ISartMode.NO_TRAY) {
|
||||
if (formOfSetting.value.isHideDock) {
|
||||
ElMessage.warning(t('SETTINGS_ISHIDEDOCK_TIPS'))
|
||||
currentStartMode.value = valueToOptionItem(ISartMode.QUIET, startModeList)
|
||||
currentStartMode.value = valueToOptionItem(ISartMode.QUIET, startModeList.value)
|
||||
return
|
||||
}
|
||||
$message.info(t('TIPS_NEED_RELOAD'))
|
||||
|
||||
@@ -3,8 +3,8 @@ import { ref } from 'vue'
|
||||
import { IRPCActionType } from '#/types/enum'
|
||||
import { IPicBedType } from '#/types/types'
|
||||
|
||||
console.log('global.ts loaded', window.node.crypto.randomBytes(16).toString('hex'))
|
||||
const osGlobal = ref<string>(window.electron.sendRpcSync(IRPCActionType.GET_PLATFORM))
|
||||
console.log('global.ts loaded', window.electron.platform)
|
||||
const osGlobal = ref<string>(window.electron.platform)
|
||||
|
||||
const picBedGlobal = ref<IPicBedType[]>([])
|
||||
const pageReloadCount = ref(0)
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { IRPCActionType } from '#/types/enum'
|
||||
|
||||
const isSpecialKey = (key: string) => {
|
||||
const keyArr = ['Shift', 'Control', 'Alt', 'Meta']
|
||||
|
||||
@@ -7,7 +5,7 @@ const isSpecialKey = (key: string) => {
|
||||
}
|
||||
|
||||
const keyBinding = (event: KeyboardEvent) => {
|
||||
const meta = window.electron.sendRpcSync(IRPCActionType.GET_PLATFORM) === 'darwin' ? 'Cmd' : 'Super'
|
||||
const meta = window.electron.platform === 'darwin' ? 'Cmd' : 'Super'
|
||||
const specialKey = {
|
||||
Ctrl: event.ctrlKey,
|
||||
Shift: event.shiftKey,
|
||||
|
||||
Reference in New Issue
Block a user