mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-23 23:06:06 +08:00
修复获取最新版本号
This commit is contained in:
parent
0f31cb5fcc
commit
0644edb62e
|
@ -380,19 +380,30 @@ export default class UserService {
|
||||||
|
|
||||||
public async checkUpdate() {
|
public async checkUpdate() {
|
||||||
try {
|
try {
|
||||||
const { version } = await import(config.versionFile);
|
const versionRegx = /.*export const version = (.*)\n/;
|
||||||
|
const logRegx = /.*export const changeLog = (.*)\n/;
|
||||||
|
const linkRegx = /.*export const changeLogLink = (.*)\n/;
|
||||||
|
|
||||||
|
const currentVersionFile = fs.readFileSync(config.versionFile, 'utf8');
|
||||||
|
const currentVersion = currentVersionFile.match(versionRegx)![1];
|
||||||
|
|
||||||
const lastVersionFileContent = await got.get(config.lastVersionFile);
|
const lastVersionFileContent = await got.get(config.lastVersionFile);
|
||||||
const filePath = `${config.rootPath}/.version.ts`;
|
const filePath = `${config.rootPath}/.version.ts`;
|
||||||
fs.writeFileSync(filePath, lastVersionFileContent.body, {
|
fs.writeFileSync(filePath, lastVersionFileContent.body, {
|
||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
});
|
});
|
||||||
const result = await import(config.versionFile);
|
const lastVersionFile = fs.readFileSync(config.lastVersionFile, 'utf8');
|
||||||
|
const lastVersion = lastVersionFile.match(versionRegx)![1];
|
||||||
|
const lastLog = lastVersionFile.match(logRegx)![1];
|
||||||
|
const lastLink = lastVersionFile.match(linkRegx)![1];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
code: 200,
|
code: 200,
|
||||||
data: {
|
data: {
|
||||||
hasNewVersion: version !== result.version,
|
hasNewVersion: currentVersion !== lastVersion,
|
||||||
...result,
|
lastVersion,
|
||||||
|
lastLog,
|
||||||
|
lastLink,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user