🐛 Fix(custom): fix the double v in version page

This commit is contained in:
Kuingsmile
2026-01-05 13:36:18 +08:00
parent 4d074e8ed2
commit 5460bd785a
16 changed files with 118 additions and 511 deletions

View File

@@ -105,7 +105,6 @@ jobs:
if: matrix.os != 'windows-11-arm' if: matrix.os != 'windows-11-arm'
run: | run: |
yarn release yarn release
yarn upload-dist
env: env:
GH_TOKEN: ${{ secrets.GH_TOKEN }} GH_TOKEN: ${{ secrets.GH_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
@@ -134,7 +133,6 @@ jobs:
Remove-Item Env:CSC_KEY_PASSWORD -ErrorAction SilentlyContinue Remove-Item Env:CSC_KEY_PASSWORD -ErrorAction SilentlyContinue
$env:CSC_IDENTITY_AUTO_DISCOVERY = "false" $env:CSC_IDENTITY_AUTO_DISCOVERY = "false"
yarn release yarn release
yarn upload-dist
env: env:
GH_TOKEN: ${{ secrets.GH_TOKEN }} GH_TOKEN: ${{ secrets.GH_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}

View File

@@ -1,75 +0,0 @@
# main.yml
# Workflow's name
name: Mas Build
# Workflow's trigger
on:
workflow_dispatch:
permissions:
contents: read
env:
ELECTRON_OUTPUT_PATH: ./dist_electron
CSC_LINK: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
CSC_KEY_PASSWORD: ${{ secrets.P12_PASSWORD }}
# Workflow's jobs
jobs:
# job's id
release:
# job's name
name: build and release electron app
# the type of machine to run the job on
runs-on: ${{ matrix.os }}
# create a build matrix for jobs
strategy:
fail-fast: false
matrix:
os: [macos-13]
# create steps
steps:
# step1: check out repository
- name: Check out git repository
uses: actions/checkout@v2
# step2: sign
- name: Install the Apple certificates
if: matrix.os == 'macos-13'
run: |
PP_PATH=$RUNNER_TEMP/build/piclistmas.provisionprofile
echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode -o $PP_PATH
# step2: install node env
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '18.17.0'
# step3: yarn
- name: Yarn install
run: |
yarn
yarn global add xvfb-maybe
- name: Build & release app
run: |
yarn build
yarn upload-beta
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
R2_SECRET_ID: ${{ secrets.R2_SECRET_ID }}
R2_SECRET_KEY: ${{ secrets.R2_SECRET_KEY }}
R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }}
ELECTRON_SKIP_NOTARIZATION: ${{ secrets.ELECTRON_SKIP_NOTARIZATION }}
XCODE_APP_LOADER_EMAIL: ${{ secrets.XCODE_APP_LOADER_EMAIL }}
XCODE_APP_LOADER_PASSWORD: ${{ secrets.XCODE_APP_LOADER_PASSWORD }}
XCODE_TEAM_ID: ${{ secrets.XCODE_TEAM_ID }}
BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}

View File

@@ -1,214 +0,0 @@
name: Test Build
on:
workflow_dispatch:
permissions:
contents: read
env:
ELECTRON_OUTPUT_PATH: ./dist_electron
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
USE_HARD_LINKS: false
jobs:
test-build:
name: Test Build for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-15-intel, windows-latest, windows-11-arm, macos-latest]
steps:
- name: Set up git config
run: |
git config --global core.autocrlf false
- name: Check out git repository
uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '22.x'
- name: Install system deps
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y icnsutils graphicsmagick xz-utils
- name: Install dependencies (macOS)
if: matrix.os == 'macos-15-intel' || matrix.os == 'macos-latest'
run: |
yarn config set ignore-engines true
yarn install
- name: Install dependencies (Windows)
if: matrix.os == 'windows-latest' || matrix.os == 'windows-11-arm'
run: |
yarn config set ignore-engines true
yarn install
- name: Install dependencies (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
yarn config set ignore-engines true
yarn install
- name: Modify electron-builder.json for Windows x64
if: matrix.os == 'windows-latest'
run: |
# Remove arm64 from the arch array, keep only x64
$config = Get-Content electron-builder.json | ConvertFrom-Json
$config.win.target[0].arch = @("x64", "ia32")
$config | ConvertTo-Json -Depth 10 | Set-Content electron-builder.json
- name: Modify electron-builder.json for Windows ARM64
if: matrix.os == 'windows-11-arm'
run: |
# Remove x64 from the arch array, keep only arm64
$config = Get-Content electron-builder.json | ConvertFrom-Json
$config.win.target[0].arch = @("arm64")
$config | ConvertTo-Json -Depth 10 | Set-Content electron-builder.json
- name: Modify electron-builder.json for Macos x64
if: matrix.os == 'macos-15-intel'
run: |
# Remove arm64 from the arch array, keep only x64
jq '.mac.target[0].arch = ["x64"]' electron-builder.json > tmp.json && mv tmp.json electron-builder.json
- name: Modify electron-builder.json for Macos ARM64
if: matrix.os == 'macos-latest'
run: |
# Remove x64 from the arch array, keep only arm64
jq '.mac.target[0].arch = ["arm64"]' electron-builder.json > tmp.json && mv tmp.json electron-builder.json
- name: Build application (Windows x64)
if: matrix.os == 'windows-latest' || matrix.os == 'windows-11-arm'
run: yarn build:win
env:
ELECTRON_SKIP_NOTARIZATION: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Build application (macOS)
if: matrix.os == 'macos-15-intel' || matrix.os == 'macos-latest'
run: yarn build:mac
env:
ELECTRON_SKIP_NOTARIZATION: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
USE_HARD_LINKS: false
- name: Build application (Linux)
if: matrix.os == 'ubuntu-latest'
run: yarn build:linux
env:
ELECTRON_SKIP_NOTARIZATION: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Upload Windows x64 executables
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: windows-x64-executables
path: |
dist_electron/*
retention-days: 30
if-no-files-found: error
- name: Upload Windows ARM64 executables
if: matrix.os == 'windows-11-arm'
uses: actions/upload-artifact@v4
with:
name: windows-arm64-executables
path: |
dist_electron/*.exe
retention-days: 30
if-no-files-found: error
- name: Upload macOS packages
if: matrix.os == 'macos-15-intel'
uses: actions/upload-artifact@v4
with:
name: macos-x64-packages
path: |
dist_electron/*.dmg
retention-days: 30
if-no-files-found: error
- name: Upload macOS ARM64 packages
if: matrix.os == 'macos-latest'
uses: actions/upload-artifact@v4
with:
name: macos-arm64-packages
path: |
dist_electron/*.dmg
retention-days: 30
- name: Upload Linux packages
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: linux-packages
path: |
dist_electron/*.AppImage
dist_electron/*.snap
retention-days: 30
if-no-files-found: ignore
- name: Upload Windows x64 yml
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: windows-x64-yml
path: |
dist_electron/github/*
retention-days: 30
if-no-files-found: error
- name: Upload Windows ARM64 yml
if: matrix.os == 'windows-11-arm'
uses: actions/upload-artifact@v4
with:
name: windows-arm64-yml
path: |
dist_electron/github/*
retention-days: 30
if-no-files-found: error
- name: Upload macOS yml
if: matrix.os == 'macos-15-intel'
uses: actions/upload-artifact@v4
with:
name: macos-x64-yml
path: |
dist_electron/github/*
retention-days: 30
if-no-files-found: error
- name: Upload macOS ARM64 yml
if: matrix.os == 'macos-latest'
uses: actions/upload-artifact@v4
with:
name: macos-arm64-yml
path: |
dist_electron/github/*
retention-days: 30
if-no-files-found: error
- name: Upload Linux yml
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: linux-yml
path: |
dist_electron/github/*
retention-days: 30
if-no-files-found: ignore

View File

@@ -5,11 +5,11 @@ PackageIdentifier: Kuingsmile.PicList
PackageVersion: 3.1.1 PackageVersion: 3.1.1
InstallerType: nullsoft InstallerType: nullsoft
Installers: Installers:
- Architecture: x64 - Architecture: x64
InstallerUrl: https://github.com/Kuingsmile/PicList/releases/download/v3.1.1/PicList-Setup-3.1.1.exe InstallerUrl: https://github.com/Kuingsmile/PicList/releases/download/v3.1.1/PicList-Setup-3.1.1.exe
InstallerSha256: 82CFFA9421ABE366CF1000CD7B0B094688A039F701900D55629FC86A495D9C82 InstallerSha256: 82CFFA9421ABE366CF1000CD7B0B094688A039F701900D55629FC86A495D9C82
- Architecture: arm64 - Architecture: arm64
InstallerUrl: https://github.com/Kuingsmile/PicList/releases/download/v3.1.1/PicList-Setup-3.1.1-arm64.exe InstallerUrl: https://github.com/Kuingsmile/PicList/releases/download/v3.1.1/PicList-Setup-3.1.1-arm64.exe
InstallerSha256: 11DA78D81629491208BED735155705A27C107695571EE6EEFC261B7CA306F6CD InstallerSha256: 11DA78D81629491208BED735155705A27C107695571EE6EEFC261B7CA306F6CD
ManifestType: installer ManifestType: installer
ManifestVersion: 1.9.0 ManifestVersion: 1.9.0

View File

@@ -38,8 +38,7 @@
"release": "electron-vite build && electron-builder --publish always", "release": "electron-vite build && electron-builder --publish always",
"sha256": "node ./scripts/gen-sha256.js", "sha256": "node ./scripts/gen-sha256.js",
"test": "vitest", "test": "vitest",
"upload-beta": "node ./scripts/upload-beta.cjs", "winget": "node ./scripts/auto-winget.js"
"upload-dist": "node ./scripts/upload-dist-to-r2.cjs"
}, },
"dependencies": { "dependencies": {
"@aws-sdk/client-s3": "^3.962.0", "@aws-sdk/client-s3": "^3.962.0",
@@ -62,7 +61,7 @@
"fflate": "^0.8.2", "fflate": "^0.8.2",
"form-data": "^4.0.5", "form-data": "^4.0.5",
"fs-extra": "^11.3.3", "fs-extra": "^11.3.3",
"got": "^14.6.5", "got": "^14.6.6",
"hpagent": "^1.2.0", "hpagent": "^1.2.0",
"js-yaml": "^4.1.1", "js-yaml": "^4.1.1",
"lodash-es": "^4.17.22", "lodash-es": "^4.17.22",
@@ -82,7 +81,8 @@
"uuid": "^13.0.0", "uuid": "^13.0.0",
"vue": "^3.5.26", "vue": "^3.5.26",
"webdav": "^5.8.0", "webdav": "^5.8.0",
"write-file-atomic": "^7.0.0" "write-file-atomic": "^7.0.0",
"yaml": "^2.8.2"
}, },
"devDependencies": { "devDependencies": {
"@electron/notarize": "^3.1.1", "@electron/notarize": "^3.1.1",

86
scripts/auto-winget.js Normal file
View File

@@ -0,0 +1,86 @@
import dotenv from 'dotenv'
import packagej from '../package.json' with { type: 'json' }
import * as fsWalk from '@nodelib/fs.walk'
import fs from 'fs-extra'
import path from 'node:path'
import yaml from 'yaml'
import axios from 'axios'
import { exec } from 'node:child_process'
dotenv.config()
const version = packagej.version
const walkPath = fsWalk.walkSync('.winget').slice(-1)[0]?.dirent.parentPath
const oldVersion = path.basename(walkPath)
const targetPath = path.resolve(`${path.dirname(walkPath)}/${version}`)
fs.renameSync(walkPath, targetPath)
const fileList = [
path.join(targetPath, 'Kuingsmile.PicList.installer.yaml'),
path.join(targetPath, 'Kuingsmile.PicList.locale.en-US.yaml'),
path.join(targetPath, 'Kuingsmile.PicList.yaml'),
]
function relaceVersion(filePath) {
let content = fs.readFileSync(filePath, 'utf-8')
content = content.replaceAll(oldVersion, version)
fs.writeFileSync(filePath, content, 'utf-8')
}
fileList.forEach(filePath => {
relaceVersion(filePath)
})
const releaseAPI = 'https://api.github.com/repos/Kuingsmile/piclist/releases/latest'
const response = await axios.get(releaseAPI, {
headers: {
Accept: 'application/vnd.github+json',
},
})
const releaseData = response.data
const fileNameList = [`PicList-Setup-${version}-arm64.exe`, `PicList-Setup-${version}.exe`]
const sha256List = []
fileNameList.forEach(fileName => {
const asset = releaseData.assets.find(a => a.name === fileName)
if (asset) {
sha256List.push({
fileName,
sha256: asset.digest.replace('sha256:', '').toUpperCase(),
})
}
})
const insatllerContent = yaml.parseDocument(fs.readFileSync(fileList[0], 'utf-8'))
const installers = insatllerContent.get('Installers')
const updatedInstallers = installers.toJSON().map(installer => {
const matched = sha256List.find(
item => installer.Architecture === (item.fileName.includes('arm64') ? 'arm64' : 'x64'),
)
if (matched) {
return {
...installer,
InstallerSha256: matched.sha256,
}
}
return installer
})
insatllerContent.set('Installers', updatedInstallers)
fs.writeFileSync(fileList[0], insatllerContent.toString(), 'utf-8')
const cmd = `wingetcreate.exe submit -p "PicList v${version}" -t "${process.env.GH_TOKEN}" .\\.winget\\manifests\\k\\Kuingsmile\\PicList\\${version}\\`
exec(cmd, (error, stdout, stderr) => {
if (error) {
console.error(`Error executing command: ${error.message}`)
return
}
if (stderr) {
console.error(`Command stderr: ${stderr}`)
return
}
console.log(`Command stdout: ${stdout}`)
})

View File

@@ -2,7 +2,7 @@ import { readFileSync, writeFileSync } from 'node:fs'
import { dirname, join } from 'node:path' import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url' import { fileURLToPath } from 'node:url'
import { load } from 'js-yaml' import yaml from 'yaml'
const languageFileName = 'zh-CN.yml' const languageFileName = 'zh-CN.yml'
const __filename = fileURLToPath(import.meta.url) const __filename = fileURLToPath(import.meta.url)
@@ -14,7 +14,7 @@ const languageFile = join(i18nFolder, languageFileName)
const langFile = readFileSync(languageFile, 'utf8') const langFile = readFileSync(languageFile, 'utf8')
const obj = load(langFile) const obj = yaml.parseDocument(langFile).toJSON()
const keys = Object.keys(obj) const keys = Object.keys(obj)

View File

@@ -1,63 +0,0 @@
// upload dist bundled-app to r2
require('dotenv').config()
const S3Client = require('@aws-sdk/client-s3')
const Upload = require('@aws-sdk/lib-storage')
const pkg = require('../package.json')
const configList = require('./config')
const fs = require('node:fs')
const path = require('node:path')
const BUCKET = 'piclist-dl'
const VERSION = pkg.version
const FILE_PATH = 'beta/'
const ACCOUNT_ID = process.env.R2_ACCOUNT_ID
const SECRET_ID = process.env.R2_SECRET_ID
const SECRET_KEY = process.env.R2_SECRET_KEY
const uploadFile = async () => {
try {
const platform = process.platform
if (configList[platform]) {
for (const [index, config] of configList[platform].entries()) {
const fileName = `${config.appNameWithPrefix}${VERSION}${config.arch}${config.ext}`
const distPath = path.join(__dirname, '../dist_electron')
console.log('[PicList Dist] Uploading...', fileName, `${index + 1}/${configList[platform].length}`)
const fileStream = fs.createReadStream(path.join(distPath, fileName))
const options = {
credentials: {
accessKeyId: SECRET_ID,
secretAccessKey: SECRET_KEY,
},
endpoint: `https://${ACCOUNT_ID}.r2.cloudflarestorage.com`,
tls: true,
region: 'auto',
}
const client = new S3Client.S3Client(options)
const parallelUploads3 = new Upload.Upload({
client,
params: {
Bucket: BUCKET,
Key: `${FILE_PATH}${fileName}`,
Body: fileStream,
ContentType: 'application/octet-stream',
Metadata: {
description: 'uploaded by PicList',
},
},
})
parallelUploads3.on('httpUploadProgress', progress => {
const progressBar = Math.round((progress.loaded / progress.total) * 100)
process.stdout.write(`\r${progressBar}% ${fileName}`)
})
console.log('\n')
await parallelUploads3.done()
console.log(`${fileName} uploaded!`)
}
} else {
console.warn('platform not supported!', platform)
}
} catch (err) {
console.error(err)
}
}
uploadFile()

View File

@@ -1,132 +0,0 @@
// upload dist bundled-app to r2
require('dotenv').config()
const S3Client = require('@aws-sdk/client-s3')
const Upload = require('@aws-sdk/lib-storage')
const pkg = require('../package.json')
const configList = require('./config')
const fs = require('node:fs')
const path = require('node:path')
const yaml = require('js-yaml')
const mime = require('mime')
const BUCKET = 'piclist-dl'
const VERSION = pkg.version
const FILE_PATH = 'latest/'
const ACCOUNT_ID = process.env.R2_ACCOUNT_ID
const SECRET_ID = process.env.R2_SECRET_ID
const SECRET_KEY = process.env.R2_SECRET_KEY
const options = {
credentials: {
accessKeyId: SECRET_ID,
secretAccessKey: SECRET_KEY,
},
endpoint: `https://${ACCOUNT_ID}.r2.cloudflarestorage.com`,
tls: true,
region: 'auto',
}
const removeDupField = path => {
const file = fs.readFileSync(path, 'utf8')
const data = yaml.load(file)
const filesMap = {}
data.files.forEach(file => {
const key = file.url + file.sha512 + file.size
filesMap[key] = file
})
data.files = Object.values(filesMap)
const newYml = yaml.dump(data, { lineWidth: -1 })
fs.writeFileSync(path, newYml, 'utf8')
}
const uploadFile = async () => {
try {
const platform = process.platform
if (!configList[platform]) {
console.warn('platform not supported!', platform)
return
}
let versionFileHasUploaded = true
for (const [index, config] of configList[platform].entries()) {
const fileName = `${config.appNameWithPrefix}${VERSION}${config.arch}${config.ext}`
const distPath = path.join(__dirname, '../dist_electron')
const versionFileName = config['version-file']
console.log('[PicList Dist] Uploading...', fileName, `${index + 1}/${configList[platform].length}`)
const fileStream = fs.createReadStream(path.join(distPath, fileName))
const client = new S3Client.S3Client(options)
const parallelUploads3 = new Upload.Upload({
client,
params: {
Bucket: BUCKET,
Key: `${FILE_PATH}${fileName}`,
Body: fileStream,
ContentType: 'application/octet-stream',
Metadata: {
description: 'uploaded by PicList',
},
},
})
parallelUploads3.on('httpUploadProgress', progress => {
const progressBar = Math.round((progress.loaded / progress.total) * 100)
process.stdout.write(`\r${progressBar}% ${fileName}`)
})
console.log('\n')
await parallelUploads3.done()
console.log(`${fileName} uploaded!`)
if (!versionFileHasUploaded) {
console.log('[PicList Version File] Uploading...', versionFileName)
let versionFilePath
if (platform === 'win32') {
versionFilePath = path.join(distPath, 'latest.yml')
} else if (platform === 'darwin') {
versionFilePath = path.join(distPath, 'latest-mac.yml')
} else {
versionFilePath = path.join(distPath, 'latest-linux.yml')
}
removeDupField(versionFilePath)
const versionFileStream = fs.createReadStream(versionFilePath)
const uploadVersionFileToRoot = new Upload.Upload({
client,
params: {
Bucket: BUCKET,
Key: `${versionFileName}`,
Body: versionFileStream,
ContentType: mime.getType(versionFileName),
Metadata: {
description: 'uploaded by PicList',
},
},
})
console.log('\nUploading version file to root...')
await uploadVersionFileToRoot.done()
console.log(`${versionFileName} uploaded!`)
versionFileStream.close()
const versionFileStream2 = fs.createReadStream(versionFilePath)
const uploadVersionFileToLatest = new Upload.Upload({
client,
params: {
Bucket: BUCKET,
Key: `${FILE_PATH}${versionFileName}`,
Body: versionFileStream2,
ContentType: mime.getType(versionFileName),
Metadata: {
description: 'uploaded by PicList',
},
},
})
console.log('\nUploading version file to latest...')
await uploadVersionFileToLatest.done()
console.log(`${versionFileName} uploaded!`)
versionFileStream2.close()
versionFileHasUploaded = true
}
}
} catch (err) {
console.error(err)
}
}
uploadFile()

View File

@@ -3,7 +3,7 @@ import { fileURLToPath } from 'node:url'
import { I18n, ObjectAdapter } from '@piclist/i18n' import { I18n, ObjectAdapter } from '@piclist/i18n'
import fs from 'fs-extra' import fs from 'fs-extra'
import yaml from 'js-yaml' import yaml from 'yaml'
const dirname = path.dirname(fileURLToPath(import.meta.url)) const dirname = path.dirname(fileURLToPath(import.meta.url))
@@ -54,7 +54,7 @@ class I18nManager {
} }
try { try {
const localesString = fs.readFileSync(localesPath, 'utf8') 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) this.localesMap.set(lang, locales)
return locales return locales
} catch (e) { } catch (e) {
@@ -62,7 +62,7 @@ class I18nManager {
// if error, use default language // if error, use default language
localesPath = path.join(this.builtinI18nFolder, `${this.defaultLanguage}.yml`) localesPath = path.join(this.builtinI18nFolder, `${this.defaultLanguage}.yml`)
const localesString = fs.readFileSync(localesPath, 'utf8') 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) this.localesMap.set(lang, locales)
return locales return locales
} }

View File

@@ -4,7 +4,7 @@ import { fileURLToPath } from 'node:url'
import { dbPathChecker } from '@core/datastore/dbChecker' import { dbPathChecker } from '@core/datastore/dbChecker'
import fs from 'fs-extra' import fs from 'fs-extra'
import yaml from 'js-yaml' import yaml from 'yaml'
import { i18nManager } from '~/i18n' import { i18nManager } from '~/i18n'
@@ -116,7 +116,7 @@ function resolveOtherI18nFiles() {
const i18nFilePath = path.join(i18nFolder, item.name) const i18nFilePath = path.join(i18nFolder, item.name)
const i18nFile = fs.readFileSync(i18nFilePath, 'utf8') const i18nFile = fs.readFileSync(i18nFilePath, 'utf8')
try { 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) { if (i18nFileObj?.LANG_DISPLAY_LABEL) {
i18nManager.addI18nFile(item.name.replace('.yml', ''), i18nFileObj.LANG_DISPLAY_LABEL) i18nManager.addI18nFile(item.name.replace('.yml', ''), i18nFileObj.LANG_DISPLAY_LABEL)
} }

View File

@@ -3,9 +3,9 @@ import path from 'node:path'
import { clipboard, contextBridge, ipcRenderer, IpcRendererEvent, webFrame, webUtils } from 'electron' import { clipboard, contextBridge, ipcRenderer, IpcRendererEvent, webFrame, webUtils } from 'electron'
import fs from 'fs-extra' import fs from 'fs-extra'
import yaml from 'js-yaml'
import mime from 'mime' import mime from 'mime'
import { isReactive, isRef, toRaw, unref } from 'vue' import { isReactive, isRef, toRaw, unref } from 'vue'
import yaml from 'yaml'
export const getRawData = (args: any): any => { export const getRawData = (args: any): any => {
if (isRef(args)) return unref(args) if (isRef(args)) return unref(args)
@@ -90,7 +90,7 @@ try {
createHash: crypto.createHash, createHash: crypto.createHash,
}, },
yaml: { yaml: {
load: yaml.load, parse: yaml.parseDocument,
}, },
mime: { mime: {
lookup: mime.getType.bind(mime), lookup: mime.getType.bind(mime),

View File

@@ -1136,7 +1136,7 @@
<div class="version-card latest" :class="{ 'has-update': needUpdate }"> <div class="version-card latest" :class="{ 'has-update': needUpdate }">
<div class="version-card-label">{{ t('pages.settings.update.newestVersion') }}</div> <div class="version-card-label">{{ t('pages.settings.update.newestVersion') }}</div>
<div class="version-card-value"> <div class="version-card-value">
{{ latestVersion ? `v${latestVersion}` : t('pages.settings.update.getting') }} {{ latestVersion ? `${latestVersion}` : t('pages.settings.update.getting') }}
</div> </div>
</div> </div>
</div> </div>

View File

@@ -7,6 +7,8 @@ export const getLatestVersion = async (): Promise<string> => {
throw new Error(`HTTP error! status: ${response.status}`) throw new Error(`HTTP error! status: ${response.status}`)
} }
const normalList = await response.json() const normalList = await response.json()
console.log('Fetched latest version info: ', normalList)
console.log('Latest version is: ', normalList[0].name)
return normalList[0].name return normalList[0].name
} catch (err) { } catch (err) {
console.error('Error fetching latest version: ', 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}`) throw new Error(`HTTP error! status: ${response.status}`)
} }
const data = await response.text() 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 return r.version
} catch (err) { } catch (err) {
console.error('Error fetching backup latest version: ', err) console.error('Error fetching backup latest version: ', err)

View File

@@ -5,9 +5,9 @@ import path from 'node:path'
import { clipboard } from 'electron' import { clipboard } from 'electron'
import fs from 'fs-extra' import fs from 'fs-extra'
import yaml from 'js-yaml'
import mime from 'mime' import mime from 'mime'
import { VNode } from 'vue' import { VNode } from 'vue'
import yaml from 'yaml'
declare global { declare global {
export namespace JSX { export namespace JSX {
@@ -53,7 +53,7 @@ declare global {
} }
yaml: { yaml: {
load: typeof yaml.load parse: typeof yaml.parseDocument
} }
mime: { mime: {
lookup: typeof mime.getType lookup: typeof mime.getType

View File

@@ -12379,6 +12379,11 @@ yaml@^2.0.0:
resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.8.0.tgz#15f8c9866211bdc2d3781a0890e44d4fa1a5fff6" resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.8.0.tgz#15f8c9866211bdc2d3781a0890e44d4fa1a5fff6"
integrity sha512-4lLa/EcQCB0cJkyts+FpIRx5G/llPxfP6VQU5KByHEhLxY3IJCH0f0Hy1MHI8sClTvsIb8qwRJ6R/ZdlDJ/leQ== integrity sha512-4lLa/EcQCB0cJkyts+FpIRx5G/llPxfP6VQU5KByHEhLxY3IJCH0f0Hy1MHI8sClTvsIb8qwRJ6R/ZdlDJ/leQ==
yaml@^2.8.2:
version "2.8.2"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.8.2.tgz#5694f25eca0ce9c3e7a9d9e00ce0ddabbd9e35c5"
integrity sha512-mplynKqc1C2hTVYxd0PU2xQAc22TI1vShAYGksCCfxbn/dFwnHTNi1bvYsBTkhdUNtGIf5xNOg938rrSSYvS9A==
yargs-parser@^21.0.0: yargs-parser@^21.0.0:
version "21.0.0" version "21.0.0"
resolved "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.0.0.tgz#a485d3966be4317426dd56bdb6a30131b281dc55" resolved "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.0.0.tgz#a485d3966be4317426dd56bdb6a30131b281dc55"