:art:新增客户端离线通知选项配置以及监听任务
All checks were successful
continuous-integration/drone/tag Build is passing

This commit is contained in:
coward
2024-06-13 14:34:03 +08:00
parent 67f394f136
commit 6f249d20b0
18 changed files with 155 additions and 132 deletions

View File

@@ -1,18 +0,0 @@
{
"recommendations": [
"christian-kohler.path-intellisense",
"vscode-icons-team.vscode-icons",
"davidanson.vscode-markdownlint",
"ms-azuretools.vscode-docker",
"stylelint.vscode-stylelint",
"bradlc.vscode-tailwindcss",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"redhat.vscode-yaml",
"csstools.postcss",
"mikestead.dotenv",
"eamodio.gitlens",
"antfu.iconify",
"Vue.volar"
]
}

View File

@@ -1,31 +0,0 @@
{
"editor.formatOnType": true,
"editor.formatOnSave": true,
"[vue]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.tabSize": 2,
"editor.formatOnPaste": true,
"editor.guides.bracketPairs": "active",
"files.autoSave": "afterDelay",
"git.confirmSync": false,
"workbench.startupEditor": "newUntitledFile",
"editor.suggestSelection": "first",
"editor.acceptSuggestionOnCommitCharacter": false,
"css.lint.propertyIgnoredDueToDisplay": "ignore",
"editor.quickSuggestions": {
"other": true,
"comments": true,
"strings": true
},
"files.associations": {
"editor.snippetSuggestions": "top"
},
"[css]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"iconify.excludes": ["el"]
}

View File

@@ -1,22 +0,0 @@
{
"Vue3.0快速生成模板": {
"scope": "vue",
"prefix": "Vue3.0",
"body": [
"<template>",
"\t<div>test</div>",
"</template>\n",
"<script lang='ts'>",
"export default {",
"\tsetup() {",
"\t\treturn {}",
"\t}",
"}",
"</script>\n",
"<style lang='scss' scoped>\n",
"</style>",
"$2"
],
"description": "Vue3.0"
}
}

View File

@@ -1,17 +0,0 @@
{
"Vue3.2+快速生成模板": {
"scope": "vue",
"prefix": "Vue3.2+",
"body": [
"<script setup lang='ts'>",
"</script>\n",
"<template>",
"\t<div>test</div>",
"</template>\n",
"<style lang='scss' scoped>\n",
"</style>",
"$2"
],
"description": "Vue3.2+"
}
}

View File

@@ -1,20 +0,0 @@
{
"Vue3.3+defineOptions快速生成模板": {
"scope": "vue",
"prefix": "Vue3.3+",
"body": [
"<script setup lang='ts'>",
"defineOptions({",
"\tname: ''",
"})",
"</script>\n",
"<template>",
"\t<div>test</div>",
"</template>\n",
"<style lang='scss' scoped>\n",
"</style>",
"$2"
],
"description": "Vue3.3+defineOptions快速生成模板"
}
}

View File

@@ -1,6 +1,6 @@
{
"Version": "5.5.0",
"Title": "WG-Dashboard",
"Title": "wg-dashboard",
"FixedHeader": true,
"HiddenSideBar": false,
"MultiTagsCache": false,

View File

@@ -47,3 +47,8 @@ export const getClientConnects = () => {
export const offlineClient = (id: string) => {
return http.request<any>("post", baseUri("/client/offline/" + id));
};
// 发送邮件
export const sendMail = (id: string) => {
return http.request<any>("post", baseUri("/client/to-email/" + id));
};

View File

@@ -1,5 +1,6 @@
import { http } from "@/utils/http";
import { baseUri } from "@/api/utils";
import { data } from "autoprefixer";
// 获取当前登陆用户信息
export const getUser = () => {
@@ -30,3 +31,8 @@ export const deleteUser = (userId: string) => {
export const changePassword = (data?: object) => {
return http.request("post", baseUri("/user/change-password"), { data });
};
// 生成头像
export const generateAvatar = () => {
return http.request<any>("post", baseUri("/user/change-avatar"));
};

View File

@@ -1,6 +1,7 @@
<script setup lang="ts">
import { ref } from "vue";
import { FormInstance } from "element-plus";
import { generateAvatar } from "@/api/user";
// 声明 props 类型
export interface FormProps {
@@ -41,11 +42,29 @@ function getUserEditFormRef() {
return userEditFormRef.value;
}
// 切换头像
const changeAvatar = () => {
generateAvatar().then(res => {
if (res.code === 200) {
userEditForm.value.avatar = res.data;
}
});
};
defineExpose({ getUserEditFormRef });
</script>
<template>
<el-form ref="userEditFormRef" :model="userEditForm" label-width="20%">
<el-form-item prop="avatar">
<el-avatar
style="cursor: pointer; margin-left: 25%"
size="large"
fit="cover"
:src="userEditForm.avatar"
@click="changeAvatar()"
/>
</el-form-item>
<el-form-item
prop="name"
label="名称"

View File

@@ -135,14 +135,6 @@ class PureHttp {
$error.isCancelRequest = Axios.isCancel($error);
// 关闭进度条动画
NProgress.done();
if ($error.response.status === 401) {
router.replace({
path: "/login",
query: {
redirect: router.currentRoute.value.fullPath
}
});
}
// 所有的响应异常 区分来源为取消请求/非取消请求
return Promise.reject($error);
}

View File

@@ -1,9 +1,11 @@
<script setup lang="ts">
import {
deleteClient,
downloadClient, generateClientIP,
downloadClient,
generateClientIP,
getClients,
saveClient
saveClient,
sendMail
} from "@/api/clients";
import { h, reactive, ref } from "vue";
import { addDialog } from "@/components/ReDialog/index";
@@ -14,6 +16,7 @@ import "plus-pro-components/es/components/search/style/css";
import { storageLocal } from "@pureadmin/utils";
import { ArrowDown } from "@element-plus/icons-vue";
import { ElMessageBox } from "element-plus";
import { message } from "@/utils/message";
defineOptions({
// name 作为一种规范最好必须写上并且和路由的name保持一致
@@ -151,7 +154,7 @@ const openAddClientDialog = () => {
}
});
const serverInfo = storageLocal().getItem("server-info");
const restartRule = storageLocal().getItem("restart-rule") ? 1 : 0;
const restartRule = !storageLocal().getItem("restart-rule") ? 1 : 0;
addDialog({
width: "40%",
title: "新增",
@@ -174,7 +177,8 @@ const openAddClientDialog = () => {
publicKey: "",
presharedKey: ""
},
enabled: 1
enabled: 1,
offlineMonitoring: 0
}
},
beforeSure: (done, { options }) => {
@@ -213,7 +217,8 @@ const openEditClientDialog = (client?: any) => {
useServerDNS: client.useServerDNS,
enableAfterCreation: client.enableAfterCreation,
keys: client.keys,
enabled: Number(client.enabled)
enabled: Number(client.enabled),
offlineMonitoring: client.offlineMonitoring
}
},
beforeSure: (done, { options }) => {
@@ -279,6 +284,15 @@ const ellipsis = (str: string) => {
return str;
};
// 发送到邮件
const sendToEmail = (clientID: string) => {
sendMail(clientID).then(res => {
if (res.code === 200) {
message("发送邮件成功", { type: "success" });
}
});
};
getClientsApi(clientSearchForm.value);
</script>
@@ -309,7 +323,10 @@ getClientsApi(clientSearchForm.value);
</div>
<div class="content">
<el-card body-style="padding: inherit" shadow="hover">
<div class="flex flex-wrap gap-4" style="display: flex;justify-content: center;">
<div
class="flex flex-wrap gap-4"
style="display: flex; justify-content: center"
>
<el-card
v-for="val in clientsList.data"
style="float: left; width: 500px"
@@ -338,6 +355,11 @@ getClientsApi(clientSearchForm.value);
>下载</el-button
>
</el-dropdown-item>
<el-dropdown-item>
<el-button type="success" @click="sendToEmail(val.id)"
>邮件</el-button
>
</el-dropdown-item>
<el-dropdown-item>
<el-button
type="danger"
@@ -418,7 +440,10 @@ getClientsApi(clientSearchForm.value);
</el-form>
</el-card>
</div>
<div class="paginate" style="background-color: #ffffff; margin-top: 5px">
<div
class="paginate"
style="background-color: #ffffff; margin-top: 5px"
>
<el-card>
<el-pagination
small

View File

@@ -4,7 +4,7 @@ import { FormInstance } from "element-plus";
import { storageLocal } from "@pureadmin/utils";
import { userKey } from "@/utils/auth";
import { clientFormRules } from "@/views/server/component/rules";
import {generateClientKeys} from "@/api/clients";
import { generateClientKeys } from "@/api/clients";
// 声明 props 类型
export interface DetailFormProps {
@@ -26,6 +26,7 @@ export interface DetailFormProps {
presharedKey: string;
};
enabled: number;
offlineMonitoring: number;
};
}
@@ -49,7 +50,8 @@ const props = withDefaults(defineProps<DetailFormProps>(), {
publicKey: "",
presharedKey: ""
},
enabled: 1
enabled: 1,
offlineMonitoring: 0
})
});
@@ -88,7 +90,10 @@ defineExpose({ getDetailFormRef });
<el-input v-model="detailForm.name" />
</el-form-item>
<el-form-item prop="email" label="邮箱">
<el-input v-model="detailForm.email" />
<el-input
v-model="detailForm.email"
placeholder="可用于离线监听通知或接收客户端配置文件"
/>
</el-form-item>
<el-form-item prop="subnetRange" label="子网范围">
<el-input v-model="detailForm.subnetRange" />
@@ -146,27 +151,33 @@ defineExpose({ getDetailFormRef });
v-if="detailForm.id === ''"
v-model="detailForm.keys.privateKey"
/>
<el-input v-else disabled v-model="detailForm.keys.privateKey" />
<el-input v-else v-model="detailForm.keys.privateKey" disabled />
</el-form-item>
<el-form-item prop="publicKey" label="公钥">
<el-input
v-if="detailForm.id === ''"
v-model="detailForm.keys.publicKey"
/>
<el-input v-else disabled v-model="detailForm.keys.publicKey" />
<el-input v-else v-model="detailForm.keys.publicKey" disabled />
</el-form-item>
<el-form-item prop="presharedKey" label="共享密钥">
<el-input
v-if="detailForm.id === ''"
v-model="detailForm.keys.presharedKey"
/>
<el-input v-else disabled v-model="detailForm.keys.presharedKey" />
<el-input v-else v-model="detailForm.keys.presharedKey" disabled />
</el-form-item>
<el-form-item v-if="detailForm.id === ''">
<el-button type="primary" size="small" @click="generateClientKeysApi()"
>生成密钥对</el-button
>
</el-form-item>
<el-form-item prop="OfflineMonitoring" label="是否启用离线监听">
<el-radio-group v-model="detailForm.offlineMonitoring">
<el-radio :value="1"></el-radio>
<el-radio :value="0"></el-radio>
</el-radio-group>
</el-form-item>
<el-form-item prop="useServerDNS" label="是否使用服务端DNS">
<el-radio-group v-model="detailForm.useServerDNS">
<el-radio :value="1"></el-radio>