mirror of
https://github.com/pompurin404/mihomo-party.git
synced 2024-11-16 03:32:17 +08:00
fix drop file
This commit is contained in:
parent
2afa0cf092
commit
acbc34370a
|
@ -7,3 +7,5 @@
|
|||
- 修复部分用户无法打开Sub-Store页面的问题
|
||||
- 修复Sub-Store无法复制的问题
|
||||
- 修复MacOS路径有空格导致内核启动失败的问题
|
||||
- 修复导入本地订阅失败的问题
|
||||
- 修复Linux无法启动的问题
|
||||
|
|
14
package.json
14
package.json
|
@ -31,7 +31,7 @@
|
|||
"express": "^4.19.2",
|
||||
"webdav": "^5.7.1",
|
||||
"ws": "^8.18.0",
|
||||
"yaml": "^2.5.0"
|
||||
"yaml": "^2.5.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@dnd-kit/core": "^6.1.0",
|
||||
|
@ -43,7 +43,7 @@
|
|||
"@nextui-org/react": "^2.4.6",
|
||||
"@types/adm-zip": "^0.5.5",
|
||||
"@types/express": "^4.17.21",
|
||||
"@types/node": "^22.5.2",
|
||||
"@types/node": "^22.5.4",
|
||||
"@types/pubsub-js": "^1.8.6",
|
||||
"@types/react": "^18.3.5",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
|
@ -51,18 +51,18 @@
|
|||
"@vitejs/plugin-react": "^4.3.1",
|
||||
"apexcharts": "^3.53.0",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"electron": "^32.0.1",
|
||||
"electron": "^32.0.2",
|
||||
"electron-builder": "^25.0.5",
|
||||
"electron-vite": "^2.3.0",
|
||||
"electron-window-state": "^5.0.3",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-plugin-react": "^7.35.0",
|
||||
"framer-motion": "^11.3.31",
|
||||
"eslint-plugin-react": "^7.35.2",
|
||||
"framer-motion": "^11.5.2",
|
||||
"meta-json-schema": "^1.18.7",
|
||||
"monaco-yaml": "^5.2.2",
|
||||
"nanoid": "^5.0.7",
|
||||
"next-themes": "^0.3.0",
|
||||
"postcss": "^8.4.44",
|
||||
"postcss": "^8.4.45",
|
||||
"prettier": "^3.3.3",
|
||||
"pubsub-js": "^1.9.4",
|
||||
"react": "^18.3.1",
|
||||
|
@ -80,7 +80,7 @@
|
|||
"tsx": "^4.19.0",
|
||||
"types-pac": "^1.0.2",
|
||||
"typescript": "^5.5.4",
|
||||
"vite": "^5.4.2",
|
||||
"vite": "^5.4.3",
|
||||
"vite-plugin-monaco-editor": "^1.1.0"
|
||||
}
|
||||
}
|
||||
|
|
728
pnpm-lock.yaml
728
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
@ -2,13 +2,14 @@ import { readFile, writeFile } from 'fs/promises'
|
|||
import { appConfigPath } from '../utils/dirs'
|
||||
import yaml from 'yaml'
|
||||
import { deepMerge } from '../utils/merge'
|
||||
import { defaultConfig } from '../utils/template'
|
||||
|
||||
let appConfig: IAppConfig // config.yaml
|
||||
|
||||
export async function getAppConfig(force = false): Promise<IAppConfig> {
|
||||
if (force || !appConfig) {
|
||||
const data = await readFile(appConfigPath(), 'utf-8')
|
||||
appConfig = yaml.parse(data)
|
||||
appConfig = yaml.parse(data) || defaultConfig
|
||||
}
|
||||
return appConfig
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ let controledMihomoConfig: Partial<IMihomoConfig> // mihomo.yaml
|
|||
export async function getControledMihomoConfig(force = false): Promise<Partial<IMihomoConfig>> {
|
||||
if (force || !controledMihomoConfig) {
|
||||
const data = await readFile(controledMihomoConfigPath(), 'utf-8')
|
||||
controledMihomoConfig = yaml.parse(data)
|
||||
controledMihomoConfig = yaml.parse(data) || defaultControledMihomoConfig
|
||||
}
|
||||
return controledMihomoConfig
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ let overrideConfig: IOverrideConfig // override.yaml
|
|||
export async function getOverrideConfig(force = false): Promise<IOverrideConfig> {
|
||||
if (force || !overrideConfig) {
|
||||
const data = await readFile(overrideConfigPath(), 'utf-8')
|
||||
overrideConfig = yaml.parse(data)
|
||||
overrideConfig = yaml.parse(data) || {}
|
||||
}
|
||||
return overrideConfig
|
||||
}
|
||||
|
|
|
@ -168,7 +168,7 @@ export async function setProfileStr(id: string, content: string): Promise<void>
|
|||
|
||||
export async function getProfile(id: string | undefined): Promise<IMihomoConfig> {
|
||||
const profile = await getProfileStr(id)
|
||||
return yaml.parse(profile)
|
||||
return yaml.parse(profile) || {}
|
||||
}
|
||||
|
||||
// attachment;filename=xxx.yaml; filename*=UTF-8''%xx%xx%xx
|
||||
|
|
|
@ -39,7 +39,7 @@ async function overrideProfile(
|
|||
profile = runOverrideScript(profile, content, item)
|
||||
break
|
||||
case 'yaml': {
|
||||
const patch = yaml.parse(content)
|
||||
const patch = yaml.parse(content) || {}
|
||||
profile = deepMerge(profile, patch)
|
||||
break
|
||||
}
|
||||
|
|
3
src/preload/index.d.ts
vendored
3
src/preload/index.d.ts
vendored
|
@ -1,8 +1,9 @@
|
|||
import { ElectronAPI } from '@electron-toolkit/preload'
|
||||
import { webUtils } from 'electron'
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
electron: ElectronAPI
|
||||
api: unknown
|
||||
api: { webUtils: typeof webUtils }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import { contextBridge } from 'electron'
|
||||
import { contextBridge, webUtils } from 'electron'
|
||||
import { electronAPI } from '@electron-toolkit/preload'
|
||||
|
||||
// Custom APIs for renderer
|
||||
const api = {}
|
||||
|
||||
const api = {
|
||||
webUtils: webUtils
|
||||
}
|
||||
// Use `contextBridge` APIs to expose Electron APIs to
|
||||
// renderer only if context isolation is enabled, otherwise
|
||||
// just add to the DOM global.
|
||||
|
|
|
@ -166,7 +166,8 @@ const Profiles: React.FC = () => {
|
|||
const file = event.dataTransfer.files[0]
|
||||
if (file.name.endsWith('.yml') || file.name.endsWith('.yaml')) {
|
||||
try {
|
||||
const content = await readTextFile(file.path)
|
||||
const path = window.api.webUtils.getPathForFile(file)
|
||||
const content = await readTextFile(path)
|
||||
await addProfileItem({ name: file.name, type: 'local', file: content })
|
||||
} catch (e) {
|
||||
alert(e)
|
||||
|
|
Loading…
Reference in New Issue
Block a user