From 396147542195dd43bd6452907c992c18c4c586d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=98=89=E4=BC=9F?= <8473136@qq.com> Date: Fri, 16 Aug 2024 23:59:40 +0800 Subject: [PATCH] =?UTF-8?q?:construction:=20=E7=B1=BB=E5=9E=8B=E7=BB=9F?= =?UTF-8?q?=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- electron/api/github.ts | 2 +- electron/storage/config.ts | 45 +- electron/storage/proxy.ts | 12 +- electron/storage/version.ts | 10 +- src/types/global.d.ts | 9 - src/views/config/index.vue | 769 ++++++++++++++++------------ src/views/download/index.vue | 25 +- src/views/proxy/index.vue | 564 +++++++++++++------- types/global.d.ts | 80 +++ {src/types => types}/shims-tsx.d.ts | 0 {src/types => types}/shims-vue.d.ts | 0 11 files changed, 921 insertions(+), 595 deletions(-) delete mode 100644 src/types/global.d.ts create mode 100644 types/global.d.ts rename {src/types => types}/shims-tsx.d.ts (100%) rename {src/types => types}/shims-vue.d.ts (100%) diff --git a/electron/api/github.ts b/electron/api/github.ts index d545b88..e94f756 100644 --- a/electron/api/github.ts +++ b/electron/api/github.ts @@ -74,7 +74,7 @@ const unZip = (zipPath: string, targetPath: string) => { export const initGitHubApi = () => { // 版本 - let versions = []; + let versions: FrpVersion[] = []; const getVersion = versionId => { return versions.find(f => f.id === versionId); diff --git a/electron/storage/config.ts b/electron/storage/config.ts index 5c41b6c..e68ece2 100644 --- a/electron/storage/config.ts +++ b/electron/storage/config.ts @@ -1,47 +1,24 @@ import Datastore from "nedb"; import path from "path"; -import {app} from "electron"; +import { app } from "electron"; -const log = require('electron-log'); +const log = require("electron-log"); const configDB = new Datastore({ - autoload: true, - filename: path.join(app.getPath("userData"), "config.db") + autoload: true, + filename: path.join(app.getPath("userData"), "config.db") }); -export type Config = { - currentVersion: any; - serverAddr: string; - serverPort: number; - authMethod: string; - authToken: string; - logLevel: string; - logMaxDays: number; - tlsConfigEnable: boolean; - tlsConfigCertFile: string; - tlsConfigKeyFile: string; - tlsConfigTrustedCaFile: string; - tlsConfigServerName: string; - proxyConfigEnable: boolean; - proxyConfigProxyUrl: string; - systemSelfStart: boolean; - systemStartupConnect: boolean; - user: string; - metaToken: string; - transportHeartbeatInterval: number; - transportHeartbeatTimeout: number; -}; - /** * 保存 */ export const saveConfig = ( - document: Config, - cb?: (err: Error | null, numberOfUpdated: number, upsert: boolean) => void + document: FrpConfig, + cb?: (err: Error | null, numberOfUpdated: number, upsert: boolean) => void ) => { - document["_id"] = "1"; - log.debug(`保存日志 ${JSON.stringify(document)}`) - configDB.update({_id: "1"}, document, {upsert: true}, cb); + document["_id"] = "1"; + log.debug(`保存日志 ${JSON.stringify(document)}`); + configDB.update({ _id: "1" }, document, { upsert: true }, cb); }; /** @@ -49,7 +26,7 @@ export const saveConfig = ( * @param cb */ export const getConfig = ( - cb: (err: Error | null, document: Config) => void + cb: (err: Error | null, document: FrpConfig) => void ) => { - configDB.findOne({_id: "1"}, cb); + configDB.findOne({ _id: "1" }, cb); }; diff --git a/electron/storage/proxy.ts b/electron/storage/proxy.ts index f975b8a..904f971 100644 --- a/electron/storage/proxy.ts +++ b/electron/storage/proxy.ts @@ -1,22 +1,14 @@ import Datastore from "nedb"; import path from "path"; import { app } from "electron"; -const log = require('electron-log'); + +const log = require("electron-log"); const proxyDB = new Datastore({ autoload: true, filename: path.join(app.getPath("userData"), "proxy.db") }); -export type Proxy = { - _id: string; - name: string; - type: string; - localIp: string; - localPort: number; - remotePort: number; - customDomains: string[]; -}; /** * 新增代理 * @param proxy diff --git a/electron/storage/version.ts b/electron/storage/version.ts index 8c2600f..e700f3b 100644 --- a/electron/storage/version.ts +++ b/electron/storage/version.ts @@ -9,12 +9,12 @@ const versionDB = new Datastore({ }); /** - * 新增代理 - * @param proxy + * 新增版本 + * @param version * @param cb */ export const insertVersion = ( - version: any, + version: FrpVersion, cb?: (err: Error | null, document: any) => void ) => { log.debug(`新增版本:${JSON.stringify(version)}`); @@ -26,14 +26,14 @@ export const insertVersion = ( * @param cb */ export const listVersion = ( - callback: (err: Error | null, documents: any[]) => void + callback: (err: Error | null, documents: FrpVersion[]) => void ) => { versionDB.find({}, callback); }; export const getVersionById = ( id: string, - callback: (err: Error | null, document: any) => void + callback: (err: Error | null, document: FrpVersion) => void ) => { versionDB.findOne({id: id}, callback); }; diff --git a/src/types/global.d.ts b/src/types/global.d.ts deleted file mode 100644 index 277926a..0000000 --- a/src/types/global.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -declare module 'element-plus/dist/locale/zh-cn.mjs' { - const zhLocale: any; - export default zhLocale; -} - -declare module 'element-plus/dist/locale/en.mjs' { - const enLocale: any; - export default enLocale; -} diff --git a/src/views/config/index.vue b/src/views/config/index.vue index b6a96fe..4445206 100644 --- a/src/views/config/index.vue +++ b/src/views/config/index.vue @@ -1,57 +1,28 @@