define-pages.js 555 字节
Newer Older
fxy060608's avatar
fxy060608 已提交
1 2 3 4 5 6 7 8 9 10 11 12
function generatePageCode (pages, pageOptions) {
  return pages.map(pagePath => {
    if (pageOptions[pagePath].nvue) {
      return ''
    }
    return `__definePage('${pagePath}',function(){return Vue.extend(require('${pagePath}.vue').default)})`
  }).join('\n')
}

module.exports = function definePages (appJson) {
  return {
    name: 'define-pages.js',
fxy060608's avatar
fxy060608 已提交
13 14
    content: `
if(uni.restoreGlobal){
fxy060608's avatar
fxy060608 已提交
15
  uni.restoreGlobal(weex,plus,setTimeout,clearTimeout,setInterval,clearInterval)
fxy060608's avatar
fxy060608 已提交
16
}
fxy060608's avatar
fxy060608 已提交
17 18 19 20
${generatePageCode(appJson.pages, appJson.page)}
`
  }
}