From 78bad4842bbb202e37c3bc65f648764683e73487 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Wed, 8 May 2024 18:24:24 +0800 Subject: [PATCH] style: webui --- src/webui/ui/NapCat.ts | 14 ++--- src/webui/ui/components/WebApi.ts | 53 ------------------- .../WebUiApiOB11Config.ts} | 29 ++++++++-- 3 files changed, 31 insertions(+), 65 deletions(-) delete mode 100644 src/webui/ui/components/WebApi.ts rename src/webui/ui/{helper/Config.ts => components/WebUiApiOB11Config.ts} (67%) diff --git a/src/webui/ui/NapCat.ts b/src/webui/ui/NapCat.ts index cfaefaf1..d96e286e 100644 --- a/src/webui/ui/NapCat.ts +++ b/src/webui/ui/NapCat.ts @@ -3,10 +3,10 @@ import { SettingItem } from "./components/SettingItem"; import { SettingButton } from "./components/SettingButton"; import { SettingSwitch } from "./components/SettingSwitch"; import { SettingSelect } from "./components/SettingSelect"; -import { WebUiApi } from "./components/WebApi" +import { OB11Config, OB11ConfigWrapper } from "./components/WebUiApiOB11Config" async function onSettingWindowCreated(view: Element) { const isEmpty = (value: any) => value === undefined || value === undefined || value === ''; - let ob11Config = await WebUiApi.getOB11Config(); + let ob11Config: OB11Config = await OB11ConfigWrapper.GetOB11Config(); const setOB11Config = (key: string, value: any) => { } @@ -135,8 +135,8 @@ async function onSettingWindowCreated(view: Element) { ) ]), SettingList([ - SettingItem('GitHub 仓库', `https://github.com/`, SettingButton('点个星星', 'open-github')), - SettingItem('NapCat 文档', `https://`, SettingButton('看看文档', 'open-docs')), + SettingItem('GitHub 仓库', `https://github.com/NapNeko/NapCatQQ`, SettingButton('点个星星', 'open-github')), + SettingItem('NapCat 文档', ``, SettingButton('看看文档', 'open-docs')), SettingItem('Telegram 群', `https://t.me/+nLZEnpne-pQ1OWFl`, SettingButton('进去逛逛', 'open-telegram')), SettingItem('QQ 群', `545402644`, SettingButton('我要进去', 'open-qq-group')), ]), @@ -147,7 +147,7 @@ async function onSettingWindowCreated(view: Element) { // 外链按钮 doc.querySelector('#open-github')?.addEventListener('click', () => { - window.open("https://github.com/", '_blank'); + window.open("https://napneko.github.io/", '_blank'); }) doc.querySelector('#open-telegram')?.addEventListener('click', () => { window.open('https://t.me/+nLZEnpne-pQ1OWFl') @@ -156,7 +156,7 @@ async function onSettingWindowCreated(view: Element) { window.open('https://qm.qq.com/q/bDnHRG38aI') }) doc.querySelector('#open-docs')?.addEventListener('click', () => { - window.open('https://github.io/') + window.open('https://github.com/NapNeko/NapCatQQ') }) // 生成反向地址列表 const buildHostListItem = (type: string, host: string, index: number, inputAttrs: any = {}) => { @@ -279,7 +279,7 @@ async function onSettingWindowCreated(view: Element) { // 保存按钮 doc.querySelector('#config-ob11-save')?.addEventListener('click', () => { - WebUiApi.setOB11Config(ob11Config); + OB11ConfigWrapper.SetOB11Config(ob11Config); alert('保存成功'); }) doc.body.childNodes.forEach((node) => { diff --git a/src/webui/ui/components/WebApi.ts b/src/webui/ui/components/WebApi.ts deleted file mode 100644 index d5ed7ab6..00000000 --- a/src/webui/ui/components/WebApi.ts +++ /dev/null @@ -1,53 +0,0 @@ -export interface OB11Config { - httpHost: "", - httpPort: number; - httpPostUrls: string[]; - httpSecret: "", - wsHost: "", - wsPort: number; - wsReverseUrls: string[]; - enableHttp: boolean; - enableHttpHeart: boolean; - enableHttpPost: boolean; - enableWs: boolean; - enableWsReverse: boolean; - messagePostFormat: 'array' | 'string'; - reportSelfMessage: boolean; - enableLocalFile2Url: boolean; - debug: boolean; - heartInterval: number; - token: "", - musicSignUrl: "", -} - -class WebUiApiWrapper { - token: string = ""; - public async setOB11Config(config: OB11Config) { - - } - public async getOB11Config(): Promise { - // 返回示例配置 - return { - httpHost: "", - httpPort: 3000, - httpPostUrls: [], - httpSecret: "", - wsHost: "", - wsPort: 3000, - wsReverseUrls: [], - enableHttp: false, - enableHttpHeart: false, - enableHttpPost: false, - enableWs: false, - enableWsReverse: false, - messagePostFormat: 'array', - reportSelfMessage: false, - enableLocalFile2Url: false, - debug: false, - heartInterval: 60000, - token: "", - musicSignUrl: "", - }; - } -} -export const WebUiApi = new WebUiApiWrapper(); \ No newline at end of file diff --git a/src/webui/ui/helper/Config.ts b/src/webui/ui/components/WebUiApiOB11Config.ts similarity index 67% rename from src/webui/ui/helper/Config.ts rename to src/webui/ui/components/WebUiApiOB11Config.ts index 62b9d1a6..8d6d189d 100644 --- a/src/webui/ui/helper/Config.ts +++ b/src/webui/ui/components/WebUiApiOB11Config.ts @@ -1,12 +1,31 @@ -import { OB11Config } from "../components/WebApi"; - - +export interface OB11Config { + [key: string]: any, + httpHost: "", + httpPort: number; + httpPostUrls: string[]; + httpSecret: "", + wsHost: "", + wsPort: number; + wsReverseUrls: string[]; + enableHttp: boolean; + enableHttpHeart: boolean; + enableHttpPost: boolean; + enableWs: boolean; + enableWsReverse: boolean; + messagePostFormat: 'array' | 'string'; + reportSelfMessage: boolean; + enableLocalFile2Url: boolean; + debug: boolean; + heartInterval: number; + token: "", + musicSignUrl: "", +} class WebUiApiOB11ConfigWrapper { private retCredential: string = ""; async Init(Credential: string) { this.retCredential = Credential; } - async GetConfig(): Promise { + async GetOB11Config(): Promise { let ConfigResponse = await fetch('/api/OB11Config/GetConfig', { method: 'POST', headers: { @@ -22,7 +41,7 @@ class WebUiApiOB11ConfigWrapper { } return {} as OB11Config; } - async SetConfig(config: OB11Config): Promise { + async SetOB11Config(config: OB11Config): Promise { let ConfigResponse = await fetch('/api/OB11Config/SetConfig', { method: 'POST',