mirror of https://github.com/certd/certd
chore: env
parent
e0466409d0
commit
81d6c0ebdf
|
@ -6,6 +6,6 @@ VITE_APP_SLOGAN=让你的证书永不过期
|
||||||
VITE_APP_COPYRIGHT_YEAR=2021-2024
|
VITE_APP_COPYRIGHT_YEAR=2021-2024
|
||||||
VITE_APP_COPYRIGHT_NAME=handsfree.work
|
VITE_APP_COPYRIGHT_NAME=handsfree.work
|
||||||
VITE_APP_COPYRIGHT_URL=https://certd.handsfree.work
|
VITE_APP_COPYRIGHT_URL=https://certd.handsfree.work
|
||||||
VITE_APP_LOGO_PATH=./images/logo/logo.svg
|
VITE_APP_LOGO=./images/logo/logo.svg
|
||||||
VITE_APP_PROJECT_PATH=https://github.com/certd/certd
|
VITE_APP_PROJECT_PATH=https://github.com/certd/certd
|
||||||
VITE_APP_ICP_NO=
|
|
||||||
|
|
|
@ -1,37 +1,25 @@
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import _ from "lodash-es";
|
import _ from "lodash-es";
|
||||||
export function getEnvValue(key: string) {
|
|
||||||
// @ts-ignore
|
|
||||||
return import.meta.env["VITE_APP_" + key];
|
|
||||||
}
|
|
||||||
|
|
||||||
export class EnvConfig {
|
export class EnvConfig {
|
||||||
API: string;
|
MODE: string = import.meta.env.MODE;
|
||||||
MODE: string;
|
API: string = import.meta.env.VITE_APP_API;
|
||||||
STORAGE: string;
|
STORAGE: string = import.meta.env.VITE_APP_STORAGE;
|
||||||
TITLE: string;
|
TITLE: string = import.meta.env.VITE_APP_TITLE;
|
||||||
SLOGAN: string;
|
SLOGAN: string = import.meta.env.VITE_APP_SLOGAN;
|
||||||
COPYRIGHT_YEAR: string;
|
COPYRIGHT_YEAR: string = import.meta.env.VITE_APP_COPYRIGHT_YEAR;
|
||||||
COPYRIGHT_NAME: string;
|
COPYRIGHT_NAME: string = import.meta.env.VITE_APP_COPYRIGHT_NAME;
|
||||||
COPYRIGHT_URL: string;
|
COPYRIGHT_URL: string = import.meta.env.VITE_APP_COPYRIGHT_URL;
|
||||||
LOGO_PATH: string;
|
LOGO: string = import.meta.env.VITE_APP_LOGO;
|
||||||
PM_ENABLED: string;
|
PM_ENABLED: string = import.meta.env.VITE_APP_PM_ENABLED;
|
||||||
ICP_NO: string;
|
ICP_NO: string = import.meta.env.VITE_APP_ICP_NO;
|
||||||
constructor() {
|
|
||||||
this.init();
|
|
||||||
}
|
|
||||||
|
|
||||||
init() {
|
init(env: any) {
|
||||||
// @ts-ignore
|
for (const key in this) {
|
||||||
_.forEach(import.meta.env, (value, key) => {
|
if (this.hasOwnProperty(key)) {
|
||||||
if (key.startsWith("VITE_APP")) {
|
this[key] = env[key];
|
||||||
key = key.replace("VITE_APP_", "");
|
|
||||||
// @ts-ignore
|
|
||||||
this[key] = value;
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
// @ts-ignore
|
|
||||||
this.MODE = import.meta.env.MODE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get(key: string, defaultValue: string) {
|
get(key: string, defaultValue: string) {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<div class="d2-page-cover">
|
<div class="d2-page-cover">
|
||||||
<div class="d2-page-cover__title">
|
<div class="d2-page-cover__title">
|
||||||
<div class="title-line">
|
<div class="title-line">
|
||||||
<img width="50" :src="envRef.LOGO_PATH" />
|
<img width="50" :src="envRef.LOGO" />
|
||||||
{{ envRef.TITLE }} v{{ version }}
|
{{ envRef.TITLE }} v{{ version }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -46,10 +46,12 @@ import { useSettingStore } from "/@/store/modules/settings";
|
||||||
|
|
||||||
interface FormState {
|
interface FormState {
|
||||||
registerEnabled: boolean;
|
registerEnabled: boolean;
|
||||||
|
managerOtherUserPipeline: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const formState = reactive<Partial<FormState>>({
|
const formState = reactive<Partial<FormState>>({
|
||||||
registerEnabled: false
|
registerEnabled: false,
|
||||||
|
managerOtherUserPipeline: false
|
||||||
});
|
});
|
||||||
|
|
||||||
async function loadSysPublicSettings() {
|
async function loadSysPublicSettings() {
|
||||||
|
@ -61,7 +63,6 @@ async function loadSysPublicSettings() {
|
||||||
loadSysPublicSettings();
|
loadSysPublicSettings();
|
||||||
const settingsStore = useSettingStore();
|
const settingsStore = useSettingStore();
|
||||||
const onFinish = async (form: any) => {
|
const onFinish = async (form: any) => {
|
||||||
console.log("Success:", form);
|
|
||||||
await api.PublicSettingsSave(form);
|
await api.PublicSettingsSave(form);
|
||||||
await settingsStore.loadSysSettings();
|
await settingsStore.loadSysSettings();
|
||||||
notification.success({
|
notification.success({
|
||||||
|
|
|
@ -1,23 +1,8 @@
|
||||||
import { Rule, RuleType } from '@midwayjs/validate';
|
|
||||||
import { Controller, Get, Inject, Provide } from '@midwayjs/core';
|
import { Controller, Get, Inject, Provide } from '@midwayjs/core';
|
||||||
import { BaseController } from '../../../basic/base-controller.js';
|
import { BaseController } from '../../../basic/base-controller.js';
|
||||||
import { Constants } from '../../../basic/constants.js';
|
import { Constants } from '../../../basic/constants.js';
|
||||||
import { SysSettingsService } from '../../system/service/sys-settings-service.js';
|
import { SysSettingsService } from '../../system/service/sys-settings-service.js';
|
||||||
import { SysInstallInfo, SysPublicSettings } from '../../system/service/models.js';
|
import { SysInstallInfo, SysPublicSettings, SysSiteInfo } from '../../system/service/models.js';
|
||||||
|
|
||||||
export class SmsCodeReq {
|
|
||||||
@Rule(RuleType.number().required())
|
|
||||||
phoneCode: number;
|
|
||||||
|
|
||||||
@Rule(RuleType.string().required())
|
|
||||||
mobile: string;
|
|
||||||
|
|
||||||
@Rule(RuleType.string().required().max(10))
|
|
||||||
randomStr: string;
|
|
||||||
|
|
||||||
@Rule(RuleType.number().required().max(4))
|
|
||||||
imgCode: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
|
@ -38,4 +23,10 @@ export class BasicSettingsController extends BaseController {
|
||||||
const settings = await this.sysSettingsService.getSetting(SysInstallInfo);
|
const settings = await this.sysSettingsService.getSetting(SysInstallInfo);
|
||||||
return this.ok(settings);
|
return this.ok(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Get('/siteInfo', { summary: Constants.per.guest })
|
||||||
|
public async getSiteInfo() {
|
||||||
|
const settings = await this.sysSettingsService.getSetting(SysSiteInfo);
|
||||||
|
return this.ok(settings);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,3 +38,13 @@ export class SysLicenseInfo extends BaseSettings {
|
||||||
static __access__ = 'private';
|
static __access__ = 'private';
|
||||||
license?: string;
|
license?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class SysSiteInfo extends BaseSettings {
|
||||||
|
static __title__ = '站点信息';
|
||||||
|
static __key__ = 'sys.site';
|
||||||
|
static __access__ = 'public';
|
||||||
|
TITLE?: string;
|
||||||
|
SLOGAN?: string;
|
||||||
|
LOGO?: string;
|
||||||
|
ICP_NO?: string;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue