添加客户端配置
This commit is contained in:
parent
06ce7be084
commit
4e06c09ca3
|
|
@ -105,6 +105,11 @@ export const LocalClientStatusHandler = () => {
|
||||||
return local_request.get('/vpn/get_status')
|
return local_request.get('/vpn/get_status')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 设置客户端配置
|
||||||
|
export const SetClientConfigHandler = (Data) => {
|
||||||
|
return local_request.post('/vpn/set_client', Data)
|
||||||
|
}
|
||||||
|
|
||||||
// VPN Policy Management APIs
|
// VPN Policy Management APIs
|
||||||
// myVPNPolicyGroup := router.Group("/vpn_policy")
|
// myVPNPolicyGroup := router.Group("/vpn_policy")
|
||||||
// myVPNPolicyGroup.GET("/get", GetMyVPNPolicyHandler)
|
// myVPNPolicyGroup.GET("/get", GetMyVPNPolicyHandler)
|
||||||
|
|
|
||||||
|
|
@ -172,15 +172,6 @@ const routes: RouteRecordRaw[] = [
|
||||||
permiss: '755',
|
permiss: '755',
|
||||||
},
|
},
|
||||||
component: () => import(/* webpackChunkName: "system-user" */ '../views/system/vpn-server-online-user.vue'),
|
component: () => import(/* webpackChunkName: "system-user" */ '../views/system/vpn-server-online-user.vue'),
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/vpn-policy',
|
|
||||||
name: 'vpn-policy',
|
|
||||||
meta: {
|
|
||||||
title: 'VPN策略',
|
|
||||||
permiss: '756',
|
|
||||||
},
|
|
||||||
component: () => import(/* webpackChunkName: "system-user" */ '../views/system/vpn-policy.vue'),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/vpn-status',
|
path: '/vpn-status',
|
||||||
|
|
@ -191,6 +182,15 @@ const routes: RouteRecordRaw[] = [
|
||||||
},
|
},
|
||||||
component: () => import(/* webpackChunkName: "system-user" */ '../views/system/vpn-server-status.vue'),
|
component: () => import(/* webpackChunkName: "system-user" */ '../views/system/vpn-server-status.vue'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/vpn-policy',
|
||||||
|
name: 'vpn-policy',
|
||||||
|
meta: {
|
||||||
|
title: 'VPN策略',
|
||||||
|
permiss: '756',
|
||||||
|
},
|
||||||
|
component: () => import(/* webpackChunkName: "system-user" */ '../views/system/vpn-policy.vue'),
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
path: '/callback',
|
path: '/callback',
|
||||||
|
|
|
||||||
|
|
@ -190,18 +190,30 @@
|
||||||
<el-dialog
|
<el-dialog
|
||||||
v-model="showClientConfigDialog"
|
v-model="showClientConfigDialog"
|
||||||
title="客户端配置"
|
title="客户端配置"
|
||||||
width="800px"
|
width="500px"
|
||||||
:before-close="handleClientConfigDialogClose"
|
:before-close="handleClientConfigDialogClose"
|
||||||
>
|
>
|
||||||
<!-- 客户端配置内容 -->
|
<!-- 客户端配置内容 -->
|
||||||
<div class="client-options">
|
<div class="client-options" style="padding: 20px 0;">
|
||||||
<el-switch
|
<el-form label-width="120px">
|
||||||
v-model="clientConfig.auto_reconnect"
|
<el-form-item label="自动重连">
|
||||||
active-color="#13ce66"
|
<el-switch
|
||||||
inactive-color="#ff4949"
|
v-model="clientConfig.auto_reconnect"
|
||||||
active-text="自动重连"
|
active-color="#13ce66"
|
||||||
/>
|
inactive-color="#ff4949"
|
||||||
|
active-text="开启"
|
||||||
|
inactive-text="关闭"
|
||||||
|
/>
|
||||||
|
<div style="margin-top: 8px; color: #909399; font-size: 13px;">
|
||||||
|
开启后,当VPN连接意外断开时,客户端将自动尝试重新连接
|
||||||
|
</div>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="handleClientConfigDialogClose">取消</el-button>
|
||||||
|
<el-button type="primary" @click="saveClientConfig" :loading="savingConfig">保存配置</el-button>
|
||||||
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -210,7 +222,7 @@
|
||||||
import { ref, onMounted, onUnmounted } from 'vue'
|
import { ref, onMounted, onUnmounted } from 'vue'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import { Download, Monitor, Connection } from '@element-plus/icons-vue'
|
import { Download, Monitor, Connection } from '@element-plus/icons-vue'
|
||||||
import { GetSurppotVPNServerOnlineListHandler, LocalClientConnectHandler, LocalClientStatusHandler,LocalClientDisConnectHandler,GetClientDownloadURLHandler } from '@/api/vpn'
|
import { GetSurppotVPNServerOnlineListHandler, LocalClientConnectHandler, LocalClientStatusHandler,LocalClientDisConnectHandler,GetClientDownloadURLHandler, SetClientConfigHandler } from '@/api/vpn'
|
||||||
|
|
||||||
interface ServerInfo {
|
interface ServerInfo {
|
||||||
/** 服务器名称 */
|
/** 服务器名称 */
|
||||||
|
|
@ -260,6 +272,7 @@ const onlineInfoData = ref({
|
||||||
const clientConfig = ref({
|
const clientConfig = ref({
|
||||||
auto_reconnect: false,
|
auto_reconnect: false,
|
||||||
})
|
})
|
||||||
|
const savingConfig = ref(false)
|
||||||
|
|
||||||
// 格式化字节数显示
|
// 格式化字节数显示
|
||||||
const formatBytes = (bytes: number): string => {
|
const formatBytes = (bytes: number): string => {
|
||||||
|
|
@ -281,6 +294,28 @@ const handleClientConfigDialogClose = () => {
|
||||||
showClientConfigDialog.value = false
|
showClientConfigDialog.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const saveClientConfig = async () => {
|
||||||
|
savingConfig.value = true
|
||||||
|
try {
|
||||||
|
const requestData = {
|
||||||
|
auto_reconnect: clientConfig.value.auto_reconnect ? 1 : 0
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await SetClientConfigHandler(requestData)
|
||||||
|
if (response && response["code"] === 0) {
|
||||||
|
ElMessage.success('客户端配置保存成功')
|
||||||
|
showClientConfigDialog.value = false
|
||||||
|
} else {
|
||||||
|
ElMessage.error(response["message"] || '配置保存失败')
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('保存客户端配置错误:', error)
|
||||||
|
ElMessage.error('保存失败,请稍后重试')
|
||||||
|
} finally {
|
||||||
|
savingConfig.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 刷新在线信息
|
// 刷新在线信息
|
||||||
const refreshOnlineInfo = async () => {
|
const refreshOnlineInfo = async () => {
|
||||||
onlineInfoLoading.value = true
|
onlineInfoLoading.value = true
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue