Compare commits

...

12 Commits

Author SHA1 Message Date
pk5ls20
5d2d8c7123
fix: #551
Some checks failed
Build Action / Build-LiteLoader (push) Failing after 3m37s
Build Action / Build-Shell (push) Failing after 2m58s
2024-11-20 17:00:01 +08:00
pk5ls20
23702f412c
chore: link 2024-11-20 16:23:04 +08:00
pk5ls20
31e94792c4
Merge pull request #548 from huankong233/main 2024-11-20 14:45:28 +08:00
huankong233
249afdce81 revent: 对手动拆分chunk进行回滚 2024-11-20 14:15:03 +08:00
huankong233
ee8f381341 feat: 增强webui对老设备的支持 2024-11-20 14:02:34 +08:00
Mlikiowa
83f3df76cd release: v4.1.12 2024-11-20 04:22:12 +00:00
手瓜一十雪
16195ca52b fix: old version handle 2024-11-20 12:21:45 +08:00
Mlikiowa
d5f492775e release: v4.1.11 2024-11-20 02:20:35 +00:00
手瓜一十雪
1f273a8799 Merge branch 'main' of https://github.com/NapNeko/NapCatQQ 2024-11-20 10:20:00 +08:00
手瓜一十雪
f44f6fd1e9 fix: 文件后清除 2024-11-20 10:19:43 +08:00
Mlikiowa
21ca13789e release: v4.1.9 2024-11-20 02:18:14 +00:00
手瓜一十雪
648faedca6 fix: #544 2024-11-20 10:16:41 +08:00
10 changed files with 69 additions and 49 deletions

View File

@ -34,7 +34,7 @@ NapCatQQ 是现代化的基于 NTQQ 的 Bot 协议端实现
## 回家旅途 ## 回家旅途
[QQ Group](https://qm.qq.com/q/haLGHixZ74) [QQ Group](https://qm.qq.com/q/NWP25OeV0c)
## 感谢他们 ## 感谢他们
感谢 [Lagrange](https://github.com/LagrangeDev/Lagrange.Core) 对本项目的大力支持 参考部分代码 已获授权 感谢 [Lagrange](https://github.com/LagrangeDev/Lagrange.Core) 对本项目的大力支持 参考部分代码 已获授权

View File

@ -4,7 +4,7 @@
"name": "NapCatQQ", "name": "NapCatQQ",
"slug": "NapCat.Framework", "slug": "NapCat.Framework",
"description": "高性能的 OneBot 11 协议实现", "description": "高性能的 OneBot 11 协议实现",
"version": "4.1.8", "version": "4.1.12",
"icon": "./logo.png", "icon": "./logo.png",
"authors": [ "authors": [
{ {

View File

@ -12,6 +12,7 @@
"dependencies": { "dependencies": {
"eslint-plugin-prettier": "^5.2.1", "eslint-plugin-prettier": "^5.2.1",
"qrcode": "^1.5.4", "qrcode": "^1.5.4",
"tdesign-icons-vue-next": "^0.3.3",
"tdesign-vue-next": "^1.10.3", "tdesign-vue-next": "^1.10.3",
"vue": "^3.5.12", "vue": "^3.5.12",
"vue-router": "^4.4.5" "vue-router": "^4.4.5"
@ -20,10 +21,12 @@
"@eslint/eslintrc": "^3.1.0", "@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.14.0", "@eslint/js": "^9.14.0",
"@types/qrcode": "^1.5.5", "@types/qrcode": "^1.5.5",
"@vitejs/plugin-legacy": "^5.4.3",
"@vitejs/plugin-vue": "^5.1.4", "@vitejs/plugin-vue": "^5.1.4",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^9.1.0",
"eslint-plugin-vue": "^9.31.0", "eslint-plugin-vue": "^9.31.0",
"globals": "^15.12.0", "globals": "^15.12.0",
"terser": "^5.36.0",
"typescript": "~5.6.2", "typescript": "~5.6.2",
"vite": "^5.4.10", "vite": "^5.4.10",
"vue-tsc": "^2.1.8" "vue-tsc": "^2.1.8"

View File

@ -1,10 +1,17 @@
import { defineConfig } from 'vite'; import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue'; import vue from '@vitejs/plugin-vue';
import legacy from '@vitejs/plugin-legacy';
import path from 'path'; import path from 'path';
// https://vite.dev/config/ // https://vite.dev/config/
export default defineConfig({ export default defineConfig({
plugins: [vue()], plugins: [
vue(),
legacy({
targets: ['defaults', 'not IE 11'],
modernPolyfills: ['web.structured-clone'],
}),
],
base: './', base: './',
resolve: { resolve: {
alias: { alias: {
@ -17,14 +24,18 @@ export default defineConfig({
}, },
}, },
build: { build: {
chunkSizeWarningLimit: 4000,
rollupOptions: { rollupOptions: {
output: { output: {
manualChunks(id) { chunkFileNames: 'static/js/[name]-[hash].js',
entryFileNames: 'static/js/[name]-[hash].js',
assetFileNames: 'static/[ext]/[name]-[hash].[ext]',
manualChunks(id: string) {
if (id.includes('node_modules')) { if (id.includes('node_modules')) {
return id.toString().split('node_modules/')[1].split('/')[0].toString(); return id.toString().split('node_modules/')[1].split('/')[0].toString();
} }
} },
} },
} },
} },
}); });

View File

@ -2,7 +2,7 @@
"name": "napcat", "name": "napcat",
"private": true, "private": true,
"type": "module", "type": "module",
"version": "4.1.8", "version": "4.1.12",
"scripts": { "scripts": {
"build:framework": "npm run build:webui && vite build --mode framework", "build:framework": "npm run build:webui && vite build --mode framework",
"build:shell": "npm run build:webui && vite build --mode shell", "build:shell": "npm run build:webui && vite build --mode shell",

View File

@ -1 +1 @@
export const napCatVersion = '4.1.8'; export const napCatVersion = '4.1.12';

View File

@ -107,7 +107,7 @@ export class NTQQFileApi {
}; };
} }
async createValidSendPicElement(context: MessageContext, picPath: string, summary: string = '', subType: 0 | 1 = 0,): Promise<SendPicElement> { async createValidSendPicElement(context: MessageContext, picPath: string, summary: string = '', subType: 0 | 1 = 0): Promise<SendPicElement> {
const { md5, fileName, path, fileSize } = await this.core.apis.FileApi.uploadFile(picPath, ElementType.PIC, subType); const { md5, fileName, path, fileSize } = await this.core.apis.FileApi.uploadFile(picPath, ElementType.PIC, subType);
if (fileSize === 0) { if (fileSize === 0) {
throw new Error('文件异常大小为0'); throw new Error('文件异常大小为0');
@ -412,15 +412,17 @@ export class NTQQFileApi {
} }
const url: string = element.originImageUrl ?? ''; const url: string = element.originImageUrl ?? '';
const md5HexStr = element.md5HexStr; const md5HexStr = element.md5HexStr;
const fileMd5 = element.md5HexStr; const fileMd5 = element.md5HexStr;
const parsedUrl = new URL(IMAGE_HTTP_HOST + url);
if (url) { const imageAppid = parsedUrl.searchParams.get('appid');
const parsedUrl = new URL(IMAGE_HTTP_HOST + url); const isNTV2 = imageAppid && ['1406', '1407'].includes(imageAppid);
const imageFileId = parsedUrl.searchParams.get('fileid');
if (url && isNTV2 && imageFileId) {
const rkeyData = await this.getRkeyData(); const rkeyData = await this.getRkeyData();
return this.getImageUrlFromParsedUrl(parsedUrl, rkeyData); return this.getImageUrlFromParsedUrl(imageFileId, imageAppid, rkeyData);
} }
return this.getImageUrlFromMd5(fileMd5, md5HexStr); return this.getImageUrlFromMd5(fileMd5, md5HexStr);
} }
@ -462,19 +464,12 @@ export class NTQQFileApi {
return rkeyData; return rkeyData;
} }
private getImageUrlFromParsedUrl(parsedUrl: URL, rkeyData: any): string { private getImageUrlFromParsedUrl(imageFileId: string, appid: string, rkeyData: any): string {
const imageAppid = parsedUrl.searchParams.get('appid'); const rkey = appid === '1406' ? rkeyData.private_rkey : rkeyData.group_rkey;
const isNTV2 = imageAppid && ['1406', '1407'].includes(imageAppid); if (rkeyData.online_rkey) {
const imageFileId = parsedUrl.searchParams.get('fileid'); return IMAGE_HTTP_HOST_NT + `/download?appid=${appid}&fileid=${imageFileId}&rkey=${rkey}`;
if (isNTV2 && rkeyData.online_rkey) {
const rkey = imageAppid === '1406' ? rkeyData.private_rkey : rkeyData.group_rkey;
return IMAGE_HTTP_HOST_NT + `/download?appid=${imageAppid}&fileid=${imageFileId}&rkey=${rkey}`;
} else if (isNTV2 && imageFileId) {
const rkey = imageAppid === '1406' ? rkeyData.private_rkey : rkeyData.group_rkey;
return IMAGE_HTTP_HOST + `/download?appid=${imageAppid}&fileid=${imageFileId}&rkey=${rkey}`;
} }
return IMAGE_HTTP_HOST + `/download?appid=${appid}&fileid=${imageFileId}&rkey=${rkey}`;
return '';
} }
private getImageUrlFromMd5(fileMd5: string | undefined, md5HexStr: string | undefined): string { private getImageUrlFromMd5(fileMd5: string | undefined, md5HexStr: string | undefined): string {

View File

@ -867,9 +867,11 @@ export class OneBotMsgApi {
guildId: '', guildId: '',
peerUid: peer.peerUid, peerUid: peer.peerUid,
}, returnMsg.msgId); }, returnMsg.msgId);
deleteAfterSentFiles.forEach(file => { setTimeout(() => {
fsPromise.unlink(file).then().catch(e => this.core.context.logger.logError.bind(this.core.context.logger)('发送消息删除文件失败', e)); deleteAfterSentFiles.forEach(file => {
}); fsPromise.unlink(file).then().catch(e => this.core.context.logger.logError.bind(this.core.context.logger)('发送消息删除文件失败', e));
});
}, 60000);
return returnMsg; return returnMsg;
} }

View File

@ -149,6 +149,9 @@ export function mergeOneBotConfigs(
if (userConfig.musicSignUrl !== undefined) { if (userConfig.musicSignUrl !== undefined) {
mergedConfig.musicSignUrl = userConfig.musicSignUrl; mergedConfig.musicSignUrl = userConfig.musicSignUrl;
} }
if(userConfig.enableLocalFile2Url !== undefined) {
mergedConfig.enableLocalFile2Url = userConfig.enableLocalFile2Url;
}
return mergedConfig; return mergedConfig;
} }

View File

@ -4,6 +4,7 @@ import { LogWrapper } from '@/common/log';
import { NapCatPathWrapper } from '@/common/path'; import { NapCatPathWrapper } from '@/common/path';
import { WebUiConfigWrapper } from './src/helper/config'; import { WebUiConfigWrapper } from './src/helper/config';
import { RequestUtil } from '@/common/request'; import { RequestUtil } from '@/common/request';
import { isIP } from "node:net";
const app = express(); const app = express();
@ -46,24 +47,29 @@ export async function InitWebUi(logger: LogWrapper, pathWrapper: NapCatPathWrapp
}); });
app.use(config.prefix + '/api', ALLRouter); app.use(config.prefix + '/api', ALLRouter);
app.listen(config.port, config.host, async () => { app.listen(config.port, config.host, async () => {
const normalizeHost = (host: string) => {
if (host === '0.0.0.0') return '127.0.0.1';
if (isIP(host) === 6) return `[${host}]`;
return host;
};
const createUrl = (host: string, path: string, token: string) => {
const url = new URL(`http://${normalizeHost(host)}`);
url.port = config.port.toString();
url.pathname = `${config.prefix}${path}`;
url.searchParams.set('token', token);
return url.toString();
};
log(`[NapCat] [WebUi] Current WebUi is running at http://${config.host}:${config.port}${config.prefix}`); 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] Login Token is ${config.token}`);
log( log(`[NapCat] [WebUi] WebUi User Panel Url: ${createUrl(config.host, '/webui', config.token)}`);
`[NapCat] [WebUi] WebUi User Panel Url: http://${config.host}:${config.port}${config.prefix}/webui?token=${config.token}` log(`[NapCat] [WebUi] WebUi Local Panel Url: ${createUrl('127.0.0.1', '/webui', config.token)}`);
); try {
log( const publishUrl = 'https://ip.011102.xyz/';
`[NapCat] [WebUi] WebUi Local Panel Url: http://127.0.0.1:${config.port}${config.prefix}/webui?token=${config.token}` const data = await RequestUtil.HttpGetJson<{ IP: { IP: string } }>(publishUrl, 'GET', {}, {}, true, true);
); log("IP data", data);
//获取上网Ip log(`[NapCat] [WebUi] WebUi Publish Panel Url: ${createUrl(data.IP.IP, '/webui', config.token)}`);
//https://www.ip.cn/api/index?ip&type=0 } catch (err) {
RequestUtil.HttpGetJson<{ IP: { IP: string } }>('https://ip.011102.xyz/', 'GET', {}, {}, true, true) logger.logError(`[NapCat] [WebUi] Get Publish Panel Url Error: ${err}`);
.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}`);
});
}); });
} }