提交 945ac407 编写于 作者: P piexlMax

调整代码自动定位无法识别windows的bug

上级 45e48357
......@@ -3,9 +3,7 @@ import * as dotenv from 'dotenv'
import * as fs from 'fs'
const NODE_ENV = process.env.NODE_ENV || 'development'
const envFiles = [
`.env.${NODE_ENV}`
]
const envFiles = [`.env.${NODE_ENV}`]
for (const file of envFiles) {
const envConfig = dotenv.parse(fs.readFileSync(file))
for (const k in envConfig) {
......@@ -18,18 +16,23 @@ export default function GvaPositionServer() {
name: 'gva-position-server',
apply: 'serve',
configureServer(server) {
server.middlewares.use((req, res, next) => {
server.middlewares.use((req, _, next) => {
if (req._parsedUrl.pathname === '/gvaPositionCode') {
const path = req._parsedUrl.query && req._parsedUrl.query.split('=')[1]
const path =
req._parsedUrl.query && req._parsedUrl.query.split('=')[1]
if (path && path !== 'null') {
if (process.env.VITE_EDITOR === 'webstorm') {
const linePath = path.split(':')[1]
const filePath = path.split(':')[0]
const platform = os()
if (platform === 'win32') {
child_process.exec(`webstorm64.exe --line ${linePath} ${filePath}`)
child_process.exec(
`webstorm64.exe --line ${linePath} ${filePath}`
)
} else {
child_process.exec(`webstorm64 --line ${linePath} ${filePath}`)
child_process.exec(
`webstorm64 --line ${linePath} ${filePath}`
)
}
} else {
child_process.exec('code -r -g ' + path)
......@@ -38,7 +41,7 @@ export default function GvaPositionServer() {
}
next()
})
}
},
}
}
......@@ -46,14 +49,5 @@ function os() {
'use strict'
const os = require('os')
const platform = os.platform()
switch (platform) {
case 'darwin':
return 'MacOSX'
case 'linux':
return 'Linux'
case 'win32':
return 'Windows'
default:
return '无法确定操作系统!'
}
return platform
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册