58
build/updateVersion.js
Normal file
58
build/updateVersion.js
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
const __dirname = path.dirname(__filename);
|
||||||
|
|
||||||
|
// 从命令行参数获取版本号
|
||||||
|
const args = process.argv.slice(2);
|
||||||
|
let version = args[0];
|
||||||
|
|
||||||
|
if (!version) {
|
||||||
|
console.error('错误: 请提供版本号作为参数');
|
||||||
|
console.error('用法: node build/updateVersion.js <version>');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证版本号格式 (遵循语义化版本号格式,如 x.y.z)
|
||||||
|
const versionRegex = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/;
|
||||||
|
if (!versionRegex.test(version)) {
|
||||||
|
console.error(`错误: 版本号格式不正确: ${version}`);
|
||||||
|
console.error('正确的版本号格式示例: 1.0.0, 2.1.3, 0.5.0-beta 等');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新 package.json
|
||||||
|
const packageJsonPath = path.join(__dirname, '..', 'package.json');
|
||||||
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
||||||
|
packageJson.version = version;
|
||||||
|
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
||||||
|
|
||||||
|
// 读取并更新 tauri.conf.json
|
||||||
|
const tauriConfPath = path.join(__dirname, '..', 'src-tauri', 'tauri.conf.json');
|
||||||
|
const tauriConf = JSON.parse(fs.readFileSync(tauriConfPath, 'utf8'));
|
||||||
|
|
||||||
|
// 更新版本号
|
||||||
|
tauriConf.version = version;
|
||||||
|
|
||||||
|
// 写回 tauri.conf.json
|
||||||
|
fs.writeFileSync(tauriConfPath, JSON.stringify(tauriConf, null, 2));
|
||||||
|
|
||||||
|
// 读取并更新 Cargo.toml
|
||||||
|
const cargoTomlPath = path.join(__dirname, '..', 'src-tauri', 'Cargo.toml');
|
||||||
|
let cargoToml = fs.readFileSync(cargoTomlPath, 'utf8');
|
||||||
|
|
||||||
|
// 使用正则表达式替换版本号
|
||||||
|
cargoToml = cargoToml.replace(
|
||||||
|
/^(\s*version\s*=\s*["'])([^"']*)(["']\s*)$/m,
|
||||||
|
`$1${version}$3`
|
||||||
|
);
|
||||||
|
|
||||||
|
// 写回 Cargo.toml
|
||||||
|
fs.writeFileSync(cargoTomlPath, cargoToml);
|
||||||
|
|
||||||
|
console.log(`版本号已更新至: ${version}`);
|
||||||
|
console.log(`- package.json`);
|
||||||
|
console.log(`- tauri.conf.json`);
|
||||||
|
console.log(`- Cargo.toml`);
|
||||||
@@ -8,6 +8,8 @@ export default antfu(
|
|||||||
rules: {
|
rules: {
|
||||||
'no-console': 'warn',
|
'no-console': 'warn',
|
||||||
'no-debugger': 'warn',
|
'no-debugger': 'warn',
|
||||||
|
'style/indent': ['error', 4],
|
||||||
|
'indent': ['error', 4, { 'SwitchCase': 1 }],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "log-lottery",
|
"name": "log-lottery",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.5.1",
|
"version": "0.5.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
"build:pre": "vue-tsc --noEmit && vite build --mode prebuild",
|
"build:pre": "vue-tsc --noEmit && vite build --mode prebuild",
|
||||||
"build:file": "vue-tsc --noEmit && vite build --mode file",
|
"build:file": "vue-tsc --noEmit && vite build --mode file",
|
||||||
"tauri": "node ./build/syncVersion.js && tauri",
|
"tauri": "node ./build/syncVersion.js && tauri",
|
||||||
|
"update-version": "node ./build/updateVersion.js",
|
||||||
"test": "vitest",
|
"test": "vitest",
|
||||||
"test:ui": "vitest --ui",
|
"test:ui": "vitest --ui",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "app"
|
name = "app"
|
||||||
version = "0.5.1"
|
version = "0.5.2"
|
||||||
description = "A Tauri App"
|
description = "A Tauri App"
|
||||||
authors = ["you"]
|
authors = ["you"]
|
||||||
license = ""
|
license = ""
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
||||||
"productName": "log-lottery",
|
"productName": "log-lottery",
|
||||||
"version": "0.5.1",
|
"version": "0.5.2",
|
||||||
"identifier": "to2026.xyz",
|
"identifier": "to2026.xyz",
|
||||||
"build": {
|
"build": {
|
||||||
"frontendDist": "../dist",
|
"frontendDist": "../dist",
|
||||||
|
|||||||
@@ -125,15 +125,20 @@ export function useViewModel() {
|
|||||||
detail.style.display = 'none'
|
detail.style.display = 'none'
|
||||||
element.appendChild(detail)
|
element.appendChild(detail)
|
||||||
|
|
||||||
|
if (isShowAvatar.value) {
|
||||||
const avatar = document.createElement('img')
|
const avatar = document.createElement('img')
|
||||||
avatar.className = 'card-avatar'
|
avatar.className = 'card-avatar'
|
||||||
avatar.src = tableData.value[i].avatar
|
avatar.src = tableData.value[i].avatar
|
||||||
avatar.alt = 'avatar'
|
avatar.alt = 'avatar'
|
||||||
avatar.style.width = '140px'
|
avatar.style.width = '140px'
|
||||||
avatar.style.height = '140px'
|
avatar.style.height = '140px'
|
||||||
if (!isShowAvatar.value)
|
|
||||||
avatar.style.display = 'none'
|
|
||||||
element.appendChild(avatar)
|
element.appendChild(avatar)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const avatarEmpty = document.createElement('div')
|
||||||
|
avatarEmpty.style.display = 'none'
|
||||||
|
element.appendChild(avatarEmpty)
|
||||||
|
}
|
||||||
|
|
||||||
element = useElementStyle(element, tableData.value[i], i, patternList.value, patternColor.value, cardColor.value, cardSize.value, textSize.value)
|
element = useElementStyle(element, tableData.value[i], i, patternList.value, patternColor.value, cardColor.value, cardSize.value, textSize.value)
|
||||||
const object = new CSS3DObject(element)
|
const object = new CSS3DObject(element)
|
||||||
|
|||||||
@@ -46,7 +46,10 @@ export function getRandomElements<T>(sourceArray: T[], count: number): T[] {
|
|||||||
crypto.getRandomValues(randomBuffer)
|
crypto.getRandomValues(randomBuffer)
|
||||||
const randomIndex = randomBuffer[0] % newArray.length
|
const randomIndex = randomBuffer[0] % newArray.length
|
||||||
|
|
||||||
|
// 添加选中的元素到结果数组
|
||||||
result.push(newArray[randomIndex])
|
result.push(newArray[randomIndex])
|
||||||
|
// 从原数组中移除已选中的元素,避免重复选择
|
||||||
|
newArray.splice(randomIndex, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|||||||
Reference in New Issue
Block a user