Compare commits

...

2 Commits

Author SHA1 Message Date
手瓜一十雪
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
4 changed files with 15 additions and 20 deletions

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.9", "version": "4.1.11",
"icon": "./logo.png", "icon": "./logo.png",
"authors": [ "authors": [
{ {

View File

@@ -2,7 +2,7 @@
"name": "napcat", "name": "napcat",
"private": true, "private": true,
"type": "module", "type": "module",
"version": "4.1.9", "version": "4.1.11",
"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.9'; export const napCatVersion = '4.1.11';

View File

@@ -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 {