mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
style: webui
This commit is contained in:
parent
b9a913cfed
commit
78bad4842b
@ -3,10 +3,10 @@ import { SettingItem } from "./components/SettingItem";
|
|||||||
import { SettingButton } from "./components/SettingButton";
|
import { SettingButton } from "./components/SettingButton";
|
||||||
import { SettingSwitch } from "./components/SettingSwitch";
|
import { SettingSwitch } from "./components/SettingSwitch";
|
||||||
import { SettingSelect } from "./components/SettingSelect";
|
import { SettingSelect } from "./components/SettingSelect";
|
||||||
import { WebUiApi } from "./components/WebApi"
|
import { OB11Config, OB11ConfigWrapper } from "./components/WebUiApiOB11Config"
|
||||||
async function onSettingWindowCreated(view: Element) {
|
async function onSettingWindowCreated(view: Element) {
|
||||||
const isEmpty = (value: any) => value === undefined || value === undefined || value === '';
|
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) => {
|
const setOB11Config = (key: string, value: any) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,8 +135,8 @@ async function onSettingWindowCreated(view: Element) {
|
|||||||
)
|
)
|
||||||
]),
|
]),
|
||||||
SettingList([
|
SettingList([
|
||||||
SettingItem('GitHub 仓库', `https://github.com/`, SettingButton('点个星星', 'open-github')),
|
SettingItem('GitHub 仓库', `https://github.com/NapNeko/NapCatQQ`, SettingButton('点个星星', 'open-github')),
|
||||||
SettingItem('NapCat 文档', `https://`, SettingButton('看看文档', 'open-docs')),
|
SettingItem('NapCat 文档', ``, SettingButton('看看文档', 'open-docs')),
|
||||||
SettingItem('Telegram 群', `https://t.me/+nLZEnpne-pQ1OWFl`, SettingButton('进去逛逛', 'open-telegram')),
|
SettingItem('Telegram 群', `https://t.me/+nLZEnpne-pQ1OWFl`, SettingButton('进去逛逛', 'open-telegram')),
|
||||||
SettingItem('QQ 群', `545402644`, SettingButton('我要进去', 'open-qq-group')),
|
SettingItem('QQ 群', `545402644`, SettingButton('我要进去', 'open-qq-group')),
|
||||||
]),
|
]),
|
||||||
@ -147,7 +147,7 @@ async function onSettingWindowCreated(view: Element) {
|
|||||||
|
|
||||||
// 外链按钮
|
// 外链按钮
|
||||||
doc.querySelector('#open-github')?.addEventListener('click', () => {
|
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', () => {
|
doc.querySelector('#open-telegram')?.addEventListener('click', () => {
|
||||||
window.open('https://t.me/+nLZEnpne-pQ1OWFl')
|
window.open('https://t.me/+nLZEnpne-pQ1OWFl')
|
||||||
@ -156,7 +156,7 @@ async function onSettingWindowCreated(view: Element) {
|
|||||||
window.open('https://qm.qq.com/q/bDnHRG38aI')
|
window.open('https://qm.qq.com/q/bDnHRG38aI')
|
||||||
})
|
})
|
||||||
doc.querySelector('#open-docs')?.addEventListener('click', () => {
|
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 = {}) => {
|
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', () => {
|
doc.querySelector('#config-ob11-save')?.addEventListener('click', () => {
|
||||||
WebUiApi.setOB11Config(ob11Config);
|
OB11ConfigWrapper.SetOB11Config(ob11Config);
|
||||||
alert('保存成功');
|
alert('保存成功');
|
||||||
})
|
})
|
||||||
doc.body.childNodes.forEach((node) => {
|
doc.body.childNodes.forEach((node) => {
|
||||||
|
@ -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<OB11Config> {
|
|
||||||
// 返回示例配置
|
|
||||||
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();
|
|
@ -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 {
|
class WebUiApiOB11ConfigWrapper {
|
||||||
private retCredential: string = "";
|
private retCredential: string = "";
|
||||||
async Init(Credential: string) {
|
async Init(Credential: string) {
|
||||||
this.retCredential = Credential;
|
this.retCredential = Credential;
|
||||||
}
|
}
|
||||||
async GetConfig(): Promise<OB11Config> {
|
async GetOB11Config(): Promise<OB11Config> {
|
||||||
let ConfigResponse = await fetch('/api/OB11Config/GetConfig', {
|
let ConfigResponse = await fetch('/api/OB11Config/GetConfig', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
@ -22,7 +41,7 @@ class WebUiApiOB11ConfigWrapper {
|
|||||||
}
|
}
|
||||||
return {} as OB11Config;
|
return {} as OB11Config;
|
||||||
}
|
}
|
||||||
async SetConfig(config: OB11Config): Promise<Boolean> {
|
async SetOB11Config(config: OB11Config): Promise<Boolean> {
|
||||||
let ConfigResponse = await fetch('/api/OB11Config/SetConfig',
|
let ConfigResponse = await fetch('/api/OB11Config/SetConfig',
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
Loading…
x
Reference in New Issue
Block a user