mirror of
https://github.com/pompurin404/mihomo-party.git
synced 2024-11-16 03:32:17 +08:00
support switch profile display date
This commit is contained in:
parent
8d09bfb1a9
commit
d2c92eedd3
|
@ -4,10 +4,4 @@
|
||||||
|
|
||||||
### New Features
|
### New Features
|
||||||
|
|
||||||
- 修改应用在 macOS 和 Linux 下的显示名称为 `Mihomo Party`
|
- 允许切换订阅卡片显示过期时间还是更新时间
|
||||||
- 默认禁用外部控制端口
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
- 修复 TrafficMonitor 勾选内置网速显示后无法取消勾选的问题
|
|
||||||
- 修复 TrafficMonitor 显示宽度不正确的问题
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ import EditInfoModal from './edit-info-modal'
|
||||||
import { useSortable } from '@dnd-kit/sortable'
|
import { useSortable } from '@dnd-kit/sortable'
|
||||||
import { CSS } from '@dnd-kit/utilities'
|
import { CSS } from '@dnd-kit/utilities'
|
||||||
import { openFile } from '@renderer/utils/ipc'
|
import { openFile } from '@renderer/utils/ipc'
|
||||||
|
import { useAppConfig } from '@renderer/hooks/use-app-config'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
info: IProfileItem
|
info: IProfileItem
|
||||||
|
@ -51,6 +52,8 @@ const ProfileItem: React.FC<Props> = (props) => {
|
||||||
const extra = info?.extra
|
const extra = info?.extra
|
||||||
const usage = (extra?.upload ?? 0) + (extra?.download ?? 0)
|
const usage = (extra?.upload ?? 0) + (extra?.download ?? 0)
|
||||||
const total = extra?.total ?? 0
|
const total = extra?.total ?? 0
|
||||||
|
const { appConfig, patchAppConfig } = useAppConfig()
|
||||||
|
const { profileDisplayDate = 'expire' } = appConfig || {}
|
||||||
const [updating, setUpdating] = useState(false)
|
const [updating, setUpdating] = useState(false)
|
||||||
const [selecting, setSelecting] = useState(false)
|
const [selecting, setSelecting] = useState(false)
|
||||||
const [openInfoEditor, setOpenInfoEditor] = useState(false)
|
const [openInfoEditor, setOpenInfoEditor] = useState(false)
|
||||||
|
@ -171,7 +174,7 @@ const ProfileItem: React.FC<Props> = (props) => {
|
||||||
<Card
|
<Card
|
||||||
fullWidth
|
fullWidth
|
||||||
isPressable
|
isPressable
|
||||||
onPress={() => {
|
onClick={() => {
|
||||||
if (disableSelect) return
|
if (disableSelect) return
|
||||||
setSelecting(true)
|
setSelecting(true)
|
||||||
onClick().finally(() => {
|
onClick().finally(() => {
|
||||||
|
@ -240,12 +243,22 @@ const ProfileItem: React.FC<Props> = (props) => {
|
||||||
</div>
|
</div>
|
||||||
{info.type === 'remote' && extra && (
|
{info.type === 'remote' && extra && (
|
||||||
<div
|
<div
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation()
|
||||||
|
patchAppConfig({
|
||||||
|
profileDisplayDate: profileDisplayDate === 'expire' ? 'update' : 'expire'
|
||||||
|
})
|
||||||
|
}}
|
||||||
className={`mt-2 flex justify-between ${isCurrent ? 'text-primary-foreground' : 'text-foreground'}`}
|
className={`mt-2 flex justify-between ${isCurrent ? 'text-primary-foreground' : 'text-foreground'}`}
|
||||||
>
|
>
|
||||||
<small>{`${calcTraffic(usage)}/${calcTraffic(total)}`}</small>
|
<small>{`${calcTraffic(usage)}/${calcTraffic(total)}`}</small>
|
||||||
|
{profileDisplayDate === 'expire' ? (
|
||||||
<small>
|
<small>
|
||||||
{extra.expire ? dayjs.unix(extra.expire).format('YYYY-MM-DD') : '长期有效'}
|
{extra.expire ? dayjs.unix(extra.expire).format('YYYY-MM-DD') : '长期有效'}
|
||||||
</small>
|
</small>
|
||||||
|
) : (
|
||||||
|
<small>{dayjs(info.updated).fromNow()}</small>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{info.type === 'local' && (
|
{info.type === 'local' && (
|
||||||
|
|
|
@ -19,7 +19,7 @@ dayjs.locale('zh-cn')
|
||||||
|
|
||||||
const ProfileCard: React.FC = () => {
|
const ProfileCard: React.FC = () => {
|
||||||
const { appConfig } = useAppConfig()
|
const { appConfig } = useAppConfig()
|
||||||
const { profileCardStatus = 'col-span-2' } = appConfig || {}
|
const { profileCardStatus = 'col-span-2', profileDisplayDate = 'expire' } = appConfig || {}
|
||||||
const location = useLocation()
|
const location = useLocation()
|
||||||
const match = location.pathname.includes('/profiles')
|
const match = location.pathname.includes('/profiles')
|
||||||
const [updating, setUpdating] = useState(false)
|
const [updating, setUpdating] = useState(false)
|
||||||
|
@ -121,9 +121,13 @@ const ProfileCard: React.FC = () => {
|
||||||
className={`mt-2 flex justify-between ${match ? 'text-primary-foreground' : 'text-foreground'} `}
|
className={`mt-2 flex justify-between ${match ? 'text-primary-foreground' : 'text-foreground'} `}
|
||||||
>
|
>
|
||||||
<small>{`${calcTraffic(usage)}/${calcTraffic(total)}`}</small>
|
<small>{`${calcTraffic(usage)}/${calcTraffic(total)}`}</small>
|
||||||
|
{profileDisplayDate === 'expire' ? (
|
||||||
<small>
|
<small>
|
||||||
{extra.expire ? dayjs.unix(extra.expire).format('YYYY-MM-DD') : '长期有效'}
|
{extra.expire ? dayjs.unix(extra.expire).format('YYYY-MM-DD') : '长期有效'}
|
||||||
</small>
|
</small>
|
||||||
|
) : (
|
||||||
|
<small>{dayjs(info.updated).fromNow()}</small>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{info.type === 'local' && (
|
{info.type === 'local' && (
|
||||||
|
|
1
src/shared/types.d.ts
vendored
1
src/shared/types.d.ts
vendored
|
@ -207,6 +207,7 @@ interface IAppConfig {
|
||||||
core: 'mihomo' | 'mihomo-alpha'
|
core: 'mihomo' | 'mihomo-alpha'
|
||||||
proxyDisplayMode: 'simple' | 'full'
|
proxyDisplayMode: 'simple' | 'full'
|
||||||
proxyDisplayOrder: 'default' | 'delay' | 'name'
|
proxyDisplayOrder: 'default' | 'delay' | 'name'
|
||||||
|
profileDisplayDate?: 'expire' | 'update'
|
||||||
envType?: ('bash' | 'cmd' | 'powershell')[]
|
envType?: ('bash' | 'cmd' | 'powershell')[]
|
||||||
proxyCols: 'auto' | '1' | '2' | '3' | '4'
|
proxyCols: 'auto' | '1' | '2' | '3' | '4'
|
||||||
connectionDirection: 'asc' | 'desc'
|
connectionDirection: 'asc' | 'desc'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user