diff --git a/default-youshu/_editorconfig b/default-youshu/_editorconfig
new file mode 100644
index 0000000..5760be5
--- /dev/null
+++ b/default-youshu/_editorconfig
@@ -0,0 +1,12 @@
+# http://editorconfig.org
+root = true
+
+[*]
+indent_style = space
+indent_size = 2
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[*.md]
+trim_trailing_whitespace = false
diff --git a/default-youshu/_eslintrc b/default-youshu/_eslintrc
new file mode 100644
index 0000000..f2d9106
--- /dev/null
+++ b/default-youshu/_eslintrc
@@ -0,0 +1,7 @@
+<%if (framework === 'vue') {-%>
+// ESLint 检查 .vue 文件需要单独配置编辑器:
+// https://eslint.vuejs.org/user-guide/#editor-integrations
+<%}-%>
+{
+ 'extends': ['taro/<%= framework %>']
+}
diff --git a/default-youshu/_gitignore b/default-youshu/_gitignore
new file mode 100644
index 0000000..2cea3ef
--- /dev/null
+++ b/default-youshu/_gitignore
@@ -0,0 +1,6 @@
+dist/
+deploy_versions/
+.temp/
+.rn_temp/
+node_modules/
+.DS_Store
diff --git a/default-youshu/_npmrc b/default-youshu/_npmrc
new file mode 100644
index 0000000..734aab2
--- /dev/null
+++ b/default-youshu/_npmrc
@@ -0,0 +1,10 @@
+registry=https://registry.npm.taobao.org
+disturl=https://npm.taobao.org/dist
+sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
+phantomjs_cdnurl=https://npm.taobao.org/mirrors/phantomjs/
+electron_mirror=https://npm.taobao.org/mirrors/electron/
+chromedriver_cdnurl=https://npm.taobao.org/mirrors/chromedriver
+operadriver_cdnurl=https://npm.taobao.org/mirrors/operadriver
+selenium_cdnurl=https://npm.taobao.org/mirrors/selenium
+node_inspector_cdnurl=https://npm.taobao.org/mirrors/node-inspector
+fsevents_binary_host_mirror=http://npm.taobao.org/mirrors/fsevents/
diff --git a/default-youshu/babel.config.js b/default-youshu/babel.config.js
new file mode 100644
index 0000000..e25950f
--- /dev/null
+++ b/default-youshu/babel.config.js
@@ -0,0 +1,10 @@
+// babel-preset-taro 更多选项和默认值:
+// https://github.com/NervJS/taro/blob/next/packages/babel-preset-taro/README.md
+module.exports = {
+ presets: [
+ ['taro', {
+ framework: '<%= framework %>',
+ ts: <%= typescript %>
+ }]
+ ]
+}
diff --git a/default-youshu/config/dev.js b/default-youshu/config/dev.js
new file mode 100644
index 0000000..6821bf8
--- /dev/null
+++ b/default-youshu/config/dev.js
@@ -0,0 +1,9 @@
+module.exports = {
+ env: {
+ NODE_ENV: '"development"'
+ },
+ defineConstants: {
+ },
+ mini: {},
+ h5: {}
+}
diff --git a/default-youshu/config/index.js b/default-youshu/config/index.js
new file mode 100644
index 0000000..c0849c1
--- /dev/null
+++ b/default-youshu/config/index.js
@@ -0,0 +1,70 @@
+const config = {
+ projectName: '<%= projectName %>',
+ date: '<%= date %>',
+ designWidth: 750,
+ deviceRatio: {
+ 640: 2.34 / 2,
+ 750: 1,
+ 828: 1.81 / 2
+ },
+ sourceRoot: 'src',
+ outputRoot: 'dist',
+ plugins: [],
+ defineConstants: {
+ },
+ copy: {
+ patterns: [
+ ],
+ options: {
+ }
+ },
+ framework: '<%= framework %>',
+ mini: {
+ postcss: {
+ pxtransform: {
+ enable: true,
+ config: {
+
+ }
+ },
+ url: {
+ enable: true,
+ config: {
+ limit: 1024 // 设定转换尺寸上限
+ }
+ },
+ cssModules: {
+ enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
+ config: {
+ namingPattern: 'module', // 转换模式,取值为 global/module
+ generateScopedName: '[name]__[local]___[hash:base64:5]'
+ }
+ }
+ }
+ },
+ h5: {
+ publicPath: '/',
+ staticDirectory: 'static',
+ postcss: {
+ autoprefixer: {
+ enable: true,
+ config: {
+ }
+ },
+ cssModules: {
+ enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
+ config: {
+ namingPattern: 'module', // 转换模式,取值为 global/module
+ generateScopedName: '[name]__[local]___[hash:base64:5]'
+ }
+ }
+ }
+ }
+}
+
+module.exports = function (merge) {
+ if (process.env.NODE_ENV === 'development') {
+ return merge({}, config, require('./dev'))
+ }
+ return merge({}, config, require('./prod'))
+}
diff --git a/default-youshu/config/prod.js b/default-youshu/config/prod.js
new file mode 100644
index 0000000..31497d7
--- /dev/null
+++ b/default-youshu/config/prod.js
@@ -0,0 +1,18 @@
+module.exports = {
+ env: {
+ NODE_ENV: '"production"'
+ },
+ defineConstants: {
+ },
+ mini: {},
+ h5: {
+ /**
+ * 如果h5端编译后体积过大,可以使用webpack-bundle-analyzer插件对打包体积进行分析。
+ * 参考代码如下:
+ * webpackChain (chain) {
+ * chain.plugin('analyzer')
+ * .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, [])
+ * }
+ */
+ }
+}
diff --git a/default-youshu/global.d.ts b/default-youshu/global.d.ts
new file mode 100644
index 0000000..be9c626
--- /dev/null
+++ b/default-youshu/global.d.ts
@@ -0,0 +1,18 @@
+declare module '*.png';
+declare module '*.gif';
+declare module '*.jpg';
+declare module '*.jpeg';
+declare module '*.svg';
+declare module '*.css';
+declare module '*.less';
+declare module '*.scss';
+declare module '*.sass';
+declare module '*.styl';
+
+// @ts-ignore
+declare const process: {
+ env: {
+ TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'quickapp' | 'qq';
+ [key: string]: any;
+ }
+}
diff --git a/default-youshu/package.json.tmpl b/default-youshu/package.json.tmpl
new file mode 100644
index 0000000..e310ad4
--- /dev/null
+++ b/default-youshu/package.json.tmpl
@@ -0,0 +1,60 @@
+{
+ "name": "<%= projectName %>",
+ "version": "1.0.0",
+ "private": true,
+ "description": "<%= description %>",
+ "templateInfo": {
+ "name": "<%= template %>",
+ "typescript": <%= typescript %>,
+ "css": "<%= css %>"
+ },
+ "scripts": {
+ "build:weapp": "taro build --type weapp",
+ "build:swan": "taro build --type swan",
+ "build:alipay": "taro build --type alipay",
+ "build:tt": "taro build --type tt",
+ "build:qq": "taro build --type qq",
+ "dev:weapp": "npm run build:weapp -- --watch",
+ "dev:swan": "npm run build:swan -- --watch",
+ "dev:alipay": "npm run build:alipay -- --watch",
+ "dev:tt": "npm run build:tt -- --watch",
+ "dev:qq": "npm run build:qq -- --watch"
+ },
+ "browserslist": [
+ "last 3 versions",
+ "Android >= 4.1",
+ "ios >= 8"
+ ],
+ "author": "",
+ "dependencies": {
+ "@babel/runtime": "^7.7.7",
+ "@tarojs/components": "<%= version %>",
+ "@tarojs/runtime": "<%= version %>",
+ "@tarojs/taro": "<%= version %>",<% if (framework === 'react') {%>
+ "@tarojs/react": "<%= version %>",
+ "react-dom": "^16.10.0",
+ "react": "^16.10.0"<%}%><% if (framework === 'nerv') {%>
+ "nervjs": "^1.5.0"<%}%><% if (framework === 'vue') {%>
+ "vue-template-compiler": "^2.5.0",
+ "vue": "^2.5.0"<%}%>,
+ "sr-sdk-wxapp": "^1.3.6"
+ },
+ "devDependencies": {
+ "@types/webpack-env": "^1.13.6",<% if (framework === 'react' || framework === 'nerv') {%>
+ "@types/react": "^16.0.0",<%}%>
+ "@tarojs/mini-runner": "<%= version %>",
+ "@babel/core": "^7.8.0",
+ "@tarojs/webpack-runner": "<%= version %>",
+ "babel-preset-taro": "<%= version %>",<% if (framework === 'vue') {%>
+ "eslint-plugin-vue": "^6.x",<%}%>
+ "eslint-config-taro": "<%= version %>",
+ "eslint": "^6.8.0",<% if (framework === 'react' || framework === 'nerv') {%>
+ "eslint-plugin-react": "^7.8.2",
+ "eslint-plugin-import": "^2.12.0",
+ "eslint-plugin-react-hooks": "^1.6.1",<%}%>
+ "stylelint": "9.3.0"<% if (typescript) {%>,
+ "@typescript-eslint/parser": "^2.x",
+ "@typescript-eslint/eslint-plugin": "^2.x",
+ "typescript": "^3.7.0"<%}%>
+ }
+}
diff --git a/default-youshu/project.config.json b/default-youshu/project.config.json
new file mode 100644
index 0000000..535aff0
--- /dev/null
+++ b/default-youshu/project.config.json
@@ -0,0 +1,13 @@
+{
+ "miniprogramRoot": "./dist",
+ "projectname": "<%= projectName %>",
+ "description": "<%= description %>",
+ "appid": "touristappid",
+ "setting": {
+ "urlCheck": true,
+ "es6": false,
+ "postcss": false,
+ "minified": false
+ },
+ "compileType": "miniprogram"
+}
diff --git a/default-youshu/src/app.config.js b/default-youshu/src/app.config.js
new file mode 100644
index 0000000..9870f49
--- /dev/null
+++ b/default-youshu/src/app.config.js
@@ -0,0 +1,11 @@
+export default {
+ pages: [
+ 'pages/index/index'
+ ],
+ window: {
+ backgroundTextStyle: 'light',
+ navigationBarBackgroundColor: '#fff',
+ navigationBarTitleText: 'WeChat',
+ navigationBarTextStyle: 'black'
+ }
+}
diff --git a/default-youshu/src/app.css b/default-youshu/src/app.css
new file mode 100644
index 0000000..e69de29
diff --git a/default-youshu/src/app.js b/default-youshu/src/app.js
new file mode 100644
index 0000000..7e2100f
--- /dev/null
+++ b/default-youshu/src/app.js
@@ -0,0 +1,84 @@
+<%if (framework === 'react') {-%>
+import { Component } from 'react'
+<%} else if (framework === 'nerv') { -%>
+import { Component } from 'nervjs'
+<%} else if (framework === 'vue') { -%>
+import Vue from 'vue'
+<%}-%>
+import sr from 'sr-sdk-wxapp'
+
+import './app.<%= cssExt %>'
+
+/**
+ * 有数埋点SDK 默认配置
+ * 使用方法请参考文档 https://mp.zhls.qq.com/youshu-docs/develop/sdk/Taro.html
+ * 如对有数SDK埋点接入有任何疑问,请联系微信:sr_data_service
+ */
+ sr.init({
+ /**
+ * 有数 - ka‘接入测试用’ 分配的 app_id,对应的业务接口人负责
+ */
+ token: 'bi6cdbda95ae2640ec',
+
+ /**
+ * 微信小程序appID,以wx开头
+ */
+ appid: 'touristappid',
+
+ /**
+ * 如果使用了小程序插件,需要设置为 true
+ */
+ usePlugin: false,
+
+ /**
+ * 开启打印调试信息, 默认 false
+ */
+ debug: true,
+
+ /**
+ * 建议开启-开启自动代理 Page, 默认 false
+ * sdk 负责上报页面的 browse 、leave、share 等事件
+ * 可以使用 sr.page 代替 Page(sr.page(options))
+ * 元素事件跟踪,需要配合 autoTrack: true
+ */
+ proxyPage: true,
+ /**
+ * 建议开启-开启组件自动代理, 默认 false
+ * sdk 负责上报页面的 browse 、leave、share 等事件
+ */
+ proxyComponent: true,
+ // 建议开启-是否开启页面分享链路自动跟踪
+ openSdkShareDepth: true,
+ // 建议开启-元素事件跟踪,自动上报元素事件,入tap、change、longpress、confirm
+ autoTrack: true,
+ installFrom: 'Taro@v3'
+ })
+
+<% if (framework === 'react' || framework === 'nerv') { -%>
+class App extends Component {
+ componentDidMount () {}
+
+ componentDidShow () {}
+
+ componentDidHide () {}
+
+ componentDidCatchError () {}
+
+ // this.props.children 是将要会渲染的页面
+ render () {
+ return this.props.children
+ }
+}
+<%}-%>
+<% if (framework === 'vue') { -%>
+const App = new Vue({
+ onShow (options) {
+ },
+ render(h) {
+ // this.$slots.default 是将要会渲染的页面
+ return h('block', this.$slots.default)
+ }
+})
+<%}-%>
+
+export default App
diff --git a/default-youshu/src/index.html b/default-youshu/src/index.html
new file mode 100644
index 0000000..826f423
--- /dev/null
+++ b/default-youshu/src/index.html
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/default-youshu/src/pages/index/index.config.js b/default-youshu/src/pages/index/index.config.js
new file mode 100644
index 0000000..be3ab00
--- /dev/null
+++ b/default-youshu/src/pages/index/index.config.js
@@ -0,0 +1,3 @@
+export default {
+ navigationBarTitleText: '首页'
+}
diff --git a/default-youshu/src/pages/index/index.css b/default-youshu/src/pages/index/index.css
new file mode 100644
index 0000000..e69de29
diff --git a/default-youshu/src/pages/index/index.jsx b/default-youshu/src/pages/index/index.jsx
new file mode 100644
index 0000000..059f256
--- /dev/null
+++ b/default-youshu/src/pages/index/index.jsx
@@ -0,0 +1,28 @@
+<%if (framework === 'react') {-%>
+import React, { Component } from 'react'
+<%} else if (framework === 'nerv') { -%>
+import Nerv, { Component } from 'nervjs'
+<%}-%>
+import { View, Text } from '@tarojs/components'
+import './<%= pageName %>.<%= cssExt %>'
+
+export default class <%= _.capitalize(pageName) %> extends Component {
+
+ componentWillMount () { }
+
+ componentDidMount () { }
+
+ componentWillUnmount () { }
+
+ componentDidShow () { }
+
+ componentDidHide () { }
+
+ render () {
+ return (
+
+ Hello world!
+
+ )
+ }
+}
diff --git a/default-youshu/src/pages/index/index.vue b/default-youshu/src/pages/index/index.vue
new file mode 100644
index 0000000..c0177c0
--- /dev/null
+++ b/default-youshu/src/pages/index/index.vue
@@ -0,0 +1,15 @@
+
+
+ {{ msg }}
+
+
+
+
diff --git a/default-youshu/template_creator.js b/default-youshu/template_creator.js
new file mode 100644
index 0000000..a468327
--- /dev/null
+++ b/default-youshu/template_creator.js
@@ -0,0 +1,24 @@
+function createWhenTs (params) {
+ return !!params.typescript
+}
+
+const handler = {
+ '/global.d.ts': createWhenTs,
+ '/tsconfig.json': createWhenTs,
+ '/src/pages/index/index.jsx' ({ pageName }) {
+ return { setPageName: `/src/pages/${pageName}/${pageName}.jsx` }
+ },
+ '/src/pages/index/index.css' ({ pageName }) {
+ return { setPageName: `/src/pages/${pageName}/${pageName}.css` }
+ }
+}
+
+const basePageFiles = [
+ '/src/pages/index/index.jsx',
+ '/src/pages/index/index.css'
+]
+
+module.exports = {
+ handler,
+ basePageFiles
+}
diff --git a/default-youshu/tsconfig.json b/default-youshu/tsconfig.json
new file mode 100644
index 0000000..e054915
--- /dev/null
+++ b/default-youshu/tsconfig.json
@@ -0,0 +1,33 @@
+{
+ "compilerOptions": {
+ "target": "es2017",
+ "module": "commonjs",
+ "removeComments": false,
+ "preserveConstEnums": true,
+ "moduleResolution": "node",
+ "experimentalDecorators": true,
+ "noImplicitAny": false,
+ "allowSyntheticDefaultImports": true,
+ "outDir": "lib",
+ "noUnusedLocals": true,
+ "noUnusedParameters": true,
+ "strictNullChecks": true,
+ "sourceMap": true,
+ "baseUrl": ".",
+ "rootDir": ".",
+ "jsx": "react",<% if (framework === 'react') {%>
+ "jsxFactory": "React.createElement",<%}%><% if (framework === 'nerv') {%>
+ "jsxFactory": "Nerv.createElement",<%}%>
+ "allowJs": true,
+ "resolveJsonModule": true,
+ "typeRoots": [
+ "node_modules/@types",
+ "global.d.ts"
+ ]
+ },
+ "exclude": [
+ "node_modules",
+ "dist"
+ ],
+ "compileOnSave": false
+}
diff --git a/h5-youshu/_editorconfig b/h5-youshu/_editorconfig
new file mode 100644
index 0000000..5760be5
--- /dev/null
+++ b/h5-youshu/_editorconfig
@@ -0,0 +1,12 @@
+# http://editorconfig.org
+root = true
+
+[*]
+indent_style = space
+indent_size = 2
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[*.md]
+trim_trailing_whitespace = false
diff --git a/h5-youshu/_eslintrc b/h5-youshu/_eslintrc
new file mode 100644
index 0000000..f2d9106
--- /dev/null
+++ b/h5-youshu/_eslintrc
@@ -0,0 +1,7 @@
+<%if (framework === 'vue') {-%>
+// ESLint 检查 .vue 文件需要单独配置编辑器:
+// https://eslint.vuejs.org/user-guide/#editor-integrations
+<%}-%>
+{
+ 'extends': ['taro/<%= framework %>']
+}
diff --git a/h5-youshu/_gitignore b/h5-youshu/_gitignore
new file mode 100644
index 0000000..2cea3ef
--- /dev/null
+++ b/h5-youshu/_gitignore
@@ -0,0 +1,6 @@
+dist/
+deploy_versions/
+.temp/
+.rn_temp/
+node_modules/
+.DS_Store
diff --git a/h5-youshu/_npmrc b/h5-youshu/_npmrc
new file mode 100644
index 0000000..734aab2
--- /dev/null
+++ b/h5-youshu/_npmrc
@@ -0,0 +1,10 @@
+registry=https://registry.npm.taobao.org
+disturl=https://npm.taobao.org/dist
+sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
+phantomjs_cdnurl=https://npm.taobao.org/mirrors/phantomjs/
+electron_mirror=https://npm.taobao.org/mirrors/electron/
+chromedriver_cdnurl=https://npm.taobao.org/mirrors/chromedriver
+operadriver_cdnurl=https://npm.taobao.org/mirrors/operadriver
+selenium_cdnurl=https://npm.taobao.org/mirrors/selenium
+node_inspector_cdnurl=https://npm.taobao.org/mirrors/node-inspector
+fsevents_binary_host_mirror=http://npm.taobao.org/mirrors/fsevents/
diff --git a/h5-youshu/babel.config.js b/h5-youshu/babel.config.js
new file mode 100644
index 0000000..e25950f
--- /dev/null
+++ b/h5-youshu/babel.config.js
@@ -0,0 +1,10 @@
+// babel-preset-taro 更多选项和默认值:
+// https://github.com/NervJS/taro/blob/next/packages/babel-preset-taro/README.md
+module.exports = {
+ presets: [
+ ['taro', {
+ framework: '<%= framework %>',
+ ts: <%= typescript %>
+ }]
+ ]
+}
diff --git a/h5-youshu/config/dev.js b/h5-youshu/config/dev.js
new file mode 100644
index 0000000..6821bf8
--- /dev/null
+++ b/h5-youshu/config/dev.js
@@ -0,0 +1,9 @@
+module.exports = {
+ env: {
+ NODE_ENV: '"development"'
+ },
+ defineConstants: {
+ },
+ mini: {},
+ h5: {}
+}
diff --git a/h5-youshu/config/index.js b/h5-youshu/config/index.js
new file mode 100644
index 0000000..c0849c1
--- /dev/null
+++ b/h5-youshu/config/index.js
@@ -0,0 +1,70 @@
+const config = {
+ projectName: '<%= projectName %>',
+ date: '<%= date %>',
+ designWidth: 750,
+ deviceRatio: {
+ 640: 2.34 / 2,
+ 750: 1,
+ 828: 1.81 / 2
+ },
+ sourceRoot: 'src',
+ outputRoot: 'dist',
+ plugins: [],
+ defineConstants: {
+ },
+ copy: {
+ patterns: [
+ ],
+ options: {
+ }
+ },
+ framework: '<%= framework %>',
+ mini: {
+ postcss: {
+ pxtransform: {
+ enable: true,
+ config: {
+
+ }
+ },
+ url: {
+ enable: true,
+ config: {
+ limit: 1024 // 设定转换尺寸上限
+ }
+ },
+ cssModules: {
+ enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
+ config: {
+ namingPattern: 'module', // 转换模式,取值为 global/module
+ generateScopedName: '[name]__[local]___[hash:base64:5]'
+ }
+ }
+ }
+ },
+ h5: {
+ publicPath: '/',
+ staticDirectory: 'static',
+ postcss: {
+ autoprefixer: {
+ enable: true,
+ config: {
+ }
+ },
+ cssModules: {
+ enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
+ config: {
+ namingPattern: 'module', // 转换模式,取值为 global/module
+ generateScopedName: '[name]__[local]___[hash:base64:5]'
+ }
+ }
+ }
+ }
+}
+
+module.exports = function (merge) {
+ if (process.env.NODE_ENV === 'development') {
+ return merge({}, config, require('./dev'))
+ }
+ return merge({}, config, require('./prod'))
+}
diff --git a/h5-youshu/config/prod.js b/h5-youshu/config/prod.js
new file mode 100644
index 0000000..31497d7
--- /dev/null
+++ b/h5-youshu/config/prod.js
@@ -0,0 +1,18 @@
+module.exports = {
+ env: {
+ NODE_ENV: '"production"'
+ },
+ defineConstants: {
+ },
+ mini: {},
+ h5: {
+ /**
+ * 如果h5端编译后体积过大,可以使用webpack-bundle-analyzer插件对打包体积进行分析。
+ * 参考代码如下:
+ * webpackChain (chain) {
+ * chain.plugin('analyzer')
+ * .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, [])
+ * }
+ */
+ }
+}
diff --git a/h5-youshu/global.d.ts b/h5-youshu/global.d.ts
new file mode 100644
index 0000000..be9c626
--- /dev/null
+++ b/h5-youshu/global.d.ts
@@ -0,0 +1,18 @@
+declare module '*.png';
+declare module '*.gif';
+declare module '*.jpg';
+declare module '*.jpeg';
+declare module '*.svg';
+declare module '*.css';
+declare module '*.less';
+declare module '*.scss';
+declare module '*.sass';
+declare module '*.styl';
+
+// @ts-ignore
+declare const process: {
+ env: {
+ TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'quickapp' | 'qq';
+ [key: string]: any;
+ }
+}
diff --git a/h5-youshu/package.json.tmpl b/h5-youshu/package.json.tmpl
new file mode 100644
index 0000000..443b157
--- /dev/null
+++ b/h5-youshu/package.json.tmpl
@@ -0,0 +1,62 @@
+{
+ "name": "<%= projectName %>",
+ "version": "1.0.0",
+ "private": true,
+ "description": "<%= description %>",
+ "templateInfo": {
+ "name": "<%= template %>",
+ "typescript": <%= typescript %>,
+ "css": "<%= css %>"
+ },
+ "scripts": {
+ "build:h5": "taro build --type h5",
+ "build:weapp": "taro build --type weapp",
+ "build:swan": "taro build --type swan",
+ "build:alipay": "taro build --type alipay",
+ "build:tt": "taro build --type tt",
+ "build:qq": "taro build --type qq",
+ "dev:h5": "npm run build:h5 -- --watch",
+ "dev:weapp": "npm run build:weapp -- --watch",
+ "dev:swan": "npm run build:swan -- --watch",
+ "dev:alipay": "npm run build:alipay -- --watch",
+ "dev:tt": "npm run build:tt -- --watch",
+ "dev:qq": "npm run build:qq -- --watch"
+ },
+ "browserslist": [
+ "last 3 versions",
+ "Android >= 4.1",
+ "ios >= 8"
+ ],
+ "author": "",
+ "dependencies": {
+ "@babel/runtime": "^7.7.7",
+ "@tarojs/components": "<%= version %>",
+ "@tarojs/runtime": "<%= version %>",
+ "@tarojs/taro": "<%= version %>",<% if (framework === 'react') {%>
+ "@tarojs/react": "<%= version %>",
+ "react-dom": "^16.10.0",
+ "react": "^16.10.0"<%}%><% if (framework === 'nerv') {%>
+ "nervjs": "^1.5.0"<%}%><% if (framework === 'vue') {%>
+ "vue-template-compiler": "^2.5.0",
+ "vue": "^2.5.0"<%}%>,
+ "sr-sdk-h5": "^1.3.1"
+ },
+ "devDependencies": {
+ "@types/webpack-env": "^1.13.6",<% if (framework === 'react' || framework === 'nerv') {%>
+ "@types/react": "^16.0.0",<%}%>
+ "@tarojs/mini-runner": "<%= version %>",
+ "@babel/core": "^7.8.0",
+ "@tarojs/webpack-runner": "<%= version %>",
+ "babel-preset-taro": "<%= version %>",<% if (framework === 'vue') {%>
+ "eslint-plugin-vue": "^6.x",<%}%>
+ "eslint-config-taro": "<%= version %>",
+ "eslint": "^6.8.0",<% if (framework === 'react' || framework === 'nerv') {%>
+ "eslint-plugin-react": "^7.8.2",
+ "eslint-plugin-import": "^2.12.0",
+ "eslint-plugin-react-hooks": "^1.6.1",<%}%>
+ "stylelint": "9.3.0"<% if (typescript) {%>,
+ "@typescript-eslint/parser": "^2.x",
+ "@typescript-eslint/eslint-plugin": "^2.x",
+ "typescript": "^3.7.0"<%}%>
+ }
+}
diff --git a/h5-youshu/project.config.json b/h5-youshu/project.config.json
new file mode 100644
index 0000000..535aff0
--- /dev/null
+++ b/h5-youshu/project.config.json
@@ -0,0 +1,13 @@
+{
+ "miniprogramRoot": "./dist",
+ "projectname": "<%= projectName %>",
+ "description": "<%= description %>",
+ "appid": "touristappid",
+ "setting": {
+ "urlCheck": true,
+ "es6": false,
+ "postcss": false,
+ "minified": false
+ },
+ "compileType": "miniprogram"
+}
diff --git a/h5-youshu/src/app.config.js b/h5-youshu/src/app.config.js
new file mode 100644
index 0000000..9870f49
--- /dev/null
+++ b/h5-youshu/src/app.config.js
@@ -0,0 +1,11 @@
+export default {
+ pages: [
+ 'pages/index/index'
+ ],
+ window: {
+ backgroundTextStyle: 'light',
+ navigationBarBackgroundColor: '#fff',
+ navigationBarTitleText: 'WeChat',
+ navigationBarTextStyle: 'black'
+ }
+}
diff --git a/h5-youshu/src/app.css b/h5-youshu/src/app.css
new file mode 100644
index 0000000..e69de29
diff --git a/h5-youshu/src/app.js b/h5-youshu/src/app.js
new file mode 100644
index 0000000..1a6e54c
--- /dev/null
+++ b/h5-youshu/src/app.js
@@ -0,0 +1,93 @@
+<%if (framework === 'react') {-%>
+import { Component } from 'react'
+<%} else if (framework === 'nerv') { -%>
+import { Component } from 'nervjs'
+<%} else if (framework === 'vue') { -%>
+import Vue from 'vue'
+<%}-%>
+import SDK from 'sr-sdk-h5'
+
+import './app.<%= cssExt %>'
+
+/**
+ * 有数埋点SDK 默认配置
+ * 使用方法请参考文档 https://mp.zhls.qq.com/youshu-docs/develop/sdk/Taro.html
+ * 如对有数SDK埋点接入有任何疑问,请联系微信:sr_data_service
+ */
+
+ window.srt = new SDK({
+
+ /**
+ * 有数 - ka‘接入测试用’ 分配的 app_id,对应的业务
+ */
+ token: 'bi72fccc7184ef45f9',
+
+ /**
+ * 传入自定义的后台上报接口,若传入则token将无意义
+ */
+ // serverUrl: 'aaa.baidu.com',
+
+ /**
+ * 开启打印调试信息, 默认 false
+ */
+ debug: true,
+
+ /**
+ * 代理配置,自动代理页面浏览事件、页面离开事件、点击事件,默认 false。建议开启
+ */
+ autoTrack: true,
+
+ /**
+ * 自动开始上报,默认 true。建议开启
+ */
+ autoStart: true,
+
+ /**
+ * 上报返回的钩子函数,返回 false 则代表不通过,SDK不会清除本地记录,会继续重拾
+ */
+ // onUploaded?: () => {},
+
+ /**
+ * 跳过初始化时对 token 的必要检查
+ * 满足场景:服务商转发SDK上报数据,在服务端回填appid,解决大量小程序同时接入的问题,默认false
+ */
+ // skipTokenCheck: false,
+
+ /**
+ * 小程序appid
+ */
+ appid: ''
+});
+
+// window.srt.setChan({chan_id: 'xxx'}) // 设置渠道,渠道信息将会被设置在props.chan对象中
+
+// window.srt.setUser({user_id: 'xxx'}) // 设置用户信息,用户信息将会被设置在props.wx_user对象中
+
+<% if (framework === 'react' || framework === 'nerv') { -%>
+class App extends Component {
+ componentDidMount () {}
+
+ componentDidShow () {}
+
+ componentDidHide () {}
+
+ componentDidCatchError () {}
+
+ // this.props.children 是将要会渲染的页面
+ render () {
+ return this.props.children
+ }
+}
+<%}-%>
+<% if (framework === 'vue') { -%>
+const App = new Vue({
+ onShow (options) {
+ },
+ render(h) {
+ // this.$slots.default 是将要会渲染的页面
+ return h('block', this.$slots.default)
+ }
+})
+<%}-%>
+
+export default App
diff --git a/h5-youshu/src/index.html b/h5-youshu/src/index.html
new file mode 100644
index 0000000..826f423
--- /dev/null
+++ b/h5-youshu/src/index.html
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/h5-youshu/src/pages/index/index.config.js b/h5-youshu/src/pages/index/index.config.js
new file mode 100644
index 0000000..be3ab00
--- /dev/null
+++ b/h5-youshu/src/pages/index/index.config.js
@@ -0,0 +1,3 @@
+export default {
+ navigationBarTitleText: '首页'
+}
diff --git a/h5-youshu/src/pages/index/index.css b/h5-youshu/src/pages/index/index.css
new file mode 100644
index 0000000..e69de29
diff --git a/h5-youshu/src/pages/index/index.jsx b/h5-youshu/src/pages/index/index.jsx
new file mode 100644
index 0000000..059f256
--- /dev/null
+++ b/h5-youshu/src/pages/index/index.jsx
@@ -0,0 +1,28 @@
+<%if (framework === 'react') {-%>
+import React, { Component } from 'react'
+<%} else if (framework === 'nerv') { -%>
+import Nerv, { Component } from 'nervjs'
+<%}-%>
+import { View, Text } from '@tarojs/components'
+import './<%= pageName %>.<%= cssExt %>'
+
+export default class <%= _.capitalize(pageName) %> extends Component {
+
+ componentWillMount () { }
+
+ componentDidMount () { }
+
+ componentWillUnmount () { }
+
+ componentDidShow () { }
+
+ componentDidHide () { }
+
+ render () {
+ return (
+
+ Hello world!
+
+ )
+ }
+}
diff --git a/h5-youshu/src/pages/index/index.vue b/h5-youshu/src/pages/index/index.vue
new file mode 100644
index 0000000..c0177c0
--- /dev/null
+++ b/h5-youshu/src/pages/index/index.vue
@@ -0,0 +1,15 @@
+
+
+ {{ msg }}
+
+
+
+
diff --git a/h5-youshu/template_creator.js b/h5-youshu/template_creator.js
new file mode 100644
index 0000000..a468327
--- /dev/null
+++ b/h5-youshu/template_creator.js
@@ -0,0 +1,24 @@
+function createWhenTs (params) {
+ return !!params.typescript
+}
+
+const handler = {
+ '/global.d.ts': createWhenTs,
+ '/tsconfig.json': createWhenTs,
+ '/src/pages/index/index.jsx' ({ pageName }) {
+ return { setPageName: `/src/pages/${pageName}/${pageName}.jsx` }
+ },
+ '/src/pages/index/index.css' ({ pageName }) {
+ return { setPageName: `/src/pages/${pageName}/${pageName}.css` }
+ }
+}
+
+const basePageFiles = [
+ '/src/pages/index/index.jsx',
+ '/src/pages/index/index.css'
+]
+
+module.exports = {
+ handler,
+ basePageFiles
+}
diff --git a/mobx/.eslintrc b/mobx/.eslintrc
index a860a4e..d5fd4f7 100644
--- a/mobx/.eslintrc
+++ b/mobx/.eslintrc
@@ -1,6 +1,5 @@
{
<%if (!locals.typescript) {-%>
- "extends": ["taro"],
"rules": {
"no-unused-vars": ["error", { "varsIgnorePattern": "Taro" }],
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx", ".tsx"] }]
diff --git a/mobx/babel.config.js b/mobx/babel.config.js
new file mode 100644
index 0000000..7721705
--- /dev/null
+++ b/mobx/babel.config.js
@@ -0,0 +1,25 @@
+module.exports = {
+ presets: [
+ ['@babel/env']<% if (framework === "react" || framework === "nerv") {%>,
+ [
+ '@babel/preset-react',
+ {
+ 'pragma': '<%= framework === "react" ? "React" : "Nerv" %>.createElement', // default pragma is React.createElement
+ 'pragmaFrag': '<%= framework === "react" ? "React" : "Nerv" %>.Fragment', // default is React.Fragment
+ }
+ ],<%}%>
+ // '@babel/typescript'
+ ],
+ plugins: [
+ ['@babel/plugin-transform-runtime', {
+ "useESModules": true,
+ }],
+ '@babel/plugin-proposal-class-properties',
+ [
+ '@babel/plugin-proposal-decorators',
+ {
+ 'legacy': true
+ }
+ ]
+ ]
+}
diff --git a/mobx/config/index.js b/mobx/config/index.js
index 352a0d8..280af32 100644
--- a/mobx/config/index.js
+++ b/mobx/config/index.js
@@ -3,9 +3,9 @@ const config = {
date: '<%= date %>',
designWidth: 750,
deviceRatio: {
- '640': 2.34 / 2,
- '750': 1,
- '828': 1.81 / 2
+ 640: 2.34 / 2,
+ 750: 1,
+ 828: 1.81 / 2
},
sourceRoot: 'src',
outputRoot: 'dist',
@@ -22,20 +22,18 @@ const config = {
'transform-object-rest-spread'
]
},
+ plugins: [],
defineConstants: {
},
+ copy: {
+ patterns: [
+ ],
+ options: {
+ }
+ },
+ framework: '<%= framework %>',
mini: {
postcss: {
- autoprefixer: {
- enable: true,
- config: {
- browsers: [
- 'last 3 versions',
- 'Android >= 4.1',
- 'ios >= 8'
- ]
- }
- },
pxtransform: {
enable: true,
config: {
@@ -45,7 +43,7 @@ const config = {
url: {
enable: true,
config: {
- limit: 10240 // 设定转换尺寸上限
+ limit: 1024 // 设定转换尺寸上限
}
},
cssModules: {
diff --git a/mobx/package.json b/mobx/package.json
index 2a446e1..2f86617 100644
--- a/mobx/package.json
+++ b/mobx/package.json
@@ -26,48 +26,41 @@
"dev:qq": "npm run build:qq -- --watch",
"dev:quickapp": "npm run build:quickapp -- --watch"
},
+ "browserslist": [
+ "last 3 versions",
+ "Android >= 4.1",
+ "ios >= 8"
+ ],
"author": "",
"license": "MIT",
"dependencies": {
+ "@babel/runtime": "^7.7.7",
"@tarojs/components": "<%= version %>",
- "@tarojs/components-qa": "<%= version %>",
- "@tarojs/router": "<%= version %>",
- "@tarojs/taro": "<%= version %>",
- "@tarojs/taro-alipay": "<%= version %>",
- "@tarojs/taro-h5": "<%= version %>",
- "@tarojs/taro-qq": "<%= version %>",
- "@tarojs/taro-quickapp": "<%= version %>",
- "@tarojs/taro-swan": "<%= version %>",
- "@tarojs/taro-tt": "<%= version %>",
- "@tarojs/taro-weapp": "<%= version %>",
- "@tarojs/mobx": "<%= version %>",
- "@tarojs/mobx-h5": "<%= version %>",
- "mobx": "4.8.0",
- "nervjs": "^1.5.5",
- "nerv-devtools": "^1.5.5"
+ "mobx": "^4.8.0",
+ "react-mobx": "^6.1.4",
+ "@tarojs/taro": "<%= version %>",<% if (framework === 'react') {%>
+ "@tarojs/react": "<%= version %>",
+ "react": "^16.10.0"<%}%><% if (framework === 'nerv') {%>
+ "nervjs": "^1.5.0"<%}%><% if (framework === 'vue') {%>
+ "vue": "^2.5.0"<%}%>
},
"devDependencies": {
- "@types/react": "^16.4.6",
- "@types/webpack-env": "^1.13.6",
+ "@types/webpack-env": "^1.13.6",<% if (framework === 'react' || framework === 'nerv') {%>
+ "@types/react": "^1.6.0",<%}%>
"@tarojs/mini-runner": "<%= version %>",
- "@tarojs/webpack-runner": "<%= version %>",
- "babel-plugin-transform-class-properties": "^6.24.1",
- "babel-plugin-transform-decorators-legacy": "^1.3.4",
- "babel-plugin-transform-jsx-stylesheet": "^0.6.5",
- "babel-plugin-transform-object-rest-spread": "^6.26.0",
- "babel-preset-env": "^1.6.1",
+ "@babel/core": "^7.6.4",
+ "@babel/plugin-proposal-class-properties": "7.5.5",
+ "@babel/plugin-proposal-decorators": "^7.7.4",
+ "@babel/preset-env": "7.6.3",
+ "@babel/preset-react": "^7.7.4",
+ "@babel/plugin-transform-runtime": "^7.7.6",
"babel-eslint": "^8.2.3",
- "eslint": "^5.16.0",
- "eslint-config-taro": "<%= version %>",
+ "eslint": "^6.8.0",<% if (framework === 'react' || framework === 'nerv') {%>
"eslint-plugin-react": "^7.8.2",
- "eslint-plugin-react-hooks": "^1.6.1",
+ "eslint-plugin-react-hooks": "^1.6.1",<%}%>
"eslint-plugin-import": "^2.12.0",
- "stylelint": "9.3.0",
- "stylelint-config-taro-rn": "<%= version %>",
- "stylelint-taro-rn": "<%= version %>",
- "eslint-plugin-taro": "<%= version %>"<% if (typescript) {%>,
- "@typescript-eslint/eslint-plugin": "^2.13.0",
- "@typescript-eslint/parser": "^2.13.0",
+ "stylelint": "9.3.0"<% if (typescript) {%>,
+ "@typescript-eslint/parser": "^1.6.0",
"typescript": "^3.0.1"<%}%>
}
}
diff --git a/mobx/src/app.config.js b/mobx/src/app.config.js
new file mode 100644
index 0000000..9870f49
--- /dev/null
+++ b/mobx/src/app.config.js
@@ -0,0 +1,11 @@
+export default {
+ pages: [
+ 'pages/index/index'
+ ],
+ window: {
+ backgroundTextStyle: 'light',
+ navigationBarBackgroundColor: '#fff',
+ navigationBarTitleText: 'WeChat',
+ navigationBarTextStyle: 'black'
+ }
+}
diff --git a/mobx/src/app.jsx b/mobx/src/app.jsx
index 79d9d6b..a72d79a 100644
--- a/mobx/src/app.jsx
+++ b/mobx/src/app.jsx
@@ -1,48 +1,20 @@
-<%if (locals.typescript) {-%>
-import Taro, { Component, Config } from '@tarojs/taro'
-<%} else { -%>
-import Taro, { Component } from '@tarojs/taro'
+<%if (framework === 'react') {-%>
+import React, { Component } from 'react'
+<%} else if (framework === 'nerv') { -%>
+import Nerv, { Component } from 'nervjs'
<%}-%>
-import { Provider } from '@tarojs/mobx'
+import { Provider } from 'react-mobx'
import Index from './pages/index'
import counterStore from './store/counter'
import './app.<%= cssExt %>'
-// 如果需要在 h5 环境中开启 React Devtools
-// 取消以下注释:
-// if (process.env.NODE_ENV !== 'production' && process.env.TARO_ENV === 'h5') {
-// require('nerv-devtools')
-// }
-
const store = {
counterStore
}
class App extends Component {
-
-<%if (locals.typescript) {-%>
- /**
- * 指定config的类型声明为: Taro.Config
- *
- * 由于 typescript 对于 object 类型推导只能推出 Key 的基本类型
- * 对于像 navigationBarTextStyle: 'black' 这样的推导出的类型是 string
- * 提示和声明 navigationBarTextStyle: 'black' | 'white' 类型冲突, 需要显示声明类型
- */
-<%}-%>
- config<%if (locals.typescript) {%>: Config<%}%> = {
- pages: [
- 'pages/index/index'
- ],
- window: {
- backgroundTextStyle: 'light',
- navigationBarBackgroundColor: '#fff',
- navigationBarTitleText: 'WeChat',
- navigationBarTextStyle: 'black'
- }
- }
-
componentDidMount () {}
componentDidShow () {}
@@ -51,15 +23,14 @@ class App extends Component {
componentDidCatchError () {}
- // 在 App 类中的 render() 函数没有实际作用
- // 请勿修改此函数
+ // this.props.children 就是要渲染的页面
render () {
return (
-
+ {this.props.children}
)
}
}
-Taro.render(, document.getElementById('app'))
+export default App
diff --git a/mobx/src/pages/index/index.config.js b/mobx/src/pages/index/index.config.js
new file mode 100644
index 0000000..be3ab00
--- /dev/null
+++ b/mobx/src/pages/index/index.config.js
@@ -0,0 +1,3 @@
+export default {
+ navigationBarTitleText: '首页'
+}
diff --git a/mobx/src/pages/index/index.jsx b/mobx/src/pages/index/index.jsx
index 81b9b13..d4d1107 100644
--- a/mobx/src/pages/index/index.jsx
+++ b/mobx/src/pages/index/index.jsx
@@ -1,11 +1,13 @@
<%if (locals.typescript) {-%>
import { ComponentType } from 'react'
-import Taro, { Component, Config } from '@tarojs/taro'
-<%} else { -%>
-import Taro, { Component } from '@tarojs/taro'
+<%}-%>
+<%if (framework === 'react') {-%>
+import React, { Component } from 'react'
+<%} else if (framework === 'nerv') { -%>
+import Nerv, { Component } from 'nervjs'
<%}-%>
import { View, Button, Text } from '@tarojs/components'
-import { observer, inject } from '@tarojs/mobx'
+import { observer, inject } from 'react-mobx'
import './<%= pageName %>.<%= cssExt %>'
@@ -27,20 +29,6 @@ interface <%= _.capitalize(pageName) %> {
@inject('counterStore')
@observer
class <%= _.capitalize(pageName) %> extends Component {
-
-<%if (locals.typescript) {-%>
- /**
- * 指定config的类型声明为: Taro.Config
- *
- * 由于 typescript 对于 object 类型推导只能推出 Key 的基本类型
- * 对于像 navigationBarTextStyle: 'black' 这样的推导出的类型是 string
- * 提示和声明 navigationBarTextStyle: 'black' | 'white' 类型冲突, 需要显示声明类型
- */
-<%}-%>
- config<%if (locals.typescript) {%>: Config<%}%> = {
- navigationBarTitleText: '首页'
- }
-
componentWillMount () { }
componentWillReact () {
diff --git a/mobx/src/store/counter.js b/mobx/src/store/counter.js
index bc2b198..7221d84 100644
--- a/mobx/src/store/counter.js
+++ b/mobx/src/store/counter.js
@@ -17,4 +17,5 @@ const counterStore = observable({
}, 1000)
}
})
+
export default counterStore
\ No newline at end of file
diff --git a/redux/src/app.jsx b/redux/src/app.jsx
index 5078029..6a89623 100644
--- a/redux/src/app.jsx
+++ b/redux/src/app.jsx
@@ -60,5 +60,3 @@ class App extends Component {
)
}
}
-
-Taro.render(, document.getElementById('app'))