| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- const fse = require('fs-extra');
- const config = require('../src/config.json');
- const targetBaseUrl = `${process.cwd()}/src`;
- const taroConfig = `${targetBaseUrl}/sites/mobile-taro/vue/src/app.config.ts`;
- // 创建 config
- const createConfig = async () => {
- let configRef = [];
- return new Promise((res, rej) => {
- config.nav.map((item) => {
- let co = {
- root: item.enName,
- pages: []
- };
- item.packages.map((it) => {
- if (!(it.exportEmpty == false) && it.show) {
- co.pages.push(`pages/${it.name.toLowerCase()}/index`);
- }
- });
- configRef.push(co);
- });
- res(configRef);
- });
- };
- const create = async () => {
- const configTemplate = {
- pages: ['pages/index/index'],
- subpackages: '',
- window: {
- backgroundTextStyle: 'light',
- navigationBarBackgroundColor: '#fff',
- navigationBarTitleText: 'NutUI',
- navigationBarTextStyle: 'black'
- }
- };
- configTemplate.subpackages = await createConfig();
- fse.writeFileSync(taroConfig, `export default ${JSON.stringify(configTemplate)}`, 'utf8');
- };
- create();
|