Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions default-youshu/_editorconfig
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions default-youshu/_eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<%if (framework === 'vue') {-%>
// ESLint 检查 .vue 文件需要单独配置编辑器:
// https://eslint.vuejs.org/user-guide/#editor-integrations
<%}-%>
{
'extends': ['taro/<%= framework %>']
}
6 changes: 6 additions & 0 deletions default-youshu/_gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dist/
deploy_versions/
.temp/
.rn_temp/
node_modules/
.DS_Store
10 changes: 10 additions & 0 deletions default-youshu/_npmrc
Original file line number Diff line number Diff line change
@@ -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/
10 changes: 10 additions & 0 deletions default-youshu/babel.config.js
Original file line number Diff line number Diff line change
@@ -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 %>
}]
]
}
9 changes: 9 additions & 0 deletions default-youshu/config/dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
env: {
NODE_ENV: '"development"'
},
defineConstants: {
},
mini: {},
h5: {}
}
70 changes: 70 additions & 0 deletions default-youshu/config/index.js
Original file line number Diff line number Diff line change
@@ -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'))
}
18 changes: 18 additions & 0 deletions default-youshu/config/prod.js
Original file line number Diff line number Diff line change
@@ -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, [])
* }
*/
}
}
18 changes: 18 additions & 0 deletions default-youshu/global.d.ts
Original file line number Diff line number Diff line change
@@ -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;
}
}
60 changes: 60 additions & 0 deletions default-youshu/package.json.tmpl
Original file line number Diff line number Diff line change
@@ -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"<%}%>
}
}
13 changes: 13 additions & 0 deletions default-youshu/project.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"miniprogramRoot": "./dist",
"projectname": "<%= projectName %>",
"description": "<%= description %>",
"appid": "touristappid",
"setting": {
"urlCheck": true,
"es6": false,
"postcss": false,
"minified": false
},
"compileType": "miniprogram"
}
11 changes: 11 additions & 0 deletions default-youshu/src/app.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export default {
pages: [
'pages/index/index'
],
window: {
backgroundTextStyle: 'light',
navigationBarBackgroundColor: '#fff',
navigationBarTitleText: 'WeChat',
navigationBarTextStyle: 'black'
}
}
Empty file added default-youshu/src/app.css
Empty file.
84 changes: 84 additions & 0 deletions default-youshu/src/app.js
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions default-youshu/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta content="width=device-width,initial-scale=1,user-scalable=no" name="viewport">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta name="format-detection" content="telephone=no,address=no">
<meta name="apple-mobile-web-app-status-bar-style" content="white">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" >
<title></title>
<script>
!function(x){function w(){var v,u,t,tes,s=x.document,r=s.documentElement,a=r.getBoundingClientRect().width;if(!v&&!u){var n=!!x.navigator.appVersion.match(/AppleWebKit.*Mobile.*/);v=x.devicePixelRatio;tes=x.devicePixelRatio;v=n?v:1,u=1/v}if(a>=640){r.style.fontSize="40px"}else{if(a<=320){r.style.fontSize="20px"}else{r.style.fontSize=a/320*20+"px"}}}x.addEventListener("resize",function(){w()});w()}(window);
</script>
</head>
<body>
<div id="app"></div>
</body>
</html>
3 changes: 3 additions & 0 deletions default-youshu/src/pages/index/index.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
navigationBarTitleText: '首页'
}
Empty file.
28 changes: 28 additions & 0 deletions default-youshu/src/pages/index/index.jsx
Original file line number Diff line number Diff line change
@@ -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 (
<View className='<%= pageName %>'>
<Text>Hello world!</Text>
</View>
)
}
}
Loading