sync version
This commit is contained in:
@@ -7,7 +7,9 @@
|
|||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "vue-tsc --noEmit && vite build",
|
"build": "vue-tsc --noEmit && vite build",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"tauri": "tauri"
|
"tauri": "tauri",
|
||||||
|
"sync-version": "node scripts/sync-version.js",
|
||||||
|
"postversion": "pnpm sync-version"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tailwindcss/vite": "^4.2.0",
|
"@tailwindcss/vite": "^4.2.0",
|
||||||
|
|||||||
34
scripts/sync-version.js
Normal file
34
scripts/sync-version.js
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
const rootDir = path.join(__dirname, '..');
|
||||||
|
|
||||||
|
// 1. 获取 package.json 的版本号
|
||||||
|
const pkgPath = path.join(rootDir, 'package.json');
|
||||||
|
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
||||||
|
const version = pkg.version;
|
||||||
|
|
||||||
|
console.log(`[Version Sync] New version detected: v${version}`);
|
||||||
|
|
||||||
|
// 2. 更新 src-tauri/tauri.conf.json
|
||||||
|
const tauriConfPath = path.join(rootDir, 'src-tauri', 'tauri.conf.json');
|
||||||
|
if (fs.existsSync(tauriConfPath)) {
|
||||||
|
const tauriConf = JSON.parse(fs.readFileSync(tauriConfPath, 'utf8'));
|
||||||
|
tauriConf.version = version;
|
||||||
|
fs.writeFileSync(tauriConfPath, JSON.stringify(tauriConf, null, 2) + '\n');
|
||||||
|
console.log(`[Version Sync] Updated src-tauri/tauri.conf.json`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 更新 src-tauri/Cargo.toml
|
||||||
|
const cargoTomlPath = path.join(rootDir, 'src-tauri', 'Cargo.toml');
|
||||||
|
if (fs.existsSync(cargoTomlPath)) {
|
||||||
|
let cargoToml = fs.readFileSync(cargoTomlPath, 'utf8');
|
||||||
|
// 匹配 [package] 下的首个 version = "..."
|
||||||
|
cargoToml = cargoToml.replace(/^version\s*=\s*".*"/m, `version = "${version}"`);
|
||||||
|
fs.writeFileSync(cargoTomlPath, cargoToml);
|
||||||
|
console.log(`[Version Sync] Updated src-tauri/Cargo.toml`);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('[Version Sync] All versions are now synchronized.');
|
||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
} from 'lucide-vue-next';
|
} from 'lucide-vue-next';
|
||||||
import { fetch } from '@tauri-apps/plugin-http';
|
import { fetch } from '@tauri-apps/plugin-http';
|
||||||
import { useSettingsStore, LANGUAGES, DEFAULT_TEMPLATE } from './stores/settings';
|
import { useSettingsStore, LANGUAGES, DEFAULT_TEMPLATE } from './stores/settings';
|
||||||
|
import pkg from '../package.json';
|
||||||
import { clsx, type ClassValue } from 'clsx';
|
import { clsx, type ClassValue } from 'clsx';
|
||||||
import { twMerge } from 'tailwind-merge';
|
import { twMerge } from 'tailwind-merge';
|
||||||
|
|
||||||
@@ -449,7 +450,7 @@ const translate = async () => {
|
|||||||
{{ settings.ollamaApiAddress }}
|
{{ settings.ollamaApiAddress }}
|
||||||
</div>
|
</div>
|
||||||
<div class="text-[10px] text-slate-400">
|
<div class="text-[10px] text-slate-400">
|
||||||
GemmaTrans v0.1.0
|
GemmaTrans v{{ pkg.version }}
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user