From a5ad239ae3ee336cd10c995fcae97f8d7f00d0b9 Mon Sep 17 00:00:00 2001 From: ZhongxuYang Date: Tue, 30 Jul 2024 17:20:35 +0800 Subject: [PATCH] feat: add show version number --- package.json | 1 + pnpm-lock.yaml | 21 +++++++++++++++++++++ src/views/dashboard/components/Admin.vue | 16 ++++++++++++++-- types/env.d.ts | 2 ++ vite.config.ts | 12 +++++++++++- 5 files changed, 49 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index b8a96c6a..139b500a 100644 --- a/package.json +++ b/package.json @@ -69,6 +69,7 @@ "unocss": "0.61.3", "vite": "5.3.3", "vite-plugin-svg-icons": "2.0.1", + "vite-plugin-version-mark": "^0.1.0", "vite-svg-loader": "5.1.0", "vitest": "2.0.3", "vue-eslint-parser": "9.4.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5488cdad..ec2de03e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -135,6 +135,9 @@ importers: vite-plugin-svg-icons: specifier: 2.0.1 version: 2.0.1(vite@5.3.3(@types/node@20.14.10)(sass@1.77.8)) + vite-plugin-version-mark: + specifier: ^0.1.0 + version: 0.1.0(vite@5.3.3(@types/node@20.14.10)(sass@1.77.8)) vite-svg-loader: specifier: 5.1.0 version: 5.1.0(vue@3.4.31(typescript@5.5.3)) @@ -587,46 +590,55 @@ packages: resolution: {integrity: sha512-P9bSiAUnSSM7EmyRK+e5wgpqai86QOSv8BwvkGjLwYuOpaeomiZWifEos517CwbG+aZl1T4clSE1YqqH2JRs+g==} cpu: [arm] os: [linux] + libc: [glibc] '@rollup/rollup-linux-arm-musleabihf@4.18.1': resolution: {integrity: sha512-5RnjpACoxtS+aWOI1dURKno11d7krfpGDEn19jI8BuWmSBbUC4ytIADfROM1FZrFhQPSoP+KEa3NlEScznBTyQ==} cpu: [arm] os: [linux] + libc: [musl] '@rollup/rollup-linux-arm64-gnu@4.18.1': resolution: {integrity: sha512-8mwmGD668m8WaGbthrEYZ9CBmPug2QPGWxhJxh/vCgBjro5o96gL04WLlg5BA233OCWLqERy4YUzX3bJGXaJgQ==} cpu: [arm64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-arm64-musl@4.18.1': resolution: {integrity: sha512-dJX9u4r4bqInMGOAQoGYdwDP8lQiisWb9et+T84l2WXk41yEej8v2iGKodmdKimT8cTAYt0jFb+UEBxnPkbXEQ==} cpu: [arm64] os: [linux] + libc: [musl] '@rollup/rollup-linux-powerpc64le-gnu@4.18.1': resolution: {integrity: sha512-V72cXdTl4EI0x6FNmho4D502sy7ed+LuVW6Ym8aI6DRQ9hQZdp5sj0a2usYOlqvFBNKQnLQGwmYnujo2HvjCxQ==} cpu: [ppc64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-riscv64-gnu@4.18.1': resolution: {integrity: sha512-f+pJih7sxoKmbjghrM2RkWo2WHUW8UbfxIQiWo5yeCaCM0TveMEuAzKJte4QskBp1TIinpnRcxkquY+4WuY/tg==} cpu: [riscv64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-s390x-gnu@4.18.1': resolution: {integrity: sha512-qb1hMMT3Fr/Qz1OKovCuUM11MUNLUuHeBC2DPPAWUYYUAOFWaxInaTwTQmc7Fl5La7DShTEpmYwgdt2hG+4TEg==} cpu: [s390x] os: [linux] + libc: [glibc] '@rollup/rollup-linux-x64-gnu@4.18.1': resolution: {integrity: sha512-7O5u/p6oKUFYjRbZkL2FLbwsyoJAjyeXHCU3O4ndvzg2OFO2GinFPSJFGbiwFDaCFc+k7gs9CF243PwdPQFh5g==} cpu: [x64] os: [linux] + libc: [glibc] '@rollup/rollup-linux-x64-musl@4.18.1': resolution: {integrity: sha512-pDLkYITdYrH/9Cv/Vlj8HppDuLMDUBmgsM0+N+xLtFd18aXgM9Nyqupb/Uw+HeidhfYg2lD6CXvz6CjoVOaKjQ==} cpu: [x64] os: [linux] + libc: [musl] '@rollup/rollup-win32-arm64-msvc@4.18.1': resolution: {integrity: sha512-W2ZNI323O/8pJdBGil1oCauuCzmVd9lDmWBBqxYZcOqWD6aWqJtVBQ1dFrF4dYpZPks6F+xCZHfzG5hYlSHZ6g==} @@ -3031,6 +3043,11 @@ packages: peerDependencies: vite: '>=2.0.0' + vite-plugin-version-mark@0.1.0: + resolution: {integrity: sha512-Na9KG6anEwAQVUKm3DOl4AufzvkgWlOogBnGAMR6YEcMMOYMl45/0KqMuvNxGd0WR8aW8cpUiGHDCFlIZ15YeQ==} + peerDependencies: + vite: '*' + vite-svg-loader@5.1.0: resolution: {integrity: sha512-M/wqwtOEjgb956/+m5ZrYT/Iq6Hax0OakWbokj8+9PXOnB7b/4AxESHieEtnNEy7ZpjsjYW1/5nK8fATQMmRxw==} peerDependencies: @@ -6490,6 +6507,10 @@ snapshots: transitivePeerDependencies: - supports-color + vite-plugin-version-mark@0.1.0(vite@5.3.3(@types/node@20.14.10)(sass@1.77.8)): + dependencies: + vite: 5.3.3(@types/node@20.14.10)(sass@1.77.8) + vite-svg-loader@5.1.0(vue@3.4.31(typescript@5.5.3)): dependencies: svgo: 3.3.2 diff --git a/src/views/dashboard/components/Admin.vue b/src/views/dashboard/components/Admin.vue index ee36c60a..2255f91c 100644 --- a/src/views/dashboard/components/Admin.vue +++ b/src/views/dashboard/components/Admin.vue @@ -1,14 +1,26 @@ + + diff --git a/types/env.d.ts b/types/env.d.ts index 78566444..ca334fe5 100644 --- a/types/env.d.ts +++ b/types/env.d.ts @@ -9,3 +9,5 @@ interface ImportMetaEnv { interface ImportMeta { readonly env: ImportMetaEnv } + +declare const __V3_ADMIN_VITE_VERSION__: string diff --git a/vite.config.ts b/vite.config.ts index 1675cb8e..fb98e89e 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -7,6 +7,7 @@ import vueJsx from "@vitejs/plugin-vue-jsx" import { createSvgIconsPlugin } from "vite-plugin-svg-icons" import svgLoader from "vite-svg-loader" import UnoCSS from "unocss/vite" +import { vitePluginVersionMark } from "vite-plugin-version-mark" /** 配置项文档:https://cn.vitejs.dev/config */ export default ({ mode }: ConfigEnv): UserConfigExport => { @@ -92,7 +93,16 @@ export default ({ mode }: ConfigEnv): UserConfigExport => { symbolId: "icon-[dir]-[name]" }), /** UnoCSS */ - UnoCSS() + UnoCSS(), + /** version mark */ + vitePluginVersionMark({ + // command: 'git describe --tags', + // ifGitSHA: true, + // ifShortSHA: true, + ifMeta: true, + ifLog: true, + ifGlobal: true + }) ], /** Vitest 单元测试配置:https://cn.vitest.dev/config */ test: {