vite-plugin-vue-insight 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/vite-plugin.js +15 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-vue-insight",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "点击定位源码、高亮 DOM、查看组件状态、分享链接 — Vue 3 + Vite 调试助手",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -201,10 +201,12 @@ export function vueInsightPlugin(options = {}) {
201
201
  return
202
202
  }
203
203
 
204
- const parts = fileParam.split(':')
205
- const filePath = parts[0]
206
- const line = parts[1] || '1'
207
- const column = parts[2] || '1'
204
+ // Windows 绝对路径如 C:/path/to/file.vue:10:1,需从右侧拆分行号列号
205
+ const lastColon = fileParam.lastIndexOf(':')
206
+ const secondLastColon = fileParam.lastIndexOf(':', lastColon - 1)
207
+ const filePath = fileParam.substring(0, secondLastColon)
208
+ const line = fileParam.substring(secondLastColon + 1, lastColon)
209
+ const column = fileParam.substring(lastColon + 1) || '1'
208
210
 
209
211
  const { spawn } = await import('node:child_process')
210
212
 
@@ -231,7 +233,15 @@ export function vueInsightPlugin(options = {}) {
231
233
  break
232
234
  }
233
235
 
234
- const child = spawn(cmd, args, { stdio: 'ignore', detached: true })
236
+ const child = spawn(cmd, args, {
237
+ stdio: 'ignore',
238
+ detached: true,
239
+ shell: process.platform === 'win32',
240
+ })
241
+ child.on('error', (err) => {
242
+ console.warn('[vue-insight] 无法启动编辑器 (' + cmd + '): ' + err.message)
243
+ console.warn('[vue-insight] 请确认 ' + cmd + ' 已安装且已加入 PATH 环境变量')
244
+ })
235
245
  child.unref()
236
246
 
237
247
  res.statusCode = 200