mirror of
https://github.com/pompurin404/mihomo-party.git
synced 2024-11-16 11:42:19 +08:00
support proxy for substore profile
Some checks are pending
Build / windows (arm64) (push) Waiting to run
Build / windows (ia32) (push) Waiting to run
Build / windows (x64) (push) Waiting to run
Build / windows7 (ia32) (push) Waiting to run
Build / windows7 (x64) (push) Waiting to run
Build / linux (arm64) (push) Waiting to run
Build / linux (x64) (push) Waiting to run
Build / macos (arm64) (push) Waiting to run
Build / macos (x64) (push) Waiting to run
Build / updater (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party) (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party-bin) (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party-electron) (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party-electron-bin) (push) Blocked by required conditions
Build / aur-git-updater (push) Waiting to run
Build / Update WinGet Package (push) Blocked by required conditions
Build / Update Homebrew cask (push) Blocked by required conditions
Some checks are pending
Build / windows (arm64) (push) Waiting to run
Build / windows (ia32) (push) Waiting to run
Build / windows (x64) (push) Waiting to run
Build / windows7 (ia32) (push) Waiting to run
Build / windows7 (x64) (push) Waiting to run
Build / linux (arm64) (push) Waiting to run
Build / linux (x64) (push) Waiting to run
Build / macos (arm64) (push) Waiting to run
Build / macos (x64) (push) Waiting to run
Build / updater (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party) (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party-bin) (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party-electron) (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party-electron-bin) (push) Blocked by required conditions
Build / aur-git-updater (push) Waiting to run
Build / Update WinGet Package (push) Blocked by required conditions
Build / Update Homebrew cask (push) Blocked by required conditions
This commit is contained in:
parent
e8f4c44d07
commit
ba92a26a1e
12
changelog.md
12
changelog.md
|
@ -1,13 +1,3 @@
|
||||||
### New Features
|
### New Features
|
||||||
|
|
||||||
- 设置悬浮窗标题为 `Mihomo Party Floating`,以区分主窗口,Wayland 用户可以单独为其设置窗口规则以解决置顶失效的问题
|
- 支持通过代理拉取内置 SubStore 订阅(仅对通过订阅页面Sub-Store图标新导入的订阅有效)
|
||||||
- 提高悬浮窗置顶等级,避免被其他窗口遮挡
|
|
||||||
- 悬浮窗增加边框阴影效果,避免与背景色相近时无法分辨
|
|
||||||
- 优化订阅卡片信息显示布局
|
|
||||||
- 允许在开启悬浮窗的情况下禁用托盘图标
|
|
||||||
- 再次点击悬浮窗按钮关闭窗口
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
- 修复开启轻量模式后 TrafficMonitor 重复启动的问题
|
|
||||||
- 修复 悬浮窗置顶失效的问题
|
|
||||||
|
|
|
@ -5,9 +5,10 @@ import { readFile, rm, writeFile } from 'fs/promises'
|
||||||
import { restartCore } from '../core/manager'
|
import { restartCore } from '../core/manager'
|
||||||
import { getAppConfig } from './app'
|
import { getAppConfig } from './app'
|
||||||
import { existsSync } from 'fs'
|
import { existsSync } from 'fs'
|
||||||
import axios from 'axios'
|
import axios, { AxiosResponse } from 'axios'
|
||||||
import yaml from 'yaml'
|
import yaml from 'yaml'
|
||||||
import { defaultProfile } from '../utils/template'
|
import { defaultProfile } from '../utils/template'
|
||||||
|
import { subStorePort } from '../resolve/server'
|
||||||
|
|
||||||
let profileConfig: IProfileConfig // profile.yaml
|
let profileConfig: IProfileConfig // profile.yaml
|
||||||
|
|
||||||
|
@ -105,6 +106,7 @@ export async function createProfile(item: Partial<IProfileItem>): Promise<IProfi
|
||||||
name: item.name || (item.type === 'remote' ? 'Remote File' : 'Local File'),
|
name: item.name || (item.type === 'remote' ? 'Remote File' : 'Local File'),
|
||||||
type: item.type,
|
type: item.type,
|
||||||
url: item.url,
|
url: item.url,
|
||||||
|
substore: item.substore || false,
|
||||||
interval: item.interval || 0,
|
interval: item.interval || 0,
|
||||||
override: item.override || [],
|
override: item.override || [],
|
||||||
useProxy: item.useProxy || false,
|
useProxy: item.useProxy || false,
|
||||||
|
@ -115,7 +117,22 @@ export async function createProfile(item: Partial<IProfileItem>): Promise<IProfi
|
||||||
const { userAgent } = await getAppConfig()
|
const { userAgent } = await getAppConfig()
|
||||||
const { 'mixed-port': mixedPort = 7890 } = await getControledMihomoConfig()
|
const { 'mixed-port': mixedPort = 7890 } = await getControledMihomoConfig()
|
||||||
if (!item.url) throw new Error('Empty URL')
|
if (!item.url) throw new Error('Empty URL')
|
||||||
const res = await axios.get(item.url, {
|
let res: AxiosResponse
|
||||||
|
if (newItem.substore) {
|
||||||
|
const urlObj = new URL(`http://127.0.0.1:${subStorePort}${item.url}`)
|
||||||
|
urlObj.searchParams.set('target', 'ClashMeta')
|
||||||
|
if (newItem.useProxy) {
|
||||||
|
urlObj.searchParams.set('proxy', `http://127.0.0.1:${mixedPort}`)
|
||||||
|
} else {
|
||||||
|
urlObj.searchParams.delete('proxy')
|
||||||
|
}
|
||||||
|
res = await axios.get(urlObj.toString(), {
|
||||||
|
headers: {
|
||||||
|
'User-Agent': userAgent || 'clash.meta'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
res = await axios.get(item.url, {
|
||||||
proxy: newItem.useProxy
|
proxy: newItem.useProxy
|
||||||
? {
|
? {
|
||||||
protocol: 'http',
|
protocol: 'http',
|
||||||
|
@ -127,6 +144,8 @@ export async function createProfile(item: Partial<IProfileItem>): Promise<IProfi
|
||||||
'User-Agent': userAgent || 'clash.meta'
|
'User-Agent': userAgent || 'clash.meta'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const data = res.data
|
const data = res.data
|
||||||
const headers = res.headers
|
const headers = res.headers
|
||||||
if (headers['content-disposition'] && newItem.name === 'Remote File') {
|
if (headers['content-disposition'] && newItem.name === 'Remote File') {
|
||||||
|
|
|
@ -25,7 +25,7 @@ const FloatingApp: React.FC = () => {
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
return (
|
return (
|
||||||
<div className="app-drag h-[100vh] w-[100vw]">
|
<div className="app-drag h-[100vh] w-[100vw] overflow-hidden">
|
||||||
<div className="floating-bg border-1 border-divider flex rounded-full bg-content1 h-[calc(100%-2px)] w-[calc(100%-2px)]">
|
<div className="floating-bg border-1 border-divider flex rounded-full bg-content1 h-[calc(100%-2px)] w-[calc(100%-2px)]">
|
||||||
<div className="flex justify-center items-center h-[100%] aspect-square">
|
<div className="flex justify-center items-center h-[100%] aspect-square">
|
||||||
<div
|
<div
|
||||||
|
|
|
@ -18,6 +18,7 @@ import { useOverrideConfig } from '@renderer/hooks/use-override-config'
|
||||||
import { restartCore } from '@renderer/utils/ipc'
|
import { restartCore } from '@renderer/utils/ipc'
|
||||||
import { MdDeleteForever } from 'react-icons/md'
|
import { MdDeleteForever } from 'react-icons/md'
|
||||||
import { FaPlus } from 'react-icons/fa6'
|
import { FaPlus } from 'react-icons/fa6'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
item: IProfileItem
|
item: IProfileItem
|
||||||
updateProfileItem: (item: IProfileItem) => Promise<void>
|
updateProfileItem: (item: IProfileItem) => Promise<void>
|
||||||
|
|
|
@ -13,13 +13,7 @@ import BasePage from '@renderer/components/base/base-page'
|
||||||
import ProfileItem from '@renderer/components/profiles/profile-item'
|
import ProfileItem from '@renderer/components/profiles/profile-item'
|
||||||
import { useProfileConfig } from '@renderer/hooks/use-profile-config'
|
import { useProfileConfig } from '@renderer/hooks/use-profile-config'
|
||||||
import { useAppConfig } from '@renderer/hooks/use-app-config'
|
import { useAppConfig } from '@renderer/hooks/use-app-config'
|
||||||
import {
|
import { getFilePath, readTextFile, subStoreCollections, subStoreSubs } from '@renderer/utils/ipc'
|
||||||
getFilePath,
|
|
||||||
readTextFile,
|
|
||||||
subStoreCollections,
|
|
||||||
subStorePort,
|
|
||||||
subStoreSubs
|
|
||||||
} from '@renderer/utils/ipc'
|
|
||||||
import { ReactNode, useEffect, useMemo, useRef, useState } from 'react'
|
import { ReactNode, useEffect, useMemo, useRef, useState } from 'react'
|
||||||
import { MdContentPaste } from 'react-icons/md'
|
import { MdContentPaste } from 'react-icons/md'
|
||||||
import {
|
import {
|
||||||
|
@ -286,16 +280,16 @@ const Profiles: React.FC = () => {
|
||||||
} else if (key.toString().startsWith('sub-')) {
|
} else if (key.toString().startsWith('sub-')) {
|
||||||
setSubStoreImporting(true)
|
setSubStoreImporting(true)
|
||||||
try {
|
try {
|
||||||
const port = await subStorePort()
|
|
||||||
const sub = subs.find(
|
const sub = subs.find(
|
||||||
(sub) => sub.name === key.toString().replace('sub-', '')
|
(sub) => sub.name === key.toString().replace('sub-', '')
|
||||||
)
|
)
|
||||||
await addProfileItem({
|
await addProfileItem({
|
||||||
name: sub?.displayName || sub?.name || '',
|
name: sub?.displayName || sub?.name || '',
|
||||||
|
substore: !useCustomSubStore,
|
||||||
type: 'remote',
|
type: 'remote',
|
||||||
url: useCustomSubStore
|
url: useCustomSubStore
|
||||||
? `${customSubStoreUrl}/download/${key.toString().replace('sub-', '')}?target=ClashMeta`
|
? `${customSubStoreUrl}/download/${key.toString().replace('sub-', '')}?target=ClashMeta`
|
||||||
: `http://127.0.0.1:${port}/download/${key.toString().replace('sub-', '')}?target=ClashMeta`,
|
: `/download/${key.toString().replace('sub-', '')}`,
|
||||||
useProxy
|
useProxy
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -306,7 +300,6 @@ const Profiles: React.FC = () => {
|
||||||
} else if (key.toString().startsWith('collection-')) {
|
} else if (key.toString().startsWith('collection-')) {
|
||||||
setSubStoreImporting(true)
|
setSubStoreImporting(true)
|
||||||
try {
|
try {
|
||||||
const port = await subStorePort()
|
|
||||||
const collection = collections.find(
|
const collection = collections.find(
|
||||||
(collection) =>
|
(collection) =>
|
||||||
collection.name === key.toString().replace('collection-', '')
|
collection.name === key.toString().replace('collection-', '')
|
||||||
|
@ -314,9 +307,10 @@ const Profiles: React.FC = () => {
|
||||||
await addProfileItem({
|
await addProfileItem({
|
||||||
name: collection?.displayName || collection?.name || '',
|
name: collection?.displayName || collection?.name || '',
|
||||||
type: 'remote',
|
type: 'remote',
|
||||||
|
substore: !useCustomSubStore,
|
||||||
url: useCustomSubStore
|
url: useCustomSubStore
|
||||||
? `${customSubStoreUrl}/download/collection/${key.toString().replace('collection-', '')}?target=ClashMeta`
|
? `${customSubStoreUrl}/download/collection/${key.toString().replace('collection-', '')}?target=ClashMeta`
|
||||||
: `http://127.0.0.1:${port}/download/collection/${key.toString().replace('collection-', '')}?target=ClashMeta`,
|
: `/download/collection/${key.toString().replace('collection-', '')}`,
|
||||||
useProxy
|
useProxy
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
1
src/shared/types.d.ts
vendored
1
src/shared/types.d.ts
vendored
|
@ -426,6 +426,7 @@ interface IProfileItem {
|
||||||
override?: string[]
|
override?: string[]
|
||||||
useProxy?: boolean
|
useProxy?: boolean
|
||||||
extra?: ISubscriptionUserInfo
|
extra?: ISubscriptionUserInfo
|
||||||
|
substore?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ISubStoreSub {
|
interface ISubStoreSub {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user