You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
887 B
31 lines
887 B
function generatePageCode (pages, pageOptions) {
|
|
return pages.map(pagePath => {
|
|
if (pageOptions[pagePath].nvue) {
|
|
return ''
|
|
}
|
|
return `__definePage('${pagePath}',function(){return Vue.extend(require('${pagePath}.vue?mpType=page').default)})`
|
|
}).join('\n')
|
|
}
|
|
|
|
module.exports = function definePages (appJson) {
|
|
return {
|
|
name: 'define-pages.js',
|
|
content: `
|
|
if (typeof Promise !== 'undefined' && !Promise.prototype.finally) {
|
|
Promise.prototype.finally = function(callback) {
|
|
const promise = this.constructor
|
|
return this.then(
|
|
value => promise.resolve(callback()).then(() => value),
|
|
reason => promise.resolve(callback()).then(() => {
|
|
throw reason
|
|
})
|
|
)
|
|
}
|
|
}
|
|
if(uni.restoreGlobal){
|
|
uni.restoreGlobal(weex,plus,setTimeout,clearTimeout,setInterval,clearInterval)
|
|
}
|
|
${generatePageCode(appJson.pages, appJson.page)}
|
|
`
|
|
}
|
|
}
|
|
|