Fix version tag formatting and error handling

Update packet.ts to prefix napCatVersion with 'v' in the error message link. In vite-plugin-version.js, improve formatting of catch blocks, ensure returned tags do not include a leading 'v', and standardize fallback version to '0.0.0'.
This commit is contained in:
手瓜一十雪 2025-11-25 23:03:55 +08:00
parent 7c701781a1
commit d31f0a45b4
2 changed files with 6 additions and 6 deletions

View File

@ -54,7 +54,7 @@ export class NTQQPacketApi {
const table = typedOffset[qqVer + '-' + os.arch()];
if (!table) {
const err = `[Core] [Packet] PacketBackend 不支持当前QQ版本架构${qqVer}-${os.arch()}
https://github.com/NapNeko/NapCatQQ/releases/tag/${napCatVersion} 配置正确的QQ版本`;
https://github.com/NapNeko/NapCatQQ/releases/tag/v${napCatVersion} 配置正确的QQ版本`;
this.logger.logError(err);
this.errStack.push(err);
return false;

View File

@ -26,7 +26,7 @@ export default function vitePluginNapcatVersion () {
const data = JSON.parse(fs.readFileSync(cacheFile, 'utf8'));
if (data?.tag) return data.tag;
}
} catch {}
} catch { }
return null;
}
@ -36,7 +36,7 @@ export default function vitePluginNapcatVersion () {
cacheFile,
JSON.stringify({ tag, time: new Date().toISOString() }, null, 2)
);
} catch {}
} catch { }
}
async function fetchLatestTag () {
@ -58,7 +58,7 @@ export default function vitePluginNapcatVersion () {
try {
const json = JSON.parse(data);
if (Array.isArray(json) && json[0]?.name) {
resolve(json[0].name);
resolve(json[0].name.replace(/^v/, ''));
} else reject(new Error('Invalid GitHub tag response'));
} catch (e) {
reject(e);
@ -79,7 +79,7 @@ export default function vitePluginNapcatVersion () {
return tag;
} catch (e) {
console.warn('[vite-plugin-napcat-version] Failed to fetch tag:', e.message);
return cached ?? 'v0.0.0';
return cached ?? '0.0.0';
}
}
@ -110,7 +110,7 @@ export default function vitePluginNapcatVersion () {
lastTag = tag;
ctx.server?.ws.send({ type: 'full-reload' });
}
} catch {}
} catch { }
}
},
};