From 88fa0410911ded38c9edac4bf41c5c06c29f7de6 Mon Sep 17 00:00:00 2001 From: xiange Date: Sun, 11 Aug 2024 16:32:15 +0800 Subject: [PATCH] feat: add version info to UI --- packages/chili-ui/src/home/home.module.css | 7 +++++++ packages/chili-ui/src/home/home.ts | 4 ++++ packages/chili-ui/src/ribbon/ribbon.ts | 2 +- packages/global.d.ts | 2 ++ rspack.config.js | 3 +++ 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/chili-ui/src/home/home.module.css b/packages/chili-ui/src/home/home.module.css index f3d882e4..4945f89a 100644 --- a/packages/chili-ui/src/home/home.module.css +++ b/packages/chili-ui/src/home/home.module.css @@ -67,6 +67,13 @@ font-weight: bold; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; } + + .version { + font-size: 14px; + margin-top: 4px; + letter-spacing: 0px; + opacity: 0.56; + } } } diff --git a/packages/chili-ui/src/home/home.ts b/packages/chili-ui/src/home/home.ts index 04b369cd..9d18f7b5 100644 --- a/packages/chili-ui/src/home/home.ts +++ b/packages/chili-ui/src/home/home.ts @@ -75,6 +75,10 @@ export class Home extends HTMLElement { span({ textContent: "CHILI3D", }), + span({ + className: style.version, + textContent: __APP_VERSION__, + }), ), collection({ className: style.buttons, diff --git a/packages/chili-ui/src/ribbon/ribbon.ts b/packages/chili-ui/src/ribbon/ribbon.ts index 6efeec7f..9a92575c 100644 --- a/packages/chili-ui/src/ribbon/ribbon.ts +++ b/packages/chili-ui/src/ribbon/ribbon.ts @@ -135,7 +135,7 @@ export class Ribbon extends HTMLElement { className: style.icon, icon: "icon-chili", }), - span({ textContent: "Chili3D 2024 - dev" }), + span({ textContent: `Chili3D - v${__APP_VERSION__}` }), ), ), div( diff --git a/packages/global.d.ts b/packages/global.d.ts index c05db1b0..6514f03d 100644 --- a/packages/global.d.ts +++ b/packages/global.d.ts @@ -24,3 +24,5 @@ declare module "*.jpg" { const path: string; export default path; } + +declare var __APP_VERSION__: string; diff --git a/rspack.config.js b/rspack.config.js index 21942c72..4d5f1f57 100644 --- a/rspack.config.js +++ b/rspack.config.js @@ -64,6 +64,9 @@ const config = defineConfig({ }, ], }), + new rspack.DefinePlugin({ + __APP_VERSION__: JSON.stringify(require("./package.json").version), + }), new rspack.HtmlRspackPlugin({ template: "./public/index.html", inject: "body",