perf: favicon支持自定义

pull/265/head
xiaojunnuo 2024-12-09 00:12:15 +08:00
parent 4042577c0b
commit 8b9c47daf1
6 changed files with 42 additions and 15 deletions

View File

@ -38,9 +38,9 @@ export class PlusService {
return installInfo.siteId; return installInfo.siteId;
} }
async active(code: string) { async active(code: string, inviteCode?: string) {
const plusRequestService = await this.getPlusRequestService(); const plusRequestService = await this.getPlusRequestService();
return await plusRequestService.active(code); return await plusRequestService.active(code, inviteCode);
} }
async updateLicense(license: string) { async updateLicense(license: string) {

View File

@ -2,7 +2,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"/> <meta charset="UTF-8"/>
<link rel="icon" href="/static/images/logo/logo.svg"/> <link rel="icon" href="/api/app/favicon"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Loading</title> <title>Loading</title>
<script src="/static/icons/iconfont.js"></script> <script src="/static/icons/iconfont.js"></script>

View File

@ -118,7 +118,8 @@ const expiredDays = computed(() => {
}); });
const formState = reactive({ const formState = reactive({
code: "" code: "",
inviteCode: ""
}); });
const router = useRouter(); const router = useRouter();
@ -268,7 +269,7 @@ function openUpgrade() {
activationCodeGetWay = ( activationCodeGetWay = (
<span> <span>
<a href="https://afdian.com/a/greper" target="_blank"> <a href="https://afdian.com/a/greper" target="_blank">
爱发电赞助VIP会员后获取专业版 爱发电赞助VIP会员¥29.9后获取一年期专业版激活码
</a> </a>
<span> 商业版请直接联系作者</span> <span> 商业版请直接联系作者</span>
</span> </span>
@ -327,6 +328,8 @@ function openUpgrade() {
<fs-copyable class="flex-1" v-model={computedSiteId.value}></fs-copyable> <fs-copyable class="flex-1" v-model={computedSiteId.value}></fs-copyable>
</div> </div>
<a-input class="mt-10" v-model:value={formState.code} placeholder={placeholder} /> <a-input class="mt-10" v-model:value={formState.code} placeholder={placeholder} />
<a-input class="mt-10" v-model:value={formState.inviteCode} placeholder={"邀请码【选填】可额外获得专业版30天/商业版15天时长"} />
</div> </div>
<div class="mt-10"> <div class="mt-10">

View File

@ -1,11 +1,11 @@
<template> <template>
<fs-page class="cd-page-account"> <fs-page class="cd-page-account">
<template #header> <!-- <template #header>-->
<div class="title"> <!-- <div class="title">-->
站点绑定 <!-- 站点绑定-->
<span class="sub">管理你安装过的Certd站点可以通过转移功能避免丢失VIP强烈建议绑定</span> <!-- <span class="sub">管理你安装过的Certd站点可以通过转移功能避免丢失VIP强烈建议绑定</span>-->
</div> <!-- </div>-->
</template> <!-- </template>-->
<iframe ref="iframeRef" class="account-iframe" :src="iframeSrcRef"> </iframe> <iframe ref="iframeRef" class="account-iframe" :src="iframeSrcRef"> </iframe>
</fs-page> </fs-page>

View File

@ -1,11 +1,18 @@
import { Controller, Get, Provide } from '@midwayjs/core'; import { Controller, Get, Inject, Provide } from '@midwayjs/core';
import { BaseController, Constants } from '@certd/lib-server'; import { BaseController, Constants, FileService, SysSettingsService, SysSiteInfo } from '@certd/lib-server';
import { http, logger } from '@certd/basic'; import { http, logger } from '@certd/basic';
import { isComm } from '@certd/plus-core';
/** /**
*/ */
@Provide() @Provide()
@Controller('/api/app/') @Controller('/api/app/')
export class AppController extends BaseController { export class AppController extends BaseController {
@Inject()
sysSettingsService: SysSettingsService;
@Inject()
fileService: FileService;
@Get('/latest', { summary: Constants.per.authOnly }) @Get('/latest', { summary: Constants.per.authOnly })
async latest(): Promise<any> { async latest(): Promise<any> {
const res = await http.request({ const res = await http.request({
@ -20,4 +27,21 @@ export class AppController extends BaseController {
return this.ok(''); return this.ok('');
} }
} }
@Get('/favicon', { summary: Constants.per.guest })
public async getFavicon() {
if (isComm()) {
const siteInfo = await this.sysSettingsService.getSetting<SysSiteInfo>(SysSiteInfo);
const favicon = siteInfo.logo;
if (favicon) {
const redirect = '/api/basic/file/download?key=' + favicon;
this.ctx.response.redirect(redirect);
this.ctx.response.set('Cache-Control', 'public,max-age=25920');
return;
}
}
const redirect = '/static/images/logo/logo.svg';
this.ctx.response.redirect(redirect);
this.ctx.response.set('Cache-Control', 'public,max-age=25920');
}
} }

View File

@ -14,9 +14,9 @@ export class SysPlusController extends BaseController {
@Post('/active', { summary: 'sys:settings:edit' }) @Post('/active', { summary: 'sys:settings:edit' })
async active(@Body(ALL) body) { async active(@Body(ALL) body) {
const { code } = body; const { code, inviteCode } = body;
await this.plusService.active(code); await this.plusService.active(code, inviteCode);
return this.ok(true); return this.ok(true);
} }