mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-12-18 20:30:08 +08:00
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:
parent
7c701781a1
commit
d31f0a45b4
@ -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;
|
||||
|
||||
@ -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 { }
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user