mirror of
https://github.com/JefferyHcool/BiliNote.git
synced 2026-06-12 03:00:09 +08:00
fix(frontend): 同步关于页版本号
This commit is contained in:
12
.github/workflows/docker-build.yml
vendored
12
.github/workflows/docker-build.yml
vendored
@@ -42,6 +42,16 @@ jobs:
|
|||||||
type=sha,prefix=
|
type=sha,prefix=
|
||||||
type=raw,value=latest,enable={{is_default_branch}}
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
|
|
||||||
|
- name: Resolve app version
|
||||||
|
id: app-version
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
|
||||||
|
echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "version=" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Build and Push Docker Image
|
- name: Build and Push Docker Image
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
@@ -50,6 +60,8 @@ jobs:
|
|||||||
push: true
|
push: true
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
build-args: |
|
||||||
|
VITE_APP_VERSION=${{ steps.app-version.outputs.version }}
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
|
|||||||
@@ -5,6 +5,10 @@
|
|||||||
ARG BASE_REGISTRY=docker.io
|
ARG BASE_REGISTRY=docker.io
|
||||||
FROM ${BASE_REGISTRY}/library/node:20-alpine AS builder
|
FROM ${BASE_REGISTRY}/library/node:20-alpine AS builder
|
||||||
|
|
||||||
|
# 可由发布 workflow 从 git tag 注入,用于前端 About 页展示版本;未传时由 Vite 回退读取 tauri.conf.json。
|
||||||
|
ARG VITE_APP_VERSION=
|
||||||
|
ENV VITE_APP_VERSION=${VITE_APP_VERSION}
|
||||||
|
|
||||||
# pnpm pin 到 9.x:lockfile 是 v9 生成;pnpm 11 要求 Node 22+ 与 node:20 不兼容
|
# pnpm pin 到 9.x:lockfile 是 v9 生成;pnpm 11 要求 Node 22+ 与 node:20 不兼容
|
||||||
RUN corepack enable && corepack prepare pnpm@9.15.0 --activate
|
RUN corepack enable && corepack prepare pnpm@9.15.0 --activate
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import logo from '@/assets/icon.svg'
|
|||||||
import wechatQr from '@/assets/wechat.png'
|
import wechatQr from '@/assets/wechat.png'
|
||||||
|
|
||||||
export default function AboutPage() {
|
export default function AboutPage() {
|
||||||
|
const appVersion = __APP_VERSION__
|
||||||
const images = [
|
const images = [
|
||||||
'https://common-1304618721.cos.ap-chengdu.myqcloud.com/20250504102850.png',
|
'https://common-1304618721.cos.ap-chengdu.myqcloud.com/20250504102850.png',
|
||||||
'https://common-1304618721.cos.ap-chengdu.myqcloud.com/20250504103028.png',
|
'https://common-1304618721.cos.ap-chengdu.myqcloud.com/20250504103028.png',
|
||||||
@@ -27,7 +28,7 @@ export default function AboutPage() {
|
|||||||
height={50}
|
height={50}
|
||||||
className="rounded-lg"
|
className="rounded-lg"
|
||||||
/>
|
/>
|
||||||
<h1 className="text-4xl font-bold">BiliNote v2.0.0</h1>
|
<h1 className="text-4xl font-bold">BiliNote v{appVersion}</h1>
|
||||||
</div>
|
</div>
|
||||||
<p className="text-muted-foreground mb-6 text-xl italic">
|
<p className="text-muted-foreground mb-6 text-xl italic">
|
||||||
AI 视频笔记生成工具 让 AI 为你的视频做笔记
|
AI 视频笔记生成工具 让 AI 为你的视频做笔记
|
||||||
|
|||||||
2
BillNote_frontend/src/vite-env.d.ts
vendored
2
BillNote_frontend/src/vite-env.d.ts
vendored
@@ -1 +1,3 @@
|
|||||||
/// <reference types="vite/client" />
|
/// <reference types="vite/client" />
|
||||||
|
|
||||||
|
declare const __APP_VERSION__: string
|
||||||
|
|||||||
@@ -1,11 +1,25 @@
|
|||||||
import { defineConfig, loadEnv } from 'vite'
|
import { defineConfig, loadEnv } from 'vite'
|
||||||
import react from '@vitejs/plugin-react'
|
import react from '@vitejs/plugin-react'
|
||||||
|
import fs from 'fs'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { fileURLToPath } from 'url'
|
import { fileURLToPath } from 'url'
|
||||||
import tailwindcss from '@tailwindcss/vite'
|
import tailwindcss from '@tailwindcss/vite'
|
||||||
|
|
||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||||
|
|
||||||
|
function readAppVersion() {
|
||||||
|
const fallbackVersion = '0.0.0'
|
||||||
|
|
||||||
|
try {
|
||||||
|
const tauriConfigPath = path.resolve(__dirname, 'src-tauri/tauri.conf.json')
|
||||||
|
const tauriConfig = JSON.parse(fs.readFileSync(tauriConfigPath, 'utf-8')) as { version?: string }
|
||||||
|
return tauriConfig.version || fallbackVersion
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
return fallbackVersion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default defineConfig(({ mode }) => {
|
export default defineConfig(({ mode }) => {
|
||||||
// 在 Docker 环境中,父目录可能没有 .env 文件,使用当前目录
|
// 在 Docker 环境中,父目录可能没有 .env 文件,使用当前目录
|
||||||
@@ -14,9 +28,13 @@ export default defineConfig(({ mode }) => {
|
|||||||
|
|
||||||
const apiBaseUrl = env.VITE_API_BASE_URL || 'http://127.0.0.1:8483'
|
const apiBaseUrl = env.VITE_API_BASE_URL || 'http://127.0.0.1:8483'
|
||||||
const port = parseInt(env.VITE_FRONTEND_PORT || '3015', 10)
|
const port = parseInt(env.VITE_FRONTEND_PORT || '3015', 10)
|
||||||
|
const appVersion = env.VITE_APP_VERSION || process.env.VITE_APP_VERSION || readAppVersion()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
base: './',
|
base: './',
|
||||||
|
define: {
|
||||||
|
__APP_VERSION__: JSON.stringify(appVersion),
|
||||||
|
},
|
||||||
plugins: [react(), tailwindcss()],
|
plugins: [react(), tailwindcss()],
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
|
|||||||
@@ -35,6 +35,10 @@ COPY ./backend /tmp/backend
|
|||||||
ARG BASE_REGISTRY=docker.io
|
ARG BASE_REGISTRY=docker.io
|
||||||
FROM ${BASE_REGISTRY}/library/node:20-alpine AS frontend-builder
|
FROM ${BASE_REGISTRY}/library/node:20-alpine AS frontend-builder
|
||||||
|
|
||||||
|
# 可由发布 workflow 从 git tag 注入,用于前端 About 页展示版本;未传时由 Vite 回退读取 tauri.conf.json。
|
||||||
|
ARG VITE_APP_VERSION=
|
||||||
|
ENV VITE_APP_VERSION=${VITE_APP_VERSION}
|
||||||
|
|
||||||
# pnpm 版本 pin 到 9 系列:
|
# pnpm 版本 pin 到 9 系列:
|
||||||
# - lockfile (BillNote_frontend/pnpm-lock.yaml) 是 lockfileVersion '9.0',由 pnpm 9 生成
|
# - lockfile (BillNote_frontend/pnpm-lock.yaml) 是 lockfileVersion '9.0',由 pnpm 9 生成
|
||||||
# - pnpm 11+ 要求 Node 22+,与 node:20 不兼容(ERR_UNKNOWN_BUILTIN_MODULE)
|
# - pnpm 11+ 要求 Node 22+,与 node:20 不兼容(ERR_UNKNOWN_BUILTIN_MODULE)
|
||||||
|
|||||||
Reference in New Issue
Block a user