@quicktvui/web-cli 1.0.0-beta.37 → 1.0.0-beta.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/qt-web-cli.js CHANGED
@@ -183,10 +183,9 @@ function startDevServer(configPath, port, shouldOpen) {
183
183
  const WebpackDevServer = require('webpack-dev-server')
184
184
  const config = require(configPath)
185
185
 
186
- // 确保 devServer 配置正确
187
186
  config.devServer = config.devServer || {}
188
187
  config.devServer.port = port
189
- config.devServer.open = false // 我们自己控制浏览器打开
188
+ config.devServer.open = false
190
189
 
191
190
  const compiler = webpack(config)
192
191
  const server = new WebpackDevServer(config.devServer, compiler)
@@ -198,14 +197,12 @@ function startDevServer(configPath, port, shouldOpen) {
198
197
  }
199
198
  signale.success(`开发服务器已启动: http://localhost:${port}`)
200
199
 
201
- // 打开浏览器
202
200
  if (shouldOpen) {
203
201
  const url = `http://localhost:${port}`
204
- openOrRefreshBrowser(url)
202
+ openBrowser(url)
205
203
  }
206
204
  })
207
205
 
208
- // 处理退出信号
209
206
  process.on('SIGINT', () => {
210
207
  server.stopCallback(() => {
211
208
  signale.info('开发服务器已停止')
@@ -251,41 +248,24 @@ function waitForServer(url, timeout = 30000) {
251
248
  }
252
249
 
253
250
  /**
254
- * 打开或刷新浏览器(支持 macOS)
251
+ * 打开浏览器
255
252
  */
256
- function openOrRefreshBrowser(url) {
253
+ function openBrowser(url) {
257
254
  const platform = process.platform
258
-
259
- if (platform === 'darwin') {
260
- // macOS: 使用 AppleScript 检查并刷新已存在的标签页
261
- const appleScript = `
262
- tell application "Safari"
263
- activate
264
- set found to false
265
- repeat with w in windows
266
- repeat with t in tabs of w
267
- if URL of t starts with "http://localhost:" then
268
- set URL of t to "${url}"
269
- set found to true
270
- exit repeat
271
- end if
272
- end repeat
273
- if found then exit repeat
274
- end repeat
275
- if not found then
276
- open location "${url}"
277
- end if
278
- end tell
279
- `
280
-
281
- exec(`osascript -e '${appleScript.replace(/\n/g, ' ')}'`, { silent: true })
282
- signale.success('已打开/刷新浏览器')
283
- } else {
284
- // 其他平台:直接打开 URL
285
- const openCmd = platform === 'win32' ? 'start' : 'xdg-open'
286
- exec(`${openCmd} "${url}"`, { silent: true })
255
+ const command =
256
+ platform === 'darwin'
257
+ ? `open "${url}"`
258
+ : platform === 'win32'
259
+ ? `cmd /c start "" "${url}"`
260
+ : `xdg-open "${url}"`
261
+ const result = exec(command, { silent: true })
262
+
263
+ if (result.code === 0) {
287
264
  signale.success('已打开浏览器')
265
+ return
288
266
  }
267
+
268
+ signale.warn(`自动打开浏览器失败,请手动访问: ${url}`)
289
269
  }
290
270
 
291
271
  function findProjectRoot(startDir = process.cwd()) {
@@ -10,6 +10,7 @@ const fs = require('fs')
10
10
  const projectRoot = process.env.QUICKTVUI_PROJECT_ROOT || process.cwd()
11
11
  const mainEntry = process.env.QUICKTVUI_MAIN_ENTRY || path.resolve(projectRoot, 'src/main.ts')
12
12
  const port = parseInt(process.env.QUICKTVUI_PORT || '39001', 10)
13
+ const watchPoll = parseInt(process.env.QUICKTVUI_WATCH_POLL || '1000', 10)
13
14
 
14
15
  // 尝试加载项目的 package.json
15
16
  let pkg = {}
@@ -114,7 +115,13 @@ module.exports = {
114
115
 
115
116
  devServer: {
116
117
  port,
117
- hot: true,
118
+ hot: false,
119
+ liveReload: true,
120
+ headers: {
121
+ 'Cache-Control': 'no-store, no-cache, must-revalidate, proxy-revalidate',
122
+ Pragma: 'no-cache',
123
+ Expires: '0',
124
+ },
118
125
  proxy: [
119
126
  {
120
127
  context: ['/proxy'],
@@ -149,7 +156,7 @@ module.exports = {
149
156
 
150
157
  watchOptions: {
151
158
  aggregateTimeout: 1500,
152
- poll: 1000,
159
+ poll: watchPoll,
153
160
  ignored: /node_modules/,
154
161
  },
155
162
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quicktvui/web-cli",
3
- "version": "1.0.0-beta.37",
3
+ "version": "1.0.0-beta.38",
4
4
  "description": "CLI tool for QuickTVUI web development - zero configuration",
5
5
  "author": "QuickTVUI Team",
6
6
  "license": "Apache-2.0",