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.
28 lines
913 B
28 lines
913 B
const path = require('path')
|
|
|
|
const {
|
|
getPlatformExts
|
|
} = require('../shared')
|
|
|
|
const ROOT_DATA_VAR = '$root'
|
|
|
|
function generatePageWxml (name, importee) {
|
|
if (process.env.UNI_PLATFORM === 'mp-baidu') {
|
|
return `<import src="${importee}" />
|
|
<template is="${name}" data="{{{ ...${ROOT_DATA_VAR}['0'], ${ROOT_DATA_VAR} }}}"/>`
|
|
} else if (process.env.UNI_PLATFORM === 'mp-alipay') {
|
|
return `<template is="${name}" data="{{ ...${ROOT_DATA_VAR}['0'], ${ROOT_DATA_VAR} }}"/>`
|
|
}
|
|
return `<import src="${importee}" />
|
|
<template is="${name}" data="{{ ...${ROOT_DATA_VAR}['0'], ${ROOT_DATA_VAR} }}"/>`
|
|
}
|
|
|
|
module.exports = function generatePagesWxml (pages, subPages) {
|
|
return Object.keys(pages).map(page => { // page wxml
|
|
const ext = getPlatformExts().template
|
|
return {
|
|
file: page + ext,
|
|
source: generatePageWxml(pages[page], `./${path.basename(page)}.vue${ext}`)
|
|
}
|
|
})
|
|
}
|
|
|