mirror of
https://github.com/MetaCubeX/metacubexd.git
synced 2024-11-10 05:15:35 +08:00
feat: Add Upgrade Dashboard Button (#784)
* feat: Add Upgrade Dashboard Button * style: Adjust Element Positions
This commit is contained in:
parent
7b3e68b72c
commit
32704fbaaf
@ -28,6 +28,7 @@ export const [updatingGEODatabases, setUpdatingGEODatabases] =
|
|||||||
createSignal(false)
|
createSignal(false)
|
||||||
export const [flushingFakeIPData, setFlushingFakeIPData] = createSignal(false)
|
export const [flushingFakeIPData, setFlushingFakeIPData] = createSignal(false)
|
||||||
export const [upgradingBackend, setUpgradingBackend] = createSignal(false)
|
export const [upgradingBackend, setUpgradingBackend] = createSignal(false)
|
||||||
|
export const [upgradingUI, setUpgradingUI] = createSignal(false)
|
||||||
export const [restartingBackend, setRestartingBackend] = createSignal(false)
|
export const [restartingBackend, setRestartingBackend] = createSignal(false)
|
||||||
|
|
||||||
export const reloadConfigFileAPI = async () => {
|
export const reloadConfigFileAPI = async () => {
|
||||||
@ -77,6 +78,17 @@ export const upgradeBackendAPI = async () => {
|
|||||||
setUpgradingBackend(false)
|
setUpgradingBackend(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const upgradeUIAPI = async () => {
|
||||||
|
const request = useRequest()
|
||||||
|
setUpgradingUI(true)
|
||||||
|
try {
|
||||||
|
await request.post('upgrade/ui')
|
||||||
|
} catch {
|
||||||
|
/* empty */
|
||||||
|
}
|
||||||
|
setUpgradingUI(false)
|
||||||
|
}
|
||||||
|
|
||||||
export const restartBackendAPI = async () => {
|
export const restartBackendAPI = async () => {
|
||||||
const request = useRequest()
|
const request = useRequest()
|
||||||
setRestartingBackend(true)
|
setRestartingBackend(true)
|
||||||
|
@ -58,6 +58,7 @@ export default {
|
|||||||
updateGEODatabases: 'Update GEO Databases',
|
updateGEODatabases: 'Update GEO Databases',
|
||||||
restartCore: 'Restart Core',
|
restartCore: 'Restart Core',
|
||||||
upgradeCore: 'Upgrade Core',
|
upgradeCore: 'Upgrade Core',
|
||||||
|
upgradeUI: 'Upgrade Dashboard',
|
||||||
proxiesSorting: 'Proxies Sorting',
|
proxiesSorting: 'Proxies Sorting',
|
||||||
orderNatural: 'Original order in config file',
|
orderNatural: 'Original order in config file',
|
||||||
orderLatency_asc: 'By latency from low to high',
|
orderLatency_asc: 'By latency from low to high',
|
||||||
|
@ -60,6 +60,7 @@ export default {
|
|||||||
updateGEODatabases: '更新 GEO 数据库',
|
updateGEODatabases: '更新 GEO 数据库',
|
||||||
restartCore: '重启核心',
|
restartCore: '重启核心',
|
||||||
upgradeCore: '更新核心',
|
upgradeCore: '更新核心',
|
||||||
|
upgradeUI: '更新控制面板',
|
||||||
proxiesSorting: '节点排序',
|
proxiesSorting: '节点排序',
|
||||||
orderNatural: '原配置文件中的排序',
|
orderNatural: '原配置文件中的排序',
|
||||||
orderLatency_asc: '按延迟从低到高',
|
orderLatency_asc: '按延迟从低到高',
|
||||||
|
@ -18,6 +18,8 @@ import {
|
|||||||
updatingGEODatabases,
|
updatingGEODatabases,
|
||||||
upgradeBackendAPI,
|
upgradeBackendAPI,
|
||||||
upgradingBackend,
|
upgradingBackend,
|
||||||
|
upgradeUIAPI,
|
||||||
|
upgradingUI,
|
||||||
} from '~/apis'
|
} from '~/apis'
|
||||||
import { Button, ConfigTitle } from '~/components'
|
import { Button, ConfigTitle } from '~/components'
|
||||||
import { LANG, MODE_OPTIONS, ROUTES, themes } from '~/constants'
|
import { LANG, MODE_OPTIONS, ROUTES, themes } from '~/constants'
|
||||||
@ -114,6 +116,16 @@ const ConfigForm: Component<{ backendVersion: Accessor<string> }> = ({
|
|||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
|
|
||||||
const portList = [
|
const portList = [
|
||||||
|
{
|
||||||
|
label: () => t('port', { name: 'Mixed' }),
|
||||||
|
key: 'mixed-port',
|
||||||
|
onChange: (e: Event & { target: HTMLInputElement }) =>
|
||||||
|
void updateBackendConfigAPI(
|
||||||
|
'mixed-port',
|
||||||
|
Number(e.target.value),
|
||||||
|
refetch,
|
||||||
|
),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: () => t('port', { name: 'HTTP' }),
|
label: () => t('port', { name: 'HTTP' }),
|
||||||
key: 'port',
|
key: 'port',
|
||||||
@ -150,16 +162,6 @@ const ConfigForm: Component<{ backendVersion: Accessor<string> }> = ({
|
|||||||
refetch,
|
refetch,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
label: () => t('port', { name: 'Mixed' }),
|
|
||||||
key: 'mixed-port',
|
|
||||||
onChange: (e: Event & { target: HTMLInputElement }) =>
|
|
||||||
void updateBackendConfigAPI(
|
|
||||||
'mixed-port',
|
|
||||||
Number(e.target.value),
|
|
||||||
refetch,
|
|
||||||
),
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
|
|
||||||
const { form, setInitialValues, reset } = createForm<
|
const { form, setInitialValues, reset } = createForm<
|
||||||
@ -327,14 +329,6 @@ const ConfigForm: Component<{ backendVersion: Accessor<string> }> = ({
|
|||||||
{t('reloadConfig')}
|
{t('reloadConfig')}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Button
|
|
||||||
class="btn-secondary"
|
|
||||||
loading={updatingGEODatabases()}
|
|
||||||
onClick={updateGEODatabasesAPI}
|
|
||||||
>
|
|
||||||
{t('updateGEODatabases')}
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
class="btn-accent"
|
class="btn-accent"
|
||||||
loading={flushingFakeIPData()}
|
loading={flushingFakeIPData()}
|
||||||
@ -343,16 +337,6 @@ const ConfigForm: Component<{ backendVersion: Accessor<string> }> = ({
|
|||||||
{t('flushFakeIP')}
|
{t('flushFakeIP')}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Show when={!isSingBox(backendVersion())}>
|
|
||||||
<Button
|
|
||||||
class="btn-error"
|
|
||||||
loading={upgradingBackend()}
|
|
||||||
onClick={upgradeBackendAPI}
|
|
||||||
>
|
|
||||||
{t('upgradeCore')}
|
|
||||||
</Button>
|
|
||||||
</Show>
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
class="btn-warning"
|
class="btn-warning"
|
||||||
loading={restartingBackend()}
|
loading={restartingBackend()}
|
||||||
@ -361,15 +345,31 @@ const ConfigForm: Component<{ backendVersion: Accessor<string> }> = ({
|
|||||||
{t('restartCore')}
|
{t('restartCore')}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Button
|
<Show when={!isSingBox(backendVersion())}>
|
||||||
class="btn-info"
|
<Button
|
||||||
onClick={() => {
|
class="btn-secondary"
|
||||||
setSelectedEndpoint('')
|
loading={updatingGEODatabases()}
|
||||||
navigate(ROUTES.Setup)
|
onClick={updateGEODatabasesAPI}
|
||||||
}}
|
>
|
||||||
>
|
{t('updateGEODatabases')}
|
||||||
{t('switchEndpoint')}
|
</Button>
|
||||||
</Button>
|
|
||||||
|
<Button
|
||||||
|
class="btn-info"
|
||||||
|
loading={upgradingUI()}
|
||||||
|
onClick={upgradeUIAPI}
|
||||||
|
>
|
||||||
|
{t('upgradeUI')}
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
class="btn-error"
|
||||||
|
loading={upgradingBackend()}
|
||||||
|
onClick={upgradeBackendAPI}
|
||||||
|
>
|
||||||
|
{t('upgradeCore')}
|
||||||
|
</Button>
|
||||||
|
</Show>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
@ -377,7 +377,7 @@ const ConfigForm: Component<{ backendVersion: Accessor<string> }> = ({
|
|||||||
|
|
||||||
const ConfigForXd = () => {
|
const ConfigForXd = () => {
|
||||||
const [t] = useI18n()
|
const [t] = useI18n()
|
||||||
|
const navigate = useNavigate()
|
||||||
const languages = [
|
const languages = [
|
||||||
{
|
{
|
||||||
label: () => t('en'),
|
label: () => t('en'),
|
||||||
@ -419,6 +419,19 @@ const ConfigForXd = () => {
|
|||||||
</For>
|
</For>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="flex flex-col">
|
||||||
|
<div class="py-2 text-center text-lg font-semibold"> </div>
|
||||||
|
<Button
|
||||||
|
class="btn-info"
|
||||||
|
onClick={() => {
|
||||||
|
setSelectedEndpoint('')
|
||||||
|
navigate(ROUTES.Setup)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t('switchEndpoint')}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex flex-col gap-2">
|
<div class="flex flex-col gap-2">
|
||||||
|
Loading…
Reference in New Issue
Block a user