From 77faf9a41e85a12a0fa80a0a825007de99b42b9b 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: Sat, 14 Sep 2024 02:28:26 +0800 Subject: [PATCH] =?UTF-8?q?[+][*]=20=E6=B7=BB=E5=8A=A0=E9=9A=A7=E9=81=93?= =?UTF-8?q?=E4=B8=8B=E7=BA=BF=E5=8A=9F=E8=83=BD=EF=BC=8C=E8=BF=81=E7=A7=BB?= =?UTF-8?q?=E5=88=B0=20v-clipboard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- public/netlify.toml | 4 -- src/api/base.ts | 2 +- src/api/v2/proxies/down.ts | 2 +- src/api/v2/proxies/index.ts | 4 +- src/main.js | 2 + src/utils/clipboard.js | 27 ------------- src/views/Config.vue | 18 +++++---- src/views/Dashboard.vue | 38 ++++++++++++------ src/views/Proxies.vue | 79 +++++++++++++++++++++++++++---------- 10 files changed, 103 insertions(+), 75 deletions(-) delete mode 100644 public/netlify.toml delete mode 100644 src/utils/clipboard.js diff --git a/package.json b/package.json index 7a63199..9dad604 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,6 @@ "@vicons/ionicons5": "^0.12.0", "@vicons/material": "^0.12.0", "axios": "^1.7.7", - "clipboard": "^2.0.11", "highlight.js": "^11.10.0", "js-cookie": "^3.0.5", "json": "^11.0.0", @@ -25,6 +24,7 @@ "tailwindcss": "^3.4.10", "unplugin-auto-import": "^0.17.8", "unplugin-vue-components": "^0.26.0", + "v-clipboard": "^3.0.0-next.1", "vue": "^3.5.2", "vue-axios": "^3.5.2", "vue-cookies": "^1.8.4", diff --git a/public/netlify.toml b/public/netlify.toml deleted file mode 100644 index ff1c050..0000000 --- a/public/netlify.toml +++ /dev/null @@ -1,4 +0,0 @@ -[[redirects]] - from = "/*" - to = "/index.html" - status = 200 \ No newline at end of file diff --git a/src/api/base.ts b/src/api/base.ts index 16997a0..852b13a 100644 --- a/src/api/base.ts +++ b/src/api/base.ts @@ -9,7 +9,7 @@ const base = { res.data?.msg ?? '未指定或请求失败' const data = (useDataPath ? res.data?.data : res.data) ?? {} - const statusApi = (useDataPath ? res.data?.status : res.status) + const statusApi = useDataPath ? res.data?.status : res.status return { status: res.status as number, message: message, diff --git a/src/api/v2/proxies/down.ts b/src/api/v2/proxies/down.ts index e359f29..1e5119c 100644 --- a/src/api/v2/proxies/down.ts +++ b/src/api/v2/proxies/down.ts @@ -3,7 +3,7 @@ import base from '@/api/base' import { get } from '@/utils/request' const down = async (username: string, proxy_id: string) => { - const rs = get(`${base.api_v2_url}/proxies/getlist`, { + const rs = get(`${base.api_v2_url}/proxies/down`, { username: username, proxy_id: proxy_id }) diff --git a/src/api/v2/proxies/index.ts b/src/api/v2/proxies/index.ts index f8c1f3a..39b1986 100644 --- a/src/api/v2/proxies/index.ts +++ b/src/api/v2/proxies/index.ts @@ -1,5 +1,6 @@ import add from './add' import deleteX from './delete' +import down from './down' import getlist from './getlist' import update from './update' @@ -7,5 +8,6 @@ export default { add: add, update: update, getlist: getlist, - delete: deleteX + delete: deleteX, + down: down } diff --git a/src/main.js b/src/main.js index d68d81a..00783df 100644 --- a/src/main.js +++ b/src/main.js @@ -10,6 +10,7 @@ import axios from 'axios' import VueAxios from 'vue-axios' import store from '@/utils/stores/store' import { printTitle } from '@/utils/title' +import Clipboard from 'v-clipboard' const app = createApp(App) app.use(store) @@ -26,6 +27,7 @@ const meta = document.createElement('meta') meta.name = 'naive-ui-style' document.head.appendChild(meta) +app.use(Clipboard) app.use(VueAxios, axios) app.component('message', message) app.component('loadingbar', loadingbar) diff --git a/src/utils/clipboard.js b/src/utils/clipboard.js deleted file mode 100644 index d798abf..0000000 --- a/src/utils/clipboard.js +++ /dev/null @@ -1,27 +0,0 @@ -import Clipboard from 'clipboard' -import { sendErrorMessage, sendSuccessMessage } from './message' -import logger from '@/utils/logger' - -function clipboardSuccess(msg) { - sendSuccessMessage(msg || '复制成功') -} - -function clipboardError(msg) { - sendErrorMessage(msg || '嗯...发生了点小错误') -} - -export default function handleClipboard(text, event, msg) { - logger.info(`Writing clipboard [${event.target}]: ${text}`) - const clipboard = new Clipboard(event.target, { - text: () => text - }) - clipboard.on('success', () => { - clipboardSuccess(msg) - clipboard.destroy() - }) - clipboard.on('error', () => { - clipboardError(msg) - clipboard.destroy() - }) - clipboard.onClick(event) -} diff --git a/src/views/Config.vue b/src/views/Config.vue index 203d131..a08d02e 100644 --- a/src/views/Config.vue +++ b/src/views/Config.vue @@ -7,8 +7,16 @@ - 复制 + + 复制 { }) }) -function copy(data, event) { - clipboard(data, event) -} - async function updateValue(value) { let rs try { diff --git a/src/views/Dashboard.vue b/src/views/Dashboard.vue index 6bf213f..3cfdac1 100644 --- a/src/views/Dashboard.vue +++ b/src/views/Dashboard.vue @@ -53,22 +53,31 @@ 访问密钥:
-
- +
+ 点击显示
- @@ -228,14 +243,16 @@