From 7bfcd0f3bbffd75909aae16910591e53cac0d38f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=8F=E6=B2=AB=E8=8A=B1=E7=81=ABzzz=F0=9F=8C=99?= Date: Wed, 8 Jan 2025 19:37:38 +0800 Subject: [PATCH] [+] Add proxy-level frp client config tab --- components.d.ts | 16 ++++++ src/main.js | 6 --- src/views/proxies/ConfigView.vue | 93 ++++++++++++++++++++++++++------ 3 files changed, 93 insertions(+), 22 deletions(-) diff --git a/components.d.ts b/components.d.ts index a3fb0e5..585e5bd 100644 --- a/components.d.ts +++ b/components.d.ts @@ -14,16 +14,21 @@ declare module 'vue' { NAvatar: typeof import('naive-ui')['NAvatar'] NButton: typeof import('naive-ui')['NButton'] NCard: typeof import('naive-ui')['NCard'] + NCode: typeof import('naive-ui')['NCode'] NDivider: typeof import('naive-ui')['NDivider'] NDrawer: typeof import('naive-ui')['NDrawer'] NDrawerContent: typeof import('naive-ui')['NDrawerContent'] NEl: typeof import('naive-ui')['NEl'] + NEmpty: typeof import('naive-ui')['NEmpty'] NForm: typeof import('naive-ui')['NForm'] NFormItem: typeof import('naive-ui')['NFormItem'] + NGi: typeof import('naive-ui')['NGi'] NGrid: typeof import('naive-ui')['NGrid'] NGridItem: typeof import('naive-ui')['NGridItem'] NH1: typeof import('naive-ui')['NH1'] NH2: typeof import('naive-ui')['NH2'] + NH3: typeof import('naive-ui')['NH3'] + NH4: typeof import('naive-ui')['NH4'] NH5: typeof import('naive-ui')['NH5'] NIcon: typeof import('naive-ui')['NIcon'] NInput: typeof import('naive-ui')['NInput'] @@ -31,17 +36,28 @@ declare module 'vue' { NLayoutContent: typeof import('naive-ui')['NLayoutContent'] NLayoutHeader: typeof import('naive-ui')['NLayoutHeader'] NLayoutSider: typeof import('naive-ui')['NLayoutSider'] + NList: typeof import('naive-ui')['NList'] + NListItem: typeof import('naive-ui')['NListItem'] NMenu: typeof import('naive-ui')['NMenu'] NModal: typeof import('naive-ui')['NModal'] NNumberAnimation: typeof import('naive-ui')['NNumberAnimation'] NP: typeof import('naive-ui')['NP'] + NRadioButton: typeof import('naive-ui')['NRadioButton'] + NRadioGroup: typeof import('naive-ui')['NRadioGroup'] + NScrollbar: typeof import('naive-ui')['NScrollbar'] + NSelect: typeof import('naive-ui')['NSelect'] NSpace: typeof import('naive-ui')['NSpace'] NSpin: typeof import('naive-ui')['NSpin'] NStatistic: typeof import('naive-ui')['NStatistic'] NStep: typeof import('naive-ui')['NStep'] NSteps: typeof import('naive-ui')['NSteps'] + NTab: typeof import('naive-ui')['NTab'] + NTabPane: typeof import('naive-ui')['NTabPane'] + NTabs: typeof import('naive-ui')['NTabs'] NTag: typeof import('naive-ui')['NTag'] NText: typeof import('naive-ui')['NText'] + NThing: typeof import('naive-ui')['NThing'] + NTooltip: typeof import('naive-ui')['NTooltip'] RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] TheDialog: typeof import('./src/components/TheDialog.vue')['default'] diff --git a/src/main.js b/src/main.js index 5e865e6..70cd86b 100644 --- a/src/main.js +++ b/src/main.js @@ -2,9 +2,6 @@ import { createApp } from 'vue' import '@/assets/style.css' import '@/assets/twemoji-amazing.css' import App from './App.vue' -import message from '@components/TheMessage.vue' -import loadingbar from '@components/LoadingBar.vue' -import ndialog from '@components/TheDialog.vue' import router from '@router' import axios from 'axios' import VueAxios from 'vue-axios' @@ -32,9 +29,6 @@ document.head.appendChild(meta) app.use(Clipboard) app.use(VueAxios, axios) -app.component('message', message) -app.component('loadingbar', loadingbar) -app.component('ndialog', ndialog) userDataLocal() app.mount('#app') diff --git a/src/views/proxies/ConfigView.vue b/src/views/proxies/ConfigView.vue index aebe841..0f19bd8 100644 --- a/src/views/proxies/ConfigView.vue +++ b/src/views/proxies/ConfigView.vue @@ -5,8 +5,33 @@ - - + + + + + + + + + + + + + + 复制 - - - - -
@@ -77,9 +92,11 @@ const message = new Message() const loading = ref(true) -const node = ref('') +const node = ref(null) +const proxy = ref(null) // 选择框数据 const serverList = ref([]) +const proxyList = ref([]) const code = ref('') // const rs = get('https://api.locyanfrp.cn/Proxies/GetServerList') @@ -121,7 +138,7 @@ onMounted(async () => { list.forEach((s) => { if (i === 0) { node.value = s.id - updateValue(s.id) + updateValue(s.id, null) } serverList.value[i] = { label: s.name, @@ -131,11 +148,55 @@ onMounted(async () => { }) }) -async function updateValue(value) { +onMounted(async () => { + let rs + try { + rs = await api.v2.proxy.all(userData.getters.get_user_id) + } catch (e) { + logger.error(e) + message.error('请求隧道列表失败: ' + e) + } + if (!rs) return + let i = 0 + const list = rs.data.list + list.sort((a, b) => { + if (a.name < b.name) { + return -1 + } + if (a.name > b.name) { + return 1 + } + return 0 + }) + list.forEach((s) => { + if (i === 0) { + proxy.value = s.id + updateValue(null, s.id) + } + proxyList.value[i] = { + label: s.proxy_name, + value: s.id + } + i = i + 1 + }) +}) + +async function tabUpdateHandler(value) { + switch (value) { + case 'node': + await updateValue(node.value, null) + break + case 'proxy': + await updateValue(null, proxy.value) + break + } +} + +async function updateValue(nodeId, proxyId) { loading.value = true let rs try { - rs = await api.v2.proxy.config(userData.getters.get_user_id, null, value) + rs = await api.v2.proxy.config(userData.getters.get_user_id, proxyId, nodeId) } catch (e) { logger.error(e) message.error('请求获取隧道配置文件失败: ' + e)