-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-and-test.bat
More file actions
147 lines (126 loc) · 3.07 KB
/
Copy pathbuild-and-test.bat
File metadata and controls
147 lines (126 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
@echo off
echo ========================================
echo 构建并测试Electron应用
echo ========================================
echo.
echo 🧹 清理旧文件...
if exist "dist" rmdir /s /q "dist"
if exist "dist_electron" rmdir /s /q "dist_electron"
echo.
echo 📦 安装依赖...
call npm install
if %ERRORLEVEL% NEQ 0 (
echo ❌ 依赖安装失败
pause
exit /b 1
)
echo.
echo 🏗️ 构建Vue应用...
call npm run build
if %ERRORLEVEL% NEQ 0 (
echo ❌ Vue应用构建失败
pause
exit /b 1
)
echo.
echo 📁 检查构建文件...
if not exist "dist\index.html" (
echo ❌ 找不到 dist\index.html,Vue构建可能失败
echo 当前目录内容:
dir /B
if exist "dist" (
echo dist目录内容:
dir dist /B
)
pause
exit /b 1
) else (
echo ✅ 找到 dist\index.html
echo 📋 dist目录内容:
dir dist /B
)
echo.
echo 🔧 检查关键文件...
if not exist "main.cjs" (
echo ❌ 找不到 main.cjs
pause
exit /b 1
) else (
echo ✅ 找到 main.cjs
)
if not exist "preload.js" (
echo ❌ 找不到 preload.js
pause
exit /b 1
) else (
echo ✅ 找到 preload.js
)
echo.
echo 🔧 创建临时图标文件(如果需要)...
if not exist "build" mkdir build
if not exist "build\icon.ico" (
echo 创建默认图标文件...
echo. > "build\icon.ico"
)
echo.
echo 📱 打包Electron应用...
call npm run electron:pack
if %ERRORLEVEL% NEQ 0 (
echo ❌ Electron应用打包失败
echo 可能的原因:
echo 1. dist目录不存在或为空
echo 2. 图标文件不符合要求
echo 3. 配置文件有误
pause
exit /b 1
)
echo.
echo 📋 检查打包结果...
if exist "dist_electron\win-unpacked" (
echo ✅ 打包目录存在
echo 打包目录内容:
dir "dist_electron\win-unpacked" /B
echo.
echo 检查关键文件:
if exist "dist_electron\win-unpacked\main.cjs" (
echo ✅ main.cjs 存在
) else (
echo ❌ main.cjs 不存在
)
if exist "dist_electron\win-unpacked\preload.js" (
echo ✅ preload.js 存在
) else (
echo ❌ preload.js 不存在
)
if exist "dist_electron\win-unpacked\dist\index.html" (
echo ✅ dist\index.html 存在
) else (
echo ❌ dist\index.html 不存在
)
if exist "dist_electron\win-unpacked\resources\app\dist\index.html" (
echo ✅ resources\app\dist\index.html 存在
) else (
echo ❌ resources\app\dist\index.html 不存在
)
) else (
echo ❌ 打包失败 - dist_electron\win-unpacked 目录不存在
echo 检查错误日志...
pause
exit /b 1
)
echo.
echo ✅ 构建和打包完成!
echo 📂 安装包位置: dist_electron\
echo 🚀 查找可执行文件...
for %%f in ("dist_electron\win-unpacked\*.exe") do (
echo 找到可执行文件: %%f
echo 准备测试启动...
timeout /t 2 /nobreak
start "" "%%f"
echo 应用已启动,请检查是否正常运行
goto :found
)
echo ⚠️ 未找到.exe文件
:found
echo.
pause