chore: agent

pull/213/head
xiaojunnuo 2024-10-10 18:38:22 +08:00
parent 0e4b72c65d
commit 68e5ea1cad
8 changed files with 95 additions and 9 deletions

View File

@ -87,3 +87,15 @@ jobs:
registry.cn-shenzhen.aliyuncs.com/handsfree/certd:${{steps.get_certd_version.outputs.result}}-armv7 registry.cn-shenzhen.aliyuncs.com/handsfree/certd:${{steps.get_certd_version.outputs.result}}-armv7
greper/certd:armv7 greper/certd:armv7
greper/certd:${{steps.get_certd_version.outputs.result}}-armv7 greper/certd:${{steps.get_certd_version.outputs.result}}-armv7
- name: Build agent
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
push: true
context: ./packages/ui/agent/
tags: |
registry.cn-shenzhen.aliyuncs.com/handsfree/certd-agent:latest
registry.cn-shenzhen.aliyuncs.com/handsfree/certd-agent:${{steps.get_certd_version.outputs.result}}
greper/certd-agent:latest
greper/certd-agent:${{steps.get_certd_version.outputs.result}}

View File

@ -54,3 +54,11 @@ export class SysSiteInfo extends BaseSettings {
logo?: string; logo?: string;
loginLogo?: string; loginLogo?: string;
} }
export class SysSiteEnv {
agent?: {
enabled?: boolean;
contactText?: string;
contactLink?: string;
};
}

View File

@ -0,0 +1,7 @@
FROM greper/certd:latest
ENV certd_agent_enabled=true
CMD ["npm", "run","start"]

View File

@ -1,4 +1,5 @@
import { request } from "../service"; import { request } from "../service";
import { SiteEnv, SiteInfo } from "/@/store/modules/settings";
export type SysPublicSetting = { export type SysPublicSetting = {
registerEnabled: boolean; registerEnabled: boolean;
@ -24,14 +25,20 @@ export async function getInstallInfo(): Promise<SysInstallInfo> {
}); });
} }
export async function getSiteInfo(): Promise<SysInstallInfo> { export async function getSiteInfo(): Promise<SiteInfo> {
return await request({ return await request({
url: "/basic/settings/siteInfo", url: "/basic/settings/siteInfo",
method: "get" method: "get"
}); });
} }
export async function getSiteEnv(): Promise<SiteEnv> {
return await request({
url: "/basic/settings/siteEnv",
method: "get"
});
}
export async function bindUrl(data): Promise<SysInstallInfo> { export async function bindUrl(data: any): Promise<any> {
return await request({ return await request({
url: "/sys/plus/bindUrl", url: "/sys/plus/bindUrl",
method: "post", method: "post",

View File

@ -164,9 +164,27 @@ function openUpgrade() {
okText: "激活", okText: "激活",
width: 900, width: 900,
content: () => { content: () => {
let activationCodeGetWay: any = null;
if (settingStore.siteEnv.agent.enabled != null) {
const agent = settingStore.siteEnv.agent;
if (agent.enabled === false) {
activationCodeGetWay = (
<a href="https://afdian.com/a/greper" target="_blank">
爱发电赞助VIP会员后获取
</a>
);
} else {
activationCodeGetWay = (
<a href={agent.contactLink} target="_blank">
{agent.contactText}
</a>
);
}
}
const vipLabel = settingStore.vipLabel; const vipLabel = settingStore.vipLabel;
const slots = []; const slots = [];
for (const key in vipTypeDefine) { for (const key in vipTypeDefine) {
// @ts-ignore
const item = vipTypeDefine[key]; const item = vipTypeDefine[key];
const vipBlockClass = `vip-block ${key === settingStore.plusInfo.vipType ? "current" : ""}`; const vipBlockClass = `vip-block ${key === settingStore.plusInfo.vipType ? "current" : ""}`;
slots.push( slots.push(
@ -174,7 +192,7 @@ function openUpgrade() {
<div class={vipBlockClass}> <div class={vipBlockClass}>
<h3 class="block-header">{item.title}</h3> <h3 class="block-header">{item.title}</h3>
<ul> <ul>
{item.privilege.map((p) => ( {item.privilege.map((p: string) => (
<li> <li>
<fs-icon class="color-green" icon="ion:checkmark-sharp" /> <fs-icon class="color-green" icon="ion:checkmark-sharp" />
{p} {p}
@ -203,9 +221,7 @@ function openUpgrade() {
<div class="mt-10"> <div class="mt-10">
没有激活码 没有激活码
<a href="https://afdian.com/a/greper" target="_blank"> {activationCodeGetWay}
爱发电赞助VIP会员后获取
</a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -35,8 +35,16 @@ export interface SettingState {
}; };
siteInfo: SiteInfo; siteInfo: SiteInfo;
plusInfo?: PlusInfo; plusInfo?: PlusInfo;
siteEnv?: SiteEnv;
} }
export type SiteEnv = {
agent?: {
enabled?: boolean;
contactText?: string;
contactLink?: string;
};
};
export type SiteInfo = { export type SiteInfo = {
title: string; title: string;
slogan: string; slogan: string;
@ -94,7 +102,14 @@ export const useSettingStore = defineStore({
accountServerBaseUrl: "", accountServerBaseUrl: "",
appKey: "" appKey: ""
}, },
siteInfo: defaultSiteInfo siteInfo: defaultSiteInfo,
siteEnv: {
agent: {
enabled: undefined,
contactText: "",
contactLink: ""
}
}
}), }),
getters: { getters: {
getThemeConfig(): any { getThemeConfig(): any {
@ -132,6 +147,7 @@ export const useSettingStore = defineStore({
}, },
async loadSysSettings() { async loadSysSettings() {
await this.loadSysPublicSettings(); await this.loadSysPublicSettings();
await this.loadSiteEnv();
await this.loadInstallInfo(); await this.loadInstallInfo();
await this.loadPlusInfo(); await this.loadPlusInfo();
await this.loadSiteInfo(); await this.loadSiteInfo();
@ -145,12 +161,16 @@ export const useSettingStore = defineStore({
const installInfo = await basicApi.getInstallInfo(); const installInfo = await basicApi.getInstallInfo();
_.merge(this.installInfo, installInfo); _.merge(this.installInfo, installInfo);
}, },
async loadSiteEnv() {
const siteEnv = await basicApi.getSiteEnv();
_.merge(this.siteEnv, siteEnv);
},
async loadPlusInfo() { async loadPlusInfo() {
this.plusInfo = await basicApi.getPlusInfo(); this.plusInfo = await basicApi.getPlusInfo();
}, },
async loadSiteInfo() { async loadSiteInfo() {
const isComm = this.isComm; const isComm = this.isComm;
let siteInfo = {}; let siteInfo: SiteInfo;
if (isComm) { if (isComm) {
siteInfo = await basicApi.getSiteInfo(); siteInfo = await basicApi.getSiteInfo();
if (siteInfo.logo) { if (siteInfo.logo) {

View File

@ -115,6 +115,11 @@ const development = {
// 仅在匹配路径到 /api/upload 的时候去解析 body 中的文件信息 // 仅在匹配路径到 /api/upload 的时候去解析 body 中的文件信息
match: /\/api\/basic\/file\/upload/, match: /\/api\/basic\/file\/upload/,
}, },
agent: {
enabled: false,
contactText: '',
contactLink: '',
},
} as MidwayConfig; } as MidwayConfig;
mergeConfig(development, 'development'); mergeConfig(development, 'development');

View File

@ -1,5 +1,5 @@
import { ALL, Body, Config, Controller, Get, Inject, Provide } from '@midwayjs/core'; import { ALL, Body, Config, Controller, Get, Inject, Provide } from '@midwayjs/core';
import { BaseController, Constants, SysInstallInfo, SysPublicSettings, SysSettingsService, SysSiteInfo } from '@certd/lib-server'; import { BaseController, Constants, SysInstallInfo, SysPublicSettings, SysSettingsService, SysSiteEnv, SysSiteInfo } from '@certd/lib-server';
import { AppKey, getPlusInfo } from '@certd/pipeline'; import { AppKey, getPlusInfo } from '@certd/pipeline';
/** /**
@ -12,6 +12,9 @@ export class BasicSettingsController extends BaseController {
@Config('account.server.baseUrl') @Config('account.server.baseUrl')
accountServerBaseUrl: any; accountServerBaseUrl: any;
@Config('agent')
agentConfig: SysSiteEnv['agent'];
@Get('/public', { summary: Constants.per.guest }) @Get('/public', { summary: Constants.per.guest })
public async getSysPublic() { public async getSysPublic() {
const settings = await this.sysSettingsService.getSetting(SysPublicSettings); const settings = await this.sysSettingsService.getSetting(SysPublicSettings);
@ -32,6 +35,14 @@ export class BasicSettingsController extends BaseController {
return this.ok(settings); return this.ok(settings);
} }
@Get('/siteEnv', { summary: Constants.per.guest })
public async getSiteEnv() {
const env: SysSiteEnv = {
agent: this.agentConfig,
};
return this.ok(env);
}
@Get('/plusInfo', { summary: Constants.per.guest }) @Get('/plusInfo', { summary: Constants.per.guest })
async plusInfo(@Body(ALL) body: any) { async plusInfo(@Body(ALL) body: any) {
const info = getPlusInfo(); const info = getPlusInfo();