2024-06-25 10:27:51 +08:00
|
|
|
|
2024-08-13 14:40:19 +08:00
|
|
|
import fs from 'fs'
|
|
|
|
import path from 'path'
|
|
|
|
|
2024-06-25 10:27:51 +08:00
|
|
|
const config = {
|
|
|
|
pages:'./src/pages',
|
2024-11-14 18:12:00 +08:00
|
|
|
pagesInclude:['ycysp/home.vue','ycysp/pay.vue','ycysp/order.vue','ycysp/orderDetail.vue',]
|
2024-06-25 10:27:51 +08:00
|
|
|
}
|
2024-08-13 14:40:19 +08:00
|
|
|
const { pages, pagesInclude } = config
|
|
|
|
|
|
|
|
const getPages = () => {
|
|
|
|
const srcPath = path.resolve(__dirname, pages)
|
|
|
|
//所有的模块
|
|
|
|
const allModule = fs.readdirSync(srcPath);
|
|
|
|
//指定的完整模块
|
|
|
|
const completeModule = pagesInclude.filter(item => item.indexOf('.vue') === -1)
|
|
|
|
//需要排除的整个模块
|
|
|
|
const excludeModule = allModule.filter(item => !completeModule.includes(item))
|
|
|
|
//指定特定页面的模块
|
|
|
|
const targetpageModule = pagesInclude.filter(item => item.indexOf('.vue') >= 0)
|
|
|
|
const targetModule = targetpageModule.reduce((acc,cur) => {
|
|
|
|
const [dir,file] = cur.split('/');
|
|
|
|
if(Array.isArray(acc[dir])){
|
|
|
|
acc[dir].push(file)
|
|
|
|
}else{
|
|
|
|
acc[dir] = [file]
|
|
|
|
}
|
|
|
|
return acc
|
|
|
|
},{})
|
|
|
|
//需要排除的特定的页面
|
|
|
|
const excludePages = [];
|
|
|
|
Object.keys(targetModule).forEach((ele,index) => {
|
|
|
|
if(excludeModule.includes(ele)){
|
|
|
|
excludeModule.splice(excludeModule.indexOf(ele),1)
|
|
|
|
}
|
|
|
|
const targetPages = fs.readdirSync(path.resolve(__dirname,pages,ele)).filter(element => element.indexOf('.vue') >= 0)
|
|
|
|
const targetExclude = targetPages.filter(elem => !targetModule[ele].includes(elem)).map(current => `${ele}/${current}`)
|
|
|
|
excludePages.push(...targetExclude)
|
|
|
|
})
|
|
|
|
console.log('排除的模块以及页面',[...excludeModule,...excludePages]);
|
|
|
|
return {
|
|
|
|
exclude:[...excludeModule,...excludePages],
|
|
|
|
}
|
|
|
|
}
|
2024-06-25 10:27:51 +08:00
|
|
|
|
2024-08-13 14:40:19 +08:00
|
|
|
export default getPages
|