diff --git a/projects/admin/src/assets/config.json b/projects/admin/src/assets/config.json
new file mode 100644
index 0000000..2a7ec2a
--- /dev/null
+++ b/projects/admin/src/assets/config.json
@@ -0,0 +1,17 @@
+{
+ "websiteInfo": {
+ "name": "营养配餐实训系统"
+ },
+ "assets": {
+ "logo": "/assets/images/jl-logo.png",
+ "favicon": "/assets/favicon.ico",
+ "loginBackground": "/assets/images/jl-logo.png"
+ },
+ "contactInfo": {
+ "phoneNumber": "19181752603"
+ },
+ "copyrightInfo": {
+ "icpLicense": "蜀ICP备2023038072号",
+ "companyName": ""
+ }
+}
diff --git a/projects/cdk/src/app-settings/index.ts b/projects/cdk/src/app-settings/index.ts
index 799de80..205e2f2 100644
--- a/projects/cdk/src/app-settings/index.ts
+++ b/projects/cdk/src/app-settings/index.ts
@@ -1 +1 @@
-export const appName = "营养配餐系统";
+export const appName = '营养配餐系统'
diff --git a/projects/cdk/src/shared/components/copyright/copyright.component.html b/projects/cdk/src/shared/components/copyright/copyright.component.html
index 4aae36c..94a2723 100644
--- a/projects/cdk/src/shared/components/copyright/copyright.component.html
+++ b/projects/cdk/src/shared/components/copyright/copyright.component.html
@@ -1,10 +1,6 @@
diff --git a/projects/cdk/src/shared/components/copyright/copyright.component.ts b/projects/cdk/src/shared/components/copyright/copyright.component.ts
index 8453cdd..44e651e 100644
--- a/projects/cdk/src/shared/components/copyright/copyright.component.ts
+++ b/projects/cdk/src/shared/components/copyright/copyright.component.ts
@@ -1,10 +1,12 @@
-import { Component } from "@angular/core";
+import { Component, Input } from '@angular/core'
@Component({
- selector: "lib-copyright",
- templateUrl: "./copyright.component.html",
- styleUrls: ["./copyright.component.less"],
+ selector: 'lib-copyright',
+ templateUrl: './copyright.component.html',
+ styleUrls: ['./copyright.component.less'],
})
export class CopyrightComponent {
- year = new Date().getFullYear();
+ @Input() icpLicense?: string
+ @Input() companyName?: string
+ year = new Date().getFullYear()
}
diff --git a/projects/cdk/src/types/index.ts b/projects/cdk/src/types/index.ts
index d7d4b73..18c3840 100644
--- a/projects/cdk/src/types/index.ts
+++ b/projects/cdk/src/types/index.ts
@@ -1,59 +1,86 @@
-export type AnyObject = { [k: string]: any };
+export type AnyObject = { [k: string]: any }
-export type DecSafeAny = any;
+export type DecSafeAny = any
-export type DecText = number | string;
+export type DecText = number | string
-export type Augmented = O & AnyObject;
+export type Augmented = O & AnyObject
-export type Optional = Omit & Partial>;
+export type Optional = Omit & Partial>
export type NutrientInterface = {
- key: string;
- measurement: string;
- nrv: number;
- value: string;
-};
+ key: string
+ measurement: string
+ nrv: number
+ value: string
+}
export type OptionItemInterface = Augmented<{
- label: string;
- value: string;
-}>;
+ label: string
+ value: string
+}>
export interface ResponseType {
- body: T;
- code: number;
- desc: string;
- success: boolean;
+ body: T
+ code: number
+ desc: string
+ success: boolean
}
-export type MyResponse = ResponseType;
+export type MyResponse = ResponseType
export interface TableListColumns {
- key: string;
- title: string;
- visible?: boolean;
- width?: string;
- sort?: boolean;
- order?: number;
- disabled?: boolean;
- coverStorage?: boolean;
+ key: string
+ title: string
+ visible?: boolean
+ width?: string
+ sort?: boolean
+ order?: number
+ disabled?: boolean
+ coverStorage?: boolean
}
export interface TableOperation {
- title: string;
- href?: string;
- link?: string[];
- target?: string;
- premissions: string[];
- danger?: boolean;
- disabled?: boolean;
- onClick?: (v: DecSafeAny) => void;
- visible?: (v: DecSafeAny) => boolean;
+ title: string
+ href?: string
+ link?: string[]
+ target?: string
+ premissions: string[]
+ danger?: boolean
+ disabled?: boolean
+ onClick?: (v: DecSafeAny) => void
+ visible?: (v: DecSafeAny) => boolean
}
export interface PageResult {
- total: number;
- content: T[];
- totalElements: number;
- totalPages: number;
+ total: number
+ content: T[]
+ totalElements: number
+ totalPages: number
+}
+
+export interface WebSiteConfig {
+ websiteInfo: WebsiteInfo
+ assets: Assets
+ contactInfo: ContactInfo
+ copyrightInfo: CopyrightInfo
+}
+
+export interface Assets {
+ logo: string
+ favicon: string
+ loginBackground: string
+}
+
+export interface ContactInfo {
+ phoneNumber: string
+}
+
+export interface CopyrightInfo {
+ icpLicense: string
+ companyName: string
+ yeah: number
+}
+
+export interface WebsiteInfo {
+ name: string
}
diff --git a/projects/client/src/app/app.component.ts b/projects/client/src/app/app.component.ts
index c2c895d..8035a9c 100644
--- a/projects/client/src/app/app.component.ts
+++ b/projects/client/src/app/app.component.ts
@@ -1,10 +1,27 @@
-import { Component } from '@angular/core';
+import { Component } from '@angular/core'
+import { WebSiteConfig } from '@cdk/types'
+import { ConfigService } from './services/config.service'
@Component({
- selector: 'app-root',
- templateUrl: './app.component.html',
- styleUrls: ['./app.component.less']
+ selector: 'app-root',
+ templateUrl: './app.component.html',
+ styleUrls: ['./app.component.less'],
})
export class AppComponent {
- title = 'client';
+ title = 'client'
+
+ appConfig: WebSiteConfig | null = null
+ constructor(private configService: ConfigService) {}
+
+ ngOnInit() {
+ this.appConfig = this.configService.getConfig()
+ if (this.appConfig) {
+ if (this.appConfig?.assets?.favicon) {
+ ;(document.querySelector('#favicon') as HTMLLinkElement).href = this.appConfig.assets.favicon
+ }
+ if (this.appConfig?.websiteInfo?.name) {
+ document.title = this.appConfig.websiteInfo.name + (document.title ? ' - ' + document.title : '')
+ }
+ }
+ }
}
diff --git a/projects/client/src/app/app.module.ts b/projects/client/src/app/app.module.ts
index 686b69e..9e4c39d 100644
--- a/projects/client/src/app/app.module.ts
+++ b/projects/client/src/app/app.module.ts
@@ -1,4 +1,4 @@
-import { NgModule } from '@angular/core'
+import { APP_INITIALIZER, NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { NZ_DATE_CONFIG, NZ_DATE_LOCALE, NZ_I18N } from 'ng-zorro-antd/i18n'
@@ -41,6 +41,11 @@ import { IngredientModule } from '@cdk/ingredient/ingredient.module'
import { NgxPermissionsModule } from 'ngx-permissions'
import { TemplatePageTitleStrategy } from './services/title.service'
import { TitleStrategy } from '@angular/router'
+import { ConfigService } from './services/config.service'
+
+function initializeApp(configService: ConfigService) {
+ return () => configService.loadConfig().toPromise() // 返回一个 Promise
+}
registerLocaleData(zh)
@@ -95,6 +100,14 @@ registerLocaleData(zh)
firstDayOfWeek: 1,
},
},
+
+ ConfigService,
+ {
+ provide: APP_INITIALIZER,
+ useFactory: initializeApp,
+ deps: [ConfigService],
+ multi: true,
+ },
],
bootstrap: [AppComponent],
})
diff --git a/projects/client/src/app/components/app-layout/app-layout.component.html b/projects/client/src/app/components/app-layout/app-layout.component.html
index cbd54bd..4c3fc97 100644
--- a/projects/client/src/app/components/app-layout/app-layout.component.html
+++ b/projects/client/src/app/components/app-layout/app-layout.component.html
@@ -7,9 +7,9 @@