优化读取

master
yutent 2022-02-17 13:25:27 +08:00
parent 8c7b59e1e6
commit a025463129
1 changed files with 26 additions and 28 deletions

View File

@ -72,8 +72,18 @@ class AutoPath {
} else { } else {
// 小程序 // 小程序
if (options.isMiniApp) { if (options.isMiniApp) {
let conf = require(join(options.workspace, 'app.json'))
list = conf.pages.map(it => `/${it}`)
if (conf.subPackages && conf.subPackages.length) {
for (let it of conf.subPackages) {
list.push(...it.pages.map(p => '/' + it.root + p))
}
}
currDirFixed = inputTxt currDirFixed = inputTxt
list = options.list.filter(it => it.startsWith(inputTxt)) list = list.filter(it => it.startsWith(inputTxt))
} }
// vue项目 // vue项目
else if (inputTxt.startsWith('@/') && options.extendWorkspace) { else if (inputTxt.startsWith('@/') && options.extendWorkspace) {
@ -102,23 +112,14 @@ function __init__() {
if (folders && folders.length) { if (folders && folders.length) {
options.workspace = folders[0].uri.path options.workspace = folders[0].uri.path
} else {
options.workspace = '/opt/www/web/zero.yutent.top/'
} }
if (options.workspace) { if (options.workspace) {
try {
// 判断是否是小程序 // 判断是否是小程序
if (isfile(join(options.workspace, 'app.json'))) { if (isfile(join(options.workspace, 'app.json'))) {
let conf = require(join(options.workspace, 'app.json')) let conf = require(join(options.workspace, 'app.json'))
if (conf.pages && conf.pages.length) { if (conf.pages && conf.pages.length) {
options.isMiniApp = true options.isMiniApp = true
options.list = conf.pages.map(it => `/${it}`)
if (conf.subPackages && conf.subPackages.length) {
for (let it of conf.subPackages) {
options.list.push(...it.pages.map(p => '/' + it.root + p))
}
}
return return
} }
} }
@ -132,9 +133,6 @@ function __init__() {
options.extendWorkspace = extendWorkspace options.extendWorkspace = extendWorkspace
} }
} }
} catch (e) {
console.log(e)
}
} }
} }