-
-
-
\ No newline at end of file
+
diff --git a/napcat.webui/src/components/QQLogin.vue b/napcat.webui/src/components/QQLogin.vue
index 3ec8da12..13d4b674 100644
--- a/napcat.webui/src/components/QQLogin.vue
+++ b/napcat.webui/src/components/QQLogin.vue
@@ -2,67 +2,91 @@
QQ Login
- Quick Login
- QR Code
+ Quick Login
+ QR Code
-
-
\ No newline at end of file
+
diff --git a/napcat.webui/src/pages/network/HttpClientComponent.vue b/napcat.webui/src/pages/network/HttpClientComponent.vue
index 45f02d8f..ce55b9f9 100644
--- a/napcat.webui/src/pages/network/HttpClientComponent.vue
+++ b/napcat.webui/src/pages/network/HttpClientComponent.vue
@@ -1,29 +1,42 @@
-
-
HTTP Client 配置
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
HTTP Client 配置
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
\ No newline at end of file
+
diff --git a/napcat.webui/src/pages/network/HttpServerComponent.vue b/napcat.webui/src/pages/network/HttpServerComponent.vue
index a43286b0..1474135a 100644
--- a/napcat.webui/src/pages/network/HttpServerComponent.vue
+++ b/napcat.webui/src/pages/network/HttpServerComponent.vue
@@ -1,38 +1,57 @@
-
-
HTTP Server 配置
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
HTTP Server 配置
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
\ No newline at end of file
+
diff --git a/napcat.webui/src/pages/network/WebsocketClientComponent.vue b/napcat.webui/src/pages/network/WebsocketClientComponent.vue
index 52312230..07b46018 100644
--- a/napcat.webui/src/pages/network/WebsocketClientComponent.vue
+++ b/napcat.webui/src/pages/network/WebsocketClientComponent.vue
@@ -1,32 +1,47 @@
-
-
WebSocket Client 配置
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
WebSocket Client 配置
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
\ No newline at end of file
+
diff --git a/napcat.webui/src/pages/network/WebsocketServerComponent.vue b/napcat.webui/src/pages/network/WebsocketServerComponent.vue
index c6d6d1f3..57e762b9 100644
--- a/napcat.webui/src/pages/network/WebsocketServerComponent.vue
+++ b/napcat.webui/src/pages/network/WebsocketServerComponent.vue
@@ -1,38 +1,57 @@
-
-
WebSocket Server 配置
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
WebSocket Server 配置
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
\ No newline at end of file
+
diff --git a/napcat.webui/src/router/index.ts b/napcat.webui/src/router/index.ts
index b615fb7b..50f67c11 100644
--- a/napcat.webui/src/router/index.ts
+++ b/napcat.webui/src/router/index.ts
@@ -1,4 +1,4 @@
-import { createRouter, createWebHashHistory } from 'vue-router'
+import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router';
import Dashboard from '../components/Dashboard.vue';
import BasicInfo from '../pages/BasicInfo.vue';
import AboutUs from '../pages/AboutUs.vue';
@@ -8,25 +8,25 @@ import QQLogin from '../components/QQLogin.vue';
import WebUiLogin from '../components/WebUiLogin.vue';
import OtherConfig from '../pages/OtherConfig.vue';
-const routes = [
- { path: '/', redirect: '/webui' },
- { path: '/webui', component: WebUiLogin, name: 'WebUiLogin' },
- { path: '/qqlogin', component: QQLogin, name: 'QQLogin' },
- {
- path: '/dashboard',
- component: Dashboard,
- children: [
- { path: '', redirect: 'basic-info' },
- { path: 'basic-info', component: BasicInfo, name: 'BasicInfo' },
- { path: 'network-config', component: NetWork, name: 'NetWork' },
- { path: 'log-view', component: LogView, name: 'LogView' },
- { path: 'other-config', component: OtherConfig, name: 'OtherConfig' },
- { path: 'about-us', component: AboutUs, name: 'AboutUs' }
- ]
- }
-]
+const routes: Array
= [
+ { path: '/', redirect: '/webui' },
+ { path: '/webui', component: WebUiLogin, name: 'WebUiLogin' },
+ { path: '/qqlogin', component: QQLogin, name: 'QQLogin' },
+ {
+ path: '/dashboard',
+ component: Dashboard,
+ children: [
+ { path: '', redirect: 'basic-info' },
+ { path: 'basic-info', component: BasicInfo, name: 'BasicInfo' },
+ { path: 'network-config', component: NetWork, name: 'NetWork' },
+ { path: 'log-view', component: LogView, name: 'LogView' },
+ { path: 'other-config', component: OtherConfig, name: 'OtherConfig' },
+ { path: 'about-us', component: AboutUs, name: 'AboutUs' },
+ ],
+ },
+];
export const router = createRouter({
- history: createWebHashHistory(),
- routes,
-})
\ No newline at end of file
+ history: createWebHashHistory(),
+ routes,
+});
diff --git a/napcat.webui/src/shims-vue.d.ts b/napcat.webui/src/shims-vue.d.ts
deleted file mode 100644
index ab70f827..00000000
--- a/napcat.webui/src/shims-vue.d.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-declare module '*.vue' {
- import { DefineComponent } from 'vue';
- const component: DefineComponent<{}, {}, any>;
- export default component;
-}
\ No newline at end of file
diff --git a/napcat.webui/tsconfig.app.json b/napcat.webui/tsconfig.app.json
deleted file mode 100644
index cb88a5a6..00000000
--- a/napcat.webui/tsconfig.app.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "compilerOptions": {
- "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
- "target": "ES2020",
- "useDefineForClassFields": true,
- "module": "ESNext",
- "lib": ["ES2020", "DOM", "DOM.Iterable"],
- "skipLibCheck": true,
-
- /* Bundler mode */
- "moduleResolution": "Bundler",
- "allowImportingTsExtensions": true,
- "isolatedModules": true,
- "moduleDetection": "force",
- "noEmit": true,
- "jsx": "preserve",
-
- /* Linting */
- "strict": true,
- "noUnusedLocals": true,
- "noUnusedParameters": true,
- "noFallthroughCasesInSwitch": true,
- "noUncheckedSideEffectImports": true
- },
- "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"]
-}
diff --git a/napcat.webui/tsconfig.json b/napcat.webui/tsconfig.json
index 1ffef600..bf12aee2 100644
--- a/napcat.webui/tsconfig.json
+++ b/napcat.webui/tsconfig.json
@@ -1,7 +1,34 @@
{
- "files": [],
- "references": [
- { "path": "./tsconfig.app.json" },
- { "path": "./tsconfig.node.json" }
- ]
+ "compilerOptions": {
+ "target": "ESNext",
+ "jsx": "preserve",
+ "jsxImportSource": "vue",
+ "lib": [
+ "DOM",
+ "DOM.Iterable"
+ ],
+ "baseUrl": ".",
+ "module": "esnext",
+ "moduleResolution": "bundler",
+ "paths": {
+ "@/*": [
+ "src/*"
+ ]
+ },
+ "resolveJsonModule": true,
+ "types": [
+ "vite/client"
+ ],
+ "strict": true,
+ "strictNullChecks": true,
+ "noUnusedLocals": true,
+ "esModuleInterop": true,
+ "forceConsistentCasingInFileNames": true,
+ "isolatedModules": true,
+ "experimentalDecorators": true,
+ "useDefineForClassFields": true
+ },
+ "include": ["src"],
+ "exclude": ["node_modules"],
+ "references": [{"path": "./tsconfig.node.json"}]
}
diff --git a/napcat.webui/tsconfig.node.json b/napcat.webui/tsconfig.node.json
index abcd7f0d..f026910e 100644
--- a/napcat.webui/tsconfig.node.json
+++ b/napcat.webui/tsconfig.node.json
@@ -1,24 +1,11 @@
{
- "compilerOptions": {
- "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
- "target": "ES2022",
- "lib": ["ES2023"],
- "module": "ESNext",
- "skipLibCheck": true,
-
- /* Bundler mode */
- "moduleResolution": "Bundler",
- "allowImportingTsExtensions": true,
- "isolatedModules": true,
- "moduleDetection": "force",
- "noEmit": true,
-
- /* Linting */
- "strict": true,
- "noUnusedLocals": true,
- "noUnusedParameters": true,
- "noFallthroughCasesInSwitch": true,
- "noUncheckedSideEffectImports": true
- },
- "include": ["vite.config.ts"]
+ "compilerOptions": {
+ "composite": true,
+ "skipLibCheck": true,
+ "module": "ESNext",
+ "moduleResolution": "bundler",
+ "allowSyntheticDefaultImports": true,
+ "strictNullChecks": true
+ },
+ "include": ["vite.config.ts"]
}
diff --git a/napcat.webui/vite.config.ts b/napcat.webui/vite.config.ts
index 64327ab8..22d3b08e 100644
--- a/napcat.webui/vite.config.ts
+++ b/napcat.webui/vite.config.ts
@@ -1,8 +1,8 @@
-import { defineConfig } from 'vite'
-import vue from '@vitejs/plugin-vue'
+import { defineConfig } from 'vite';
+import vue from '@vitejs/plugin-vue';
// https://vite.dev/config/
export default defineConfig({
- plugins: [vue()],
- base: './'
-})
+ plugins: [vue()],
+ base: './',
+});
diff --git a/package.json b/package.json
index 30999567..3977ddca 100644
--- a/package.json
+++ b/package.json
@@ -48,9 +48,9 @@
},
"dependencies": {
"express": "^5.0.0",
- "silk-wasm": "^3.6.1",
- "ws": "^8.18.0",
+ "fluent-ffmpeg": "^2.1.2",
"qrcode-terminal": "^0.12.0",
- "fluent-ffmpeg": "^2.1.2"
+ "silk-wasm": "^3.6.1",
+ "ws": "^8.18.0"
}
-}
\ No newline at end of file
+}
diff --git a/src/core/apis/file.ts b/src/core/apis/file.ts
index 17fc0036..5954b657 100644
--- a/src/core/apis/file.ts
+++ b/src/core/apis/file.ts
@@ -300,18 +300,18 @@ export class NTQQFileApi {
element.elementType === ElementType.FILE
) {
switch (element.elementType) {
- case ElementType.PIC:
+ case ElementType.PIC:
element.picElement!.sourcePath = elementResults[elementIndex];
- break;
- case ElementType.VIDEO:
+ break;
+ case ElementType.VIDEO:
element.videoElement!.filePath = elementResults[elementIndex];
- break;
- case ElementType.PTT:
+ break;
+ case ElementType.PTT:
element.pttElement!.filePath = elementResults[elementIndex];
- break;
- case ElementType.FILE:
+ break;
+ case ElementType.FILE:
element.fileElement!.filePath = elementResults[elementIndex];
- break;
+ break;
}
elementIndex++;
}
diff --git a/src/onebot/action/go-cqhttp/GetFriendMsgHistory.ts b/src/onebot/action/go-cqhttp/GetFriendMsgHistory.ts
index 7efd553a..15cc53cb 100644
--- a/src/onebot/action/go-cqhttp/GetFriendMsgHistory.ts
+++ b/src/onebot/action/go-cqhttp/GetFriendMsgHistory.ts
@@ -45,7 +45,7 @@ export default class GetFriendMsgHistory extends BaseAction {
await Promise.all(msgList.map(async msg => {
msg.id = MessageUnique.createUniqueMsgId({ guildId: '', chatType: msg.chatType, peerUid: msg.peerUid }, msg.msgId);
}));
- let network = Object.values(this.obContext.configLoader.configData.network) as Array;
+ const network = Object.values(this.obContext.configLoader.configData.network) as Array;
//烘焙消息
const ob11MsgList = (await Promise.all(
msgList.map(msg => this.obContext.apis.MsgApi.parseMessage(msg, network.flat().find(e => e.name === adapter)?.messagePostFormat ?? 'array')))
diff --git a/src/onebot/action/go-cqhttp/GetGroupMsgHistory.ts b/src/onebot/action/go-cqhttp/GetGroupMsgHistory.ts
index 2f1fbd2c..63047433 100644
--- a/src/onebot/action/go-cqhttp/GetGroupMsgHistory.ts
+++ b/src/onebot/action/go-cqhttp/GetGroupMsgHistory.ts
@@ -43,9 +43,9 @@ export default class GoCQHTTPGetGroupMsgHistory extends BaseAction {
msg.id = MessageUnique.createUniqueMsgId({ guildId: '', chatType: msg.chatType, peerUid: msg.peerUid }, msg.msgId);
}));
- let network = Object.values(this.obContext.configLoader.configData.network) as Array;
+ const network = Object.values(this.obContext.configLoader.configData.network) as Array;
//烘焙消息
- let msgFormat = network.flat().find(e => e.name === adapter)?.messagePostFormat ?? 'array';
+ const msgFormat = network.flat().find(e => e.name === adapter)?.messagePostFormat ?? 'array';
const ob11MsgList = (await Promise.all(
msgList.map(msg => this.obContext.apis.MsgApi.parseMessage(msg, msgFormat)))
).filter(msg => msg !== undefined);
diff --git a/src/onebot/action/group/GetGroupEssence.ts b/src/onebot/action/group/GetGroupEssence.ts
index 602c8325..374874b8 100644
--- a/src/onebot/action/group/GetGroupEssence.ts
+++ b/src/onebot/action/group/GetGroupEssence.ts
@@ -31,8 +31,8 @@ export class GetGroupEssence extends BaseAction {
}
async _handle(payload: Payload, adapter: string) {
- let network = Object.values(this.obContext.configLoader.configData.network) as Array;
- let msgFormat = network.flat().find(e => e.name === adapter)?.messagePostFormat ?? 'array';
+ const network = Object.values(this.obContext.configLoader.configData.network) as Array;
+ const msgFormat = network.flat().find(e => e.name === adapter)?.messagePostFormat ?? 'array';
const msglist = (await this.core.apis.WebApi.getGroupEssenceMsgAll(payload.group_id.toString())).flatMap((e) => e.data.msg_list);
if (!msglist) {
throw new Error('获取失败');
diff --git a/src/onebot/action/msg/GetMsg.ts b/src/onebot/action/msg/GetMsg.ts
index c32f9c5f..58f61eea 100644
--- a/src/onebot/action/msg/GetMsg.ts
+++ b/src/onebot/action/msg/GetMsg.ts
@@ -24,8 +24,8 @@ class GetMsg extends BaseAction {
async _handle(payload: Payload, adapter: string) {
// log("history msg ids", Object.keys(msgHistory));
- let network = Object.values(this.obContext.configLoader.configData.network) as Array;
- let msgFormat = network.flat().find(e => e.name === adapter)?.messagePostFormat ?? 'array';
+ const network = Object.values(this.obContext.configLoader.configData.network) as Array;
+ const msgFormat = network.flat().find(e => e.name === adapter)?.messagePostFormat ?? 'array';
if (!payload.message_id) {
throw Error('参数message_id不能为空');
}
diff --git a/src/onebot/action/user/GetRecentContact.ts b/src/onebot/action/user/GetRecentContact.ts
index 706a97ec..8ce2c58d 100644
--- a/src/onebot/action/user/GetRecentContact.ts
+++ b/src/onebot/action/user/GetRecentContact.ts
@@ -17,9 +17,9 @@ export default class GetRecentContact extends BaseAction {
async _handle(payload: Payload, adapter: string) {
const ret = await this.core.apis.UserApi.getRecentContactListSnapShot(+(payload.count || 10));
- let network = Object.values(this.obContext.configLoader.configData.network) as Array;
+ const network = Object.values(this.obContext.configLoader.configData.network) as Array;
//烘焙消息
- let msgFormat = network.flat().find(e => e.name === adapter)?.messagePostFormat ?? 'array';
+ const msgFormat = network.flat().find(e => e.name === adapter)?.messagePostFormat ?? 'array';
return await Promise.all(ret.info.changedList.map(async (t) => {
const FastMsg = await this.core.apis.MsgApi.getMsgsByMsgId({ chatType: t.chatType, peerUid: t.peerUid }, [t.msgId]);
if (FastMsg.msgList.length > 0) {
diff --git a/src/onebot/config/config.ts b/src/onebot/config/config.ts
index 66dae188..be5b4220 100644
--- a/src/onebot/config/config.ts
+++ b/src/onebot/config/config.ts
@@ -85,7 +85,7 @@ export const defaultOnebotConfig = createDefaultConfig({
},
musicSignUrl: "",
enableLocalFile2Url: false
-})
+});
export const mergeNetworkDefaultConfig = {
httpServers: httpServerDefaultConfigs,
httpClients: httpClientDefaultConfigs,
diff --git a/src/onebot/index.ts b/src/onebot/index.ts
index 7d5d75a8..aeaafdaf 100644
--- a/src/onebot/index.ts
+++ b/src/onebot/index.ts
@@ -100,7 +100,7 @@ export class NapCatOneBot11Adapter {
this.context.logger.setLogSelfInfo(selfInfo);
}).catch(this.context.logger.logError.bind(this.context.logger));
- let serviceInfo = await this.creatOneBotLog(ob11Config);
+ const serviceInfo = await this.creatOneBotLog(ob11Config);
this.context.logger.log(`[Notice] [OneBot11] ${serviceInfo}`);
// //创建NetWork服务
@@ -497,14 +497,14 @@ export class NapCatOneBot11Adapter {
}
private async emitMsg(message: RawMessage) {
- let network = Object.values(this.configLoader.configData.network) as Array;
+ const network = Object.values(this.configLoader.configData.network) as Array;
this.context.logger.logDebug('收到新消息 RawMessage', message);
this.apis.MsgApi.parseMessageV2(message).then((ob11Msg) => {
if (!ob11Msg) return;
const isSelfMsg = ob11Msg.stringMsg.user_id.toString() == this.core.selfInfo.uin || ob11Msg.arrayMsg.user_id.toString() == this.core.selfInfo.uin;
this.context.logger.logDebug('转化为 OB11Message', ob11Msg);
- let msgMap: Map = new Map();
- let enable_client: string[] = [];
+ const msgMap: Map = new Map();
+ const enable_client: string[] = [];
network.flat().filter(e => e.enable).map(e => {
enable_client.push(e.name);
if (e.messagePostFormat == 'string') {
@@ -518,7 +518,7 @@ export class NapCatOneBot11Adapter {
}
});
- let debug_network = network.flat().filter(e => e.enable && e.debug);
+ const debug_network = network.flat().filter(e => e.enable && e.debug);
if (debug_network.length > 0) {
for (const adapter of debug_network) {
if (adapter.name) {
@@ -534,7 +534,7 @@ export class NapCatOneBot11Adapter {
return;
}
- let notreportSelf_network = network.flat().filter(e => e.enable && !e.reportSelfMessage);
+ const notreportSelf_network = network.flat().filter(e => e.enable && !e.reportSelfMessage);
if (isSelfMsg) {
for (const adapter of notreportSelf_network) {
msgMap.delete(adapter.name);
diff --git a/src/onebot/network/index.ts b/src/onebot/network/index.ts
index 57c0b0eb..7373a9bb 100644
--- a/src/onebot/network/index.ts
+++ b/src/onebot/network/index.ts
@@ -38,7 +38,7 @@ export class OB11NetworkManager {
return Promise.all(Array.from(map.entries()).map(([name, event]) => {
const adapter = this.adapters.get(name);
if (adapter) {
- return adapter.onEvent(event);
+ return adapter.onEvent(event);
}
}));
}
diff --git a/src/webui/index.ts b/src/webui/index.ts
index de9c83c1..68ac18b1 100644
--- a/src/webui/index.ts
+++ b/src/webui/index.ts
@@ -37,6 +37,7 @@ export async function InitWebUi(logger: LogWrapper, pathWrapper: NapCatPathWrapp
app.use(config.prefix + '/webui', express.static(pathWrapper.staticPath));
//挂载API接口
// 添加CORS支持
+ // TODO:
app.use((req, res, next) => {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
@@ -47,22 +48,22 @@ export async function InitWebUi(logger: LogWrapper, pathWrapper: NapCatPathWrapp
app.listen(config.port, config.host, async () => {
log(`[NapCat] [WebUi] Current WebUi is running at http://${config.host}:${config.port}${config.prefix}`);
log(`[NapCat] [WebUi] Login Token is ${config.token}`);
- log(`[NapCat] [WebUi] WebUi User Panel Url: http://${config.host}:${config.port}${config.prefix}/webui?token=${config.token}`);
- log(`[NapCat] [WebUi] WebUi Local Panel Url: http://127.0.0.1:${config.port}${config.prefix}/webui?token=${config.token}`);
+ log(
+ `[NapCat] [WebUi] WebUi User Panel Url: http://${config.host}:${config.port}${config.prefix}/webui?token=${config.token}`
+ );
+ log(
+ `[NapCat] [WebUi] WebUi Local Panel Url: http://127.0.0.1:${config.port}${config.prefix}/webui?token=${config.token}`
+ );
//获取上网Ip
//https://www.ip.cn/api/index?ip&type=0
- RequestUtil.HttpGetJson<{ IP: {IP:string} }>(
- 'https://ip.011102.xyz/',
- 'GET',
- {},
- {},
- true,
- true
- ).then((data) => {
- log(`[NapCat] [WebUi] WebUi Publish Panel Url: http://${data.IP.IP}:${config.port}${config.prefix}/webui/?token=${config.token}`);
- }).catch((err) => {
- logger.logError.bind(logger)(`[NapCat] [WebUi] Get Publish Panel Url Error: ${err}`);
- });
-
+ RequestUtil.HttpGetJson<{ IP: { IP: string } }>('https://ip.011102.xyz/', 'GET', {}, {}, true, true)
+ .then((data) => {
+ log(
+ `[NapCat] [WebUi] WebUi Publish Panel Url: http://${data.IP.IP}:${config.port}${config.prefix}/webui/?token=${config.token}`
+ );
+ })
+ .catch((err) => {
+ logger.logError.bind(logger)(`[NapCat] [WebUi] Get Publish Panel Url Error: ${err}`);
+ });
});
}