mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-24 09:40:16 +08:00
🐛 Fix(custom): fix the double v in version page
This commit is contained in:
@@ -3,7 +3,7 @@ import { fileURLToPath } from 'node:url'
|
||||
|
||||
import { I18n, ObjectAdapter } from '@piclist/i18n'
|
||||
import fs from 'fs-extra'
|
||||
import yaml from 'js-yaml'
|
||||
import yaml from 'yaml'
|
||||
|
||||
const dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
|
||||
@@ -54,7 +54,7 @@ class I18nManager {
|
||||
}
|
||||
try {
|
||||
const localesString = fs.readFileSync(localesPath, 'utf8')
|
||||
const locales = yaml.load(localesString) as unknown as ILocales
|
||||
const locales = yaml.parseDocument(localesString).toJSON() as unknown as ILocales
|
||||
this.localesMap.set(lang, locales)
|
||||
return locales
|
||||
} catch (e) {
|
||||
@@ -62,7 +62,7 @@ class I18nManager {
|
||||
// if error, use default language
|
||||
localesPath = path.join(this.builtinI18nFolder, `${this.defaultLanguage}.yml`)
|
||||
const localesString = fs.readFileSync(localesPath, 'utf8')
|
||||
const locales = yaml.load(localesString) as unknown as ILocales
|
||||
const locales = yaml.parseDocument(localesString).toJSON() as unknown as ILocales
|
||||
this.localesMap.set(lang, locales)
|
||||
return locales
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import { fileURLToPath } from 'node:url'
|
||||
|
||||
import { dbPathChecker } from '@core/datastore/dbChecker'
|
||||
import fs from 'fs-extra'
|
||||
import yaml from 'js-yaml'
|
||||
import yaml from 'yaml'
|
||||
|
||||
import { i18nManager } from '~/i18n'
|
||||
|
||||
@@ -116,7 +116,7 @@ function resolveOtherI18nFiles() {
|
||||
const i18nFilePath = path.join(i18nFolder, item.name)
|
||||
const i18nFile = fs.readFileSync(i18nFilePath, 'utf8')
|
||||
try {
|
||||
const i18nFileObj = yaml.load(i18nFile) as unknown as ILocales
|
||||
const i18nFileObj = yaml.parseDocument(i18nFile).toJSON() as unknown as ILocales
|
||||
if (i18nFileObj?.LANG_DISPLAY_LABEL) {
|
||||
i18nManager.addI18nFile(item.name.replace('.yml', ''), i18nFileObj.LANG_DISPLAY_LABEL)
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@ import path from 'node:path'
|
||||
|
||||
import { clipboard, contextBridge, ipcRenderer, IpcRendererEvent, webFrame, webUtils } from 'electron'
|
||||
import fs from 'fs-extra'
|
||||
import yaml from 'js-yaml'
|
||||
import mime from 'mime'
|
||||
import { isReactive, isRef, toRaw, unref } from 'vue'
|
||||
import yaml from 'yaml'
|
||||
|
||||
export const getRawData = (args: any): any => {
|
||||
if (isRef(args)) return unref(args)
|
||||
@@ -90,7 +90,7 @@ try {
|
||||
createHash: crypto.createHash,
|
||||
},
|
||||
yaml: {
|
||||
load: yaml.load,
|
||||
parse: yaml.parseDocument,
|
||||
},
|
||||
mime: {
|
||||
lookup: mime.getType.bind(mime),
|
||||
|
||||
@@ -1136,7 +1136,7 @@
|
||||
<div class="version-card latest" :class="{ 'has-update': needUpdate }">
|
||||
<div class="version-card-label">{{ t('pages.settings.update.newestVersion') }}</div>
|
||||
<div class="version-card-value">
|
||||
{{ latestVersion ? `v${latestVersion}` : t('pages.settings.update.getting') }}
|
||||
{{ latestVersion ? `${latestVersion}` : t('pages.settings.update.getting') }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -7,6 +7,8 @@ export const getLatestVersion = async (): Promise<string> => {
|
||||
throw new Error(`HTTP error! status: ${response.status}`)
|
||||
}
|
||||
const normalList = await response.json()
|
||||
console.log('Fetched latest version info: ', normalList)
|
||||
console.log('Latest version is: ', normalList[0].name)
|
||||
return normalList[0].name
|
||||
} catch (err) {
|
||||
console.error('Error fetching latest version: ', err)
|
||||
@@ -16,7 +18,7 @@ export const getLatestVersion = async (): Promise<string> => {
|
||||
throw new Error(`HTTP error! status: ${response.status}`)
|
||||
}
|
||||
const data = await response.text()
|
||||
const r = window.node.yaml.load(data) as IStringKeyMap
|
||||
const r = window.node.yaml.parse(data).toJSON() as IStringKeyMap
|
||||
return r.version
|
||||
} catch (err) {
|
||||
console.error('Error fetching backup latest version: ', err)
|
||||
|
||||
4
src/universal/types/shims-tsx.d.ts
vendored
4
src/universal/types/shims-tsx.d.ts
vendored
@@ -5,9 +5,9 @@ import path from 'node:path'
|
||||
|
||||
import { clipboard } from 'electron'
|
||||
import fs from 'fs-extra'
|
||||
import yaml from 'js-yaml'
|
||||
import mime from 'mime'
|
||||
import { VNode } from 'vue'
|
||||
import yaml from 'yaml'
|
||||
|
||||
declare global {
|
||||
export namespace JSX {
|
||||
@@ -53,7 +53,7 @@ declare global {
|
||||
}
|
||||
|
||||
yaml: {
|
||||
load: typeof yaml.load
|
||||
parse: typeof yaml.parseDocument
|
||||
}
|
||||
mime: {
|
||||
lookup: typeof mime.getType
|
||||
|
||||
Reference in New Issue
Block a user