mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-08-07 22:44:10 +08:00
🐛 Fix(custom): fix resources path
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import path from 'node:path'
|
import path from 'node:path'
|
||||||
|
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'
|
||||||
@@ -7,6 +8,8 @@ import yaml from 'js-yaml'
|
|||||||
import type { ILocales, ILocalesKey } from '#/types/i18n'
|
import type { ILocales, ILocalesKey } from '#/types/i18n'
|
||||||
import type { II18nItem, IStringKeyMap } from '#/types/types'
|
import type { II18nItem, IStringKeyMap } from '#/types/types'
|
||||||
|
|
||||||
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||||
|
|
||||||
const builtinI18nList: II18nItem[] = [
|
const builtinI18nList: II18nItem[] = [
|
||||||
{
|
{
|
||||||
label: '简体中文',
|
label: '简体中文',
|
||||||
@@ -23,7 +26,7 @@ const builtinI18nList: II18nItem[] = [
|
|||||||
]
|
]
|
||||||
class I18nManager {
|
class I18nManager {
|
||||||
private i18n: I18n | null = null
|
private i18n: I18n | null = null
|
||||||
private builtinI18nFolder = path.join('./resources', 'i18n')
|
private builtinI18nFolder = path.join(__dirname, '../../resources', 'i18n')
|
||||||
private outterI18nFolder = ''
|
private outterI18nFolder = ''
|
||||||
private localesMap: Map<string, ILocales> = new Map()
|
private localesMap: Map<string, ILocales> = new Map()
|
||||||
private currentLanguage: string = 'zh-CN'
|
private currentLanguage: string = 'zh-CN'
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import os from 'node:os'
|
import os from 'node:os'
|
||||||
import path from 'node:path'
|
import path from 'node:path'
|
||||||
|
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'
|
||||||
@@ -10,6 +11,7 @@ import { i18nManager } from '~/i18n'
|
|||||||
|
|
||||||
const configPath = dbPathChecker()
|
const configPath = dbPathChecker()
|
||||||
const CONFIG_DIR = path.dirname(configPath)
|
const CONFIG_DIR = path.dirname(configPath)
|
||||||
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||||
|
|
||||||
function beforeOpen () {
|
function beforeOpen () {
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
@@ -46,7 +48,7 @@ function copyFileOutsideOfElectronAsar (sourceInAsarArchive: string, destOutside
|
|||||||
function resolveMacWorkFlow () {
|
function resolveMacWorkFlow () {
|
||||||
const dest = `${os.homedir()}/Library/Services/Upload pictures with PicList.workflow`
|
const dest = `${os.homedir()}/Library/Services/Upload pictures with PicList.workflow`
|
||||||
try {
|
try {
|
||||||
copyFileOutsideOfElectronAsar(path.join('./resources', 'Upload pictures with PicList.workflow'), dest)
|
copyFileOutsideOfElectronAsar(path.join(__dirname, '../../resources', 'Upload pictures with PicList.workflow'), dest)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
}
|
}
|
||||||
@@ -86,7 +88,7 @@ function resolveClipboardImageGenerator () {
|
|||||||
|
|
||||||
return files.map(item => {
|
return files.map(item => {
|
||||||
return {
|
return {
|
||||||
origin: path.join('./resources', item),
|
origin: path.join(__dirname, '../../resources', item),
|
||||||
dest: path.join(CONFIG_DIR, item)
|
dest: path.join(CONFIG_DIR, item)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user