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
|
||||
|
||||
- 设置悬浮窗标题为 `Mihomo Party Floating`,以区分主窗口,Wayland 用户可以单独为其设置窗口规则以解决置顶失效的问题
|
||||
- 提高悬浮窗置顶等级,避免被其他窗口遮挡
|
||||
- 悬浮窗增加边框阴影效果,避免与背景色相近时无法分辨
|
||||
- 优化订阅卡片信息显示布局
|
||||
- 允许在开启悬浮窗的情况下禁用托盘图标
|
||||
- 再次点击悬浮窗按钮关闭窗口
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- 修复开启轻量模式后 TrafficMonitor 重复启动的问题
|
||||
- 修复 悬浮窗置顶失效的问题
|
||||
- 支持通过代理拉取内置 SubStore 订阅(仅对通过订阅页面Sub-Store图标新导入的订阅有效)
|
||||
|
|
|
@ -5,9 +5,10 @@ import { readFile, rm, writeFile } from 'fs/promises'
|
|||
import { restartCore } from '../core/manager'
|
||||
import { getAppConfig } from './app'
|
||||
import { existsSync } from 'fs'
|
||||
import axios from 'axios'
|
||||
import axios, { AxiosResponse } from 'axios'
|
||||
import yaml from 'yaml'
|
||||
import { defaultProfile } from '../utils/template'
|
||||
import { subStorePort } from '../resolve/server'
|
||||
|
||||
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'),
|
||||
type: item.type,
|
||||
url: item.url,
|
||||
substore: item.substore || false,
|
||||
interval: item.interval || 0,
|
||||
override: item.override || [],
|
||||
useProxy: item.useProxy || false,
|
||||
|
@ -115,18 +117,35 @@ export async function createProfile(item: Partial<IProfileItem>): Promise<IProfi
|
|||
const { userAgent } = await getAppConfig()
|
||||
const { 'mixed-port': mixedPort = 7890 } = await getControledMihomoConfig()
|
||||
if (!item.url) throw new Error('Empty URL')
|
||||
const res = await axios.get(item.url, {
|
||||
proxy: newItem.useProxy
|
||||
? {
|
||||
protocol: 'http',
|
||||
host: '127.0.0.1',
|
||||
port: mixedPort
|
||||
}
|
||||
: false,
|
||||
headers: {
|
||||
'User-Agent': userAgent || 'clash.meta'
|
||||
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
|
||||
? {
|
||||
protocol: 'http',
|
||||
host: '127.0.0.1',
|
||||
port: mixedPort
|
||||
}
|
||||
: false,
|
||||
headers: {
|
||||
'User-Agent': userAgent || 'clash.meta'
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const data = res.data
|
||||
const headers = res.headers
|
||||
if (headers['content-disposition'] && newItem.name === 'Remote File') {
|
||||
|
|
|
@ -25,7 +25,7 @@ const FloatingApp: React.FC = () => {
|
|||
}
|
||||
}, [])
|
||||
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="flex justify-center items-center h-[100%] aspect-square">
|
||||
<div
|
||||
|
|
|
@ -18,6 +18,7 @@ import { useOverrideConfig } from '@renderer/hooks/use-override-config'
|
|||
import { restartCore } from '@renderer/utils/ipc'
|
||||
import { MdDeleteForever } from 'react-icons/md'
|
||||
import { FaPlus } from 'react-icons/fa6'
|
||||
|
||||
interface Props {
|
||||
item: IProfileItem
|
||||
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 { useProfileConfig } from '@renderer/hooks/use-profile-config'
|
||||
import { useAppConfig } from '@renderer/hooks/use-app-config'
|
||||
import {
|
||||
getFilePath,
|
||||
readTextFile,
|
||||
subStoreCollections,
|
||||
subStorePort,
|
||||
subStoreSubs
|
||||
} from '@renderer/utils/ipc'
|
||||
import { getFilePath, readTextFile, subStoreCollections, subStoreSubs } from '@renderer/utils/ipc'
|
||||
import { ReactNode, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { MdContentPaste } from 'react-icons/md'
|
||||
import {
|
||||
|
@ -286,16 +280,16 @@ const Profiles: React.FC = () => {
|
|||
} else if (key.toString().startsWith('sub-')) {
|
||||
setSubStoreImporting(true)
|
||||
try {
|
||||
const port = await subStorePort()
|
||||
const sub = subs.find(
|
||||
(sub) => sub.name === key.toString().replace('sub-', '')
|
||||
)
|
||||
await addProfileItem({
|
||||
name: sub?.displayName || sub?.name || '',
|
||||
substore: !useCustomSubStore,
|
||||
type: 'remote',
|
||||
url: useCustomSubStore
|
||||
? `${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
|
||||
})
|
||||
} catch (e) {
|
||||
|
@ -306,7 +300,6 @@ const Profiles: React.FC = () => {
|
|||
} else if (key.toString().startsWith('collection-')) {
|
||||
setSubStoreImporting(true)
|
||||
try {
|
||||
const port = await subStorePort()
|
||||
const collection = collections.find(
|
||||
(collection) =>
|
||||
collection.name === key.toString().replace('collection-', '')
|
||||
|
@ -314,9 +307,10 @@ const Profiles: React.FC = () => {
|
|||
await addProfileItem({
|
||||
name: collection?.displayName || collection?.name || '',
|
||||
type: 'remote',
|
||||
substore: !useCustomSubStore,
|
||||
url: useCustomSubStore
|
||||
? `${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
|
||||
})
|
||||
} catch (e) {
|
||||
|
|
1
src/shared/types.d.ts
vendored
1
src/shared/types.d.ts
vendored
|
@ -426,6 +426,7 @@ interface IProfileItem {
|
|||
override?: string[]
|
||||
useProxy?: boolean
|
||||
extra?: ISubscriptionUserInfo
|
||||
substore?: boolean
|
||||
}
|
||||
|
||||
interface ISubStoreSub {
|
||||
|
|
Loading…
Reference in New Issue
Block a user