Skip to content

Commit

Permalink
feat: upgrade core for mihomo
Browse files Browse the repository at this point in the history
  • Loading branch information
Zephyruso committed Dec 2, 2024
1 parent a59fac2 commit cd0f65b
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 18 deletions.
4 changes: 4 additions & 0 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ export const upgradeUIAPI = () => {
return axios.post('/upgrade/ui')
}

export const upgradeCoreAPI = () => {
return axios.post('/upgrade')
}

const createWebSocket = <T>(url: string, searchParams?: Record<string, string>) => {
const backend = activeBackend.value
const resurl = new URL(
Expand Down
11 changes: 9 additions & 2 deletions src/components/proxies/ProxyGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,23 @@
<div class="collapse collapse-arrow bg-base-100 shadow-lg">
<div class="collapse-title">
<div class="items-top flex gap-2">
<div class="flex flex-col gap-2 sm:flex-row">
<div class="flex flex-col gap-1 sm:flex-row">
<div class="flex items-center gap-1 text-lg font-medium sm:text-xl">
<img
v-if="proxyGroup.icon"
class="w-5"
:src="proxyGroup.icon"
/>
{{ proxyGroup.name }}

<span class="text-xs">:: {{ proxyGroup.type }}</span>
</div>
<div
class="flex items-center gap-2 text-xs sm:text-sm"
v-if="proxyGroup.now"
>
-> {{ proxyGroup.now }}
</div>
<div class="flex items-center gap-2 text-xs sm:text-sm">-> {{ proxyGroup.now }}</div>
</div>
<div class="flex-1" />
<div class="mt-1 flex gap-2">
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ export default {
language: 'Language',
automaticDisconnection: 'Automatic Disconnection',
twoColumnsForProxyGroupInMobile: 'Two Columns For Proxy Group In Mobile',
backend: 'Backend',
upgradeCore: 'Upgrade Core',
[LANG.EN_US]: 'English',
[LANG.ZH_CN]: '中文',
}
2 changes: 2 additions & 0 deletions src/i18n/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ export default {
language: '语言',
automaticDisconnection: '自动断开连接',
twoColumnsForProxyGroupInMobile: '在移动端显示两列代理节点',
backend: '后端',
upgradeCore: '更新核心',
[LANG.EN_US]: 'English',
[LANG.ZH_CN]: '中文',
}
73 changes: 57 additions & 16 deletions src/views/SettingsPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,30 @@
/>
</select>
</div>
<div v-if="!isSingBox">
<button
:class="twMerge('btn btn-primary btn-sm', isUIUpgrading ? 'animate-pulse' : '')"
@click="handlerClickUpgradeUI"
>
{{ $t('upgradeUI') }}
</button>
</div>
</div>
</div>
<div class="card card-compact bg-base-100 shadow-lg">
<div class="card-title px-4 pt-4">
{{ $t('backend') }}
</div>
<div class="card-body gap-4">
<BackendSwitch />
<div class="flex items-center gap-2">
<template v-if="!isSingBox">
<button
:class="twMerge('btn btn-primary btn-sm', isUpgrading ? 'animate-pulse' : '')"
@click="handlerClickUpgradeUI"
>
{{ $t('upgradeUI') }}
</button>
</template>
<button
v-if="!isSingBox"
:class="twMerge('btn btn-primary btn-sm', isCoreUpgrading ? 'animate-pulse' : '')"
@click="handlerClickUpgradeCore"
>
{{ $t('upgradeCore') }}
</button>
<button
:class="twMerge('btn btn-sm', isConfigReloading ? 'animate-pulse' : '')"
@click="handlerClickReloadConfigs"
Expand Down Expand Up @@ -158,7 +172,14 @@
</template>

<script setup lang="ts">
import { flushFakeIPAPI, isSingBox, reloadConfigsAPI, upgradeUIAPI, zashboardVersion } from '@/api'
import {
flushFakeIPAPI,
isSingBox,
reloadConfigsAPI,
upgradeCoreAPI,
upgradeUIAPI,
zashboardVersion,
} from '@/api'
import TableSettings from '@/components/connections/TableSettings.vue'
import BackendSwitch from '@/components/settings/BackendSwitch.vue'
import { LANG } from '@/config'
Expand All @@ -178,20 +199,40 @@ import {
import { twMerge } from 'tailwind-merge'
import { ref } from 'vue'
const isUpgrading = ref(false)
const isCoreUpgrading = ref(false)
const handlerClickUpgradeCore = async () => {
if (isCoreUpgrading.value) return
isCoreUpgrading.value = true
try {
await upgradeCoreAPI()
isCoreUpgrading.value = false
} catch {
isCoreUpgrading.value = false
}
}
const isUIUpgrading = ref(false)
const handlerClickUpgradeUI = async () => {
if (isUpgrading.value) return
isUpgrading.value = true
await upgradeUIAPI()
isUpgrading.value = false
if (isUIUpgrading.value) return
isUIUpgrading.value = true
try {
await upgradeUIAPI()
isUIUpgrading.value = false
} catch {
isUIUpgrading.value = false
}
}
const isConfigReloading = ref(false)
const handlerClickReloadConfigs = async () => {
if (isConfigReloading.value) return
isConfigReloading.value = true
await reloadConfigsAPI()
isConfigReloading.value = false
try {
await reloadConfigsAPI()
isConfigReloading.value = false
} catch {
isConfigReloading.value = false
}
}
const themes = [
Expand Down

0 comments on commit cd0f65b

Please sign in to comment.