🐛 Fix(custom): fix resources path

This commit is contained in:
Kuingsmile
2025-08-14 11:09:21 +08:00
parent 8102246e16
commit 74a3333a43
2 changed files with 8 additions and 3 deletions

View File

@@ -1,4 +1,5 @@
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { I18n, ObjectAdapter } from '@piclist/i18n'
import fs from 'fs-extra'
@@ -7,6 +8,8 @@ import yaml from 'js-yaml'
import type { ILocales, ILocalesKey } from '#/types/i18n'
import type { II18nItem, IStringKeyMap } from '#/types/types'
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const builtinI18nList: II18nItem[] = [
{
label: '简体中文',
@@ -23,7 +26,7 @@ const builtinI18nList: II18nItem[] = [
]
class I18nManager {
private i18n: I18n | null = null
private builtinI18nFolder = path.join('./resources', 'i18n')
private builtinI18nFolder = path.join(__dirname, '../../resources', 'i18n')
private outterI18nFolder = ''
private localesMap: Map<string, ILocales> = new Map()
private currentLanguage: string = 'zh-CN'

View File

@@ -1,5 +1,6 @@
import os from 'node:os'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { dbPathChecker } from '@core/datastore/dbChecker'
import fs from 'fs-extra'
@@ -10,6 +11,7 @@ import { i18nManager } from '~/i18n'
const configPath = dbPathChecker()
const CONFIG_DIR = path.dirname(configPath)
const __dirname = path.dirname(fileURLToPath(import.meta.url))
function beforeOpen () {
if (process.platform === 'darwin') {
@@ -46,7 +48,7 @@ function copyFileOutsideOfElectronAsar (sourceInAsarArchive: string, destOutside
function resolveMacWorkFlow () {
const dest = `${os.homedir()}/Library/Services/Upload pictures with PicList.workflow`
try {
copyFileOutsideOfElectronAsar(path.join('./resources', 'Upload pictures with PicList.workflow'), dest)
copyFileOutsideOfElectronAsar(path.join(__dirname, '../../resources', 'Upload pictures with PicList.workflow'), dest)
} catch (e) {
console.log(e)
}
@@ -86,7 +88,7 @@ function resolveClipboardImageGenerator () {
return files.map(item => {
return {
origin: path.join('./resources', item),
origin: path.join(__dirname, '../../resources', item),
dest: path.join(CONFIG_DIR, item)
}
})