update:自动打包&删除申请记录
This commit is contained in:
parent
c62fa0b56d
commit
9787262e88
@ -14,6 +14,14 @@ pnpm electron:dev
|
||||
pnpm electron:build
|
||||
```
|
||||
|
||||
也可以直接双击项目根目录的 `build-electron.cmd`。它会自动检查 Node.js/pnpm,在依赖缺失时执行安装,随后构建 Electron 安装包并在成功后打开输出目录。
|
||||
|
||||
对应的命令行入口为:
|
||||
|
||||
```bash
|
||||
pnpm electron:package:auto
|
||||
```
|
||||
|
||||
安装包输出到 `release/`。只生成免安装目录用于调试时,可运行:
|
||||
|
||||
```bash
|
||||
|
||||
21
build-electron.cmd
Normal file
21
build-electron.cmd
Normal file
@ -0,0 +1,21 @@
|
||||
@echo off
|
||||
chcp 65001 >nul
|
||||
title 跃动赛事 Electron 自动打包
|
||||
cd /d "%~dp0"
|
||||
|
||||
echo ========================================
|
||||
echo 跃动赛事 Electron 自动打包
|
||||
echo ========================================
|
||||
echo.
|
||||
|
||||
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%~dp0scripts\package-electron.ps1"
|
||||
if errorlevel 1 (
|
||||
echo.
|
||||
echo 打包失败,请查看上方错误信息。
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo.
|
||||
echo 打包任务已完成。
|
||||
pause
|
||||
@ -12,6 +12,7 @@
|
||||
"electron:dev": "concurrently -k \"vite --mode electron\" \"wait-on http://127.0.0.1:9991 && electron .\"",
|
||||
"electron:build": "vite build --mode electron --outDir dist && electron-builder",
|
||||
"electron:build:dir": "vite build --mode electron --outDir dist && electron-builder --dir",
|
||||
"electron:package:auto": "powershell -NoProfile -ExecutionPolicy Bypass -File scripts/package-electron.ps1",
|
||||
"lint-fix": "eslint --fix --ext .js --ext .jsx --ext .vue src/",
|
||||
"gen": "sta -p http://localhost:53785/swagger/Default/swagger.json -o ./src/apis --modular --route-types --axios --module-name-index 1 --extract-request-params -t ./templates"
|
||||
},
|
||||
|
||||
73
scripts/package-electron.ps1
Normal file
73
scripts/package-electron.ps1
Normal file
@ -0,0 +1,73 @@
|
||||
param(
|
||||
[switch]$NoOpen
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
$workspaceRoot = Split-Path -Parent $PSScriptRoot
|
||||
$releaseDirectory = Join-Path $workspaceRoot 'release'
|
||||
$electronBuilderCommand = Join-Path $workspaceRoot 'node_modules\.bin\electron-builder.CMD'
|
||||
|
||||
Set-Location -LiteralPath $workspaceRoot
|
||||
|
||||
function Invoke-CheckedCommand {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Command,
|
||||
[string[]]$Arguments = @()
|
||||
)
|
||||
|
||||
& $Command @Arguments
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Command failed with exit code ${LASTEXITCODE}: $Command $($Arguments -join ' ')"
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
Write-Host '[1/4] Checking Node.js and pnpm...' -ForegroundColor Cyan
|
||||
if (-not (Get-Command node -ErrorAction SilentlyContinue)) {
|
||||
throw 'Node.js was not found. Install Node.js 20 first.'
|
||||
}
|
||||
if (-not (Get-Command pnpm -ErrorAction SilentlyContinue)) {
|
||||
throw 'pnpm was not found. Run: corepack enable'
|
||||
}
|
||||
|
||||
$nodeVersion = (& node --version).Trim()
|
||||
$pnpmVersion = (& pnpm --version).Trim()
|
||||
Write-Host "Node.js $nodeVersion, pnpm $pnpmVersion" -ForegroundColor DarkGray
|
||||
|
||||
Write-Host '[2/4] Checking project dependencies...' -ForegroundColor Cyan
|
||||
if (-not (Test-Path -LiteralPath $electronBuilderCommand)) {
|
||||
Write-Host 'Dependencies are missing. Running pnpm install...'
|
||||
Invoke-CheckedCommand -Command 'pnpm' -Arguments @('install')
|
||||
} else {
|
||||
Write-Host 'Dependencies found. Skipping installation.' -ForegroundColor DarkGray
|
||||
}
|
||||
|
||||
Write-Host '[3/4] Building the Electron installer...' -ForegroundColor Cyan
|
||||
$env:ELECTRON_MIRROR = 'https://npmmirror.com/mirrors/electron/'
|
||||
Invoke-CheckedCommand -Command 'pnpm' -Arguments @('electron:build')
|
||||
|
||||
Write-Host '[4/4] Checking build output...' -ForegroundColor Cyan
|
||||
$installer = Get-ChildItem -LiteralPath $releaseDirectory -Filter '*.exe' -File |
|
||||
Sort-Object LastWriteTime -Descending |
|
||||
Select-Object -First 1
|
||||
|
||||
if (-not $installer) {
|
||||
throw "The build completed, but no installer was found in $releaseDirectory."
|
||||
}
|
||||
|
||||
$sizeMb = [Math]::Round($installer.Length / 1MB, 2)
|
||||
Write-Host ''
|
||||
Write-Host 'Build completed successfully.' -ForegroundColor Green
|
||||
Write-Host "Installer: $($installer.FullName)"
|
||||
Write-Host "Size: $sizeMb MB"
|
||||
|
||||
if (-not $NoOpen) {
|
||||
Start-Process -FilePath 'explorer.exe' -ArgumentList "/select,`"$($installer.FullName)`""
|
||||
}
|
||||
} catch {
|
||||
Write-Host ''
|
||||
Write-Host "Automatic packaging failed: $($_.Exception.Message)" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
@ -3,7 +3,7 @@
|
||||
<section class="workbench-main">
|
||||
<header class="topbar">
|
||||
<div><h1>{{ tabTitle }}</h1><p>{{ eventName }} · {{ tabDescription }}</p></div>
|
||||
<div class="top-actions"><span :class="['live-dot', { offline }]">● {{ offline ? '连接异常' : '实时同步' }}</span><el-button v-if="activeTab !== 'screen'" class="top-checkin-button" @click="openCheckinScreen">检录大屏</el-button><el-button v-if="activeTab !== 'screen'" :type="activeTab==='corrections'?'primary':'default'" @click="toggleCorrections">{{activeTab==='corrections'?'返回成绩列表':'修正申请'}}</el-button><el-button @click="goLauncher">切换赛事</el-button></div>
|
||||
<div class="top-actions"><span :class="['live-dot', { offline }]">● {{ offline ? '连接异常' : '实时同步' }}</span><el-button v-if="activeTab !== 'screen'" class="top-checkin-button" @click="openCheckinScreen">检录大屏</el-button><el-button @click="goLauncher">切换赛事</el-button></div>
|
||||
</header>
|
||||
|
||||
<template v-if="activeTab !== 'corrections'">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user