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;
}
async active(code: string) {
async active(code: string, inviteCode?: string) {
const plusRequestService = await this.getPlusRequestService();
return await plusRequestService.active(code);
return await plusRequestService.active(code, inviteCode);
}
async updateLicense(license: string) {

View File

@ -2,7 +2,7 @@
<html lang="en">
<head>
<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"/>
<title>Loading</title>
<script src="/static/icons/iconfont.js"></script>

View File

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

View File

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

View File

@ -1,11 +1,18 @@
import { Controller, Get, Provide } from '@midwayjs/core';
import { BaseController, Constants } from '@certd/lib-server';
import { Controller, Get, Inject, Provide } from '@midwayjs/core';
import { BaseController, Constants, FileService, SysSettingsService, SysSiteInfo } from '@certd/lib-server';
import { http, logger } from '@certd/basic';
import { isComm } from '@certd/plus-core';
/**
*/
@Provide()
@Controller('/api/app/')
export class AppController extends BaseController {
@Inject()
sysSettingsService: SysSettingsService;
@Inject()
fileService: FileService;
@Get('/latest', { summary: Constants.per.authOnly })
async latest(): Promise<any> {
const res = await http.request({
@ -20,4 +27,21 @@ export class AppController extends BaseController {
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' })
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);
}