mirror of
https://github.com/certd/certd.git
synced 2026-07-20 05:37:32 +08:00
Compare commits
4 Commits
9bf7ca400f
...
a07dcb1cf5
| Author | SHA1 | Date | |
|---|---|---|---|
| a07dcb1cf5 | |||
| cb4a86d1d5 | |||
| 0499347588 | |||
| cb08e061d2 |
@@ -1 +1 @@
|
||||
00:34
|
||||
00:26
|
||||
|
||||
@@ -204,6 +204,7 @@ const hasNewVersion = computed(() => {
|
||||
return isNewVersion(version.value, latestVersion.value);
|
||||
});
|
||||
async function loadLatestVersion() {
|
||||
// version.value = settingsStore.app.version; //前端有缓存 可能不准确
|
||||
latestVersion.value = await api.GetLatestVersion();
|
||||
console.log("latestVersion", latestVersion.value);
|
||||
|
||||
|
||||
@@ -124,7 +124,9 @@ export class MainConfiguration {
|
||||
|
||||
this.app.getMiddleware().insertFirst(async (ctx: IMidwayKoaContext, next: NextFunction) => {
|
||||
await next();
|
||||
if (shouldSetDefaultNoCache(ctx.path, ctx.response.get('Cache-Control'))) {
|
||||
const path = ctx.path;
|
||||
// 如果是首页则强制设置为不缓存
|
||||
if (path === '/' || path === '/index.html' || shouldSetDefaultNoCache(path, ctx.response.get('Cache-Control')) ) {
|
||||
ctx.response.set('Cache-Control', 'public,max-age=0');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
/// <reference types="mocha" />
|
||||
/// <reference types="node" />
|
||||
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import { normalizeReleaseVersion } from "./app-controller.js";
|
||||
|
||||
describe("AppController.normalizeReleaseVersion", () => {
|
||||
it("normalizes AtomGit release tag names", () => {
|
||||
assert.equal(normalizeReleaseVersion({ tag_name: "v1.40.0" }), "1.40.0");
|
||||
assert.equal(normalizeReleaseVersion({ tag_name: "1.40.0" }), "1.40.0");
|
||||
});
|
||||
|
||||
it("falls back to release name when tag_name is empty", () => {
|
||||
assert.equal(normalizeReleaseVersion({ name: "v1.40.0" }), "1.40.0");
|
||||
});
|
||||
});
|
||||
@@ -3,6 +3,11 @@ import { BaseController, Constants, FileService, SysSettingsService, SysSiteInfo
|
||||
import { http, logger } from '@certd/basic';
|
||||
import { isComm } from '@certd/plus-core';
|
||||
|
||||
export function normalizeReleaseVersion(release: { tag_name?: string; name?: string }) {
|
||||
const version = release?.tag_name || release?.name || '';
|
||||
return version.replace(/^v/i, '');
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
@Provide()
|
||||
@@ -17,12 +22,12 @@ export class AppController extends BaseController {
|
||||
async latest(): Promise<any> {
|
||||
try {
|
||||
const res = await http.request({
|
||||
url: 'https://registry.npmmirror.com/@certd/pipeline',
|
||||
url: 'https://api.atomgit.com/api/v5/repos/certd/certd/releases/latest',
|
||||
method: 'get',
|
||||
logRes: false,
|
||||
timeout: 5000,
|
||||
});
|
||||
const latest = res['dist-tags'].latest;
|
||||
const latest = normalizeReleaseVersion(res);
|
||||
return this.ok(latest);
|
||||
} catch (e: any) {
|
||||
logger.error(e);
|
||||
|
||||
Reference in New Issue
Block a user