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