├── .editorconfig
├── .eslintignore
├── .eslintrc.js
├── .gitignore
├── .prettierignore
├── .prettierrc
├── .yarnrc
├── babel.config.js
├── changelog.md
├── config
├── dev.js
├── index.js
└── prod.js
├── global.d.ts
├── package.json
├── project.config.json
├── readme.md
├── src
├── app.config.ts
├── app.less
├── app.tsx
├── components
│ └── DemoTxt
│ │ ├── index.module.scss
│ │ └── index.tsx
├── constants
│ └── env.ts
├── index.html
├── pages
│ ├── home2
│ │ ├── index.config.ts
│ │ ├── index.module.scss
│ │ └── index.tsx
│ └── index
│ │ ├── index.config.ts
│ │ ├── index.module.scss
│ │ └── index.tsx
├── services
│ └── demo.ts
├── store
│ ├── index.ts
│ ├── loader.js
│ ├── loader_manual.ts
│ └── models
│ │ └── common.ts
├── typing
│ └── demo.ts
└── utils
│ ├── index.ts
│ └── request.ts
└── tsconfig.json
/.editorconfig:
--------------------------------------------------------------------------------
1 | # http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | indent_style = space
6 | indent_size = 2
7 | charset = utf-8
8 | trim_trailing_whitespace = true
9 | insert_final_newline = true
10 |
11 | [*.md]
12 | trim_trailing_whitespace = false
13 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | **/dist/**
2 | **/node_modules/**
3 | **/server.js
4 | **/webpack.config*.js
5 | **/flow-typed/**
6 | src/types/**
7 | src/serviceWorker.js
8 | *.md
9 | *.log
10 | *.lock
11 | scripts/**
12 | public/**/*
13 | config/**/*
14 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | extends: ['taro/react'],
3 | };
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | dist/
2 | .temp/
3 | .rn_temp/
4 | node_modules/
5 | img/
6 | package-lock.json
7 | yarn-error.log
8 | yarn.lock
9 |
--------------------------------------------------------------------------------
/.prettierignore:
--------------------------------------------------------------------------------
1 | **/*.svg
2 | package.json
3 | .umi
4 | .umi-production
5 | AUTHORS.txt
6 | lib/
7 | es/
8 | dist/
9 | coverage/
10 | CNAME
11 | LICENSE
12 | yarn.lock
13 | netlify.toml
14 | yarn-error.log
15 | *.sh
16 | *.snap
17 | .gitignore
18 | .npmignore
19 | .prettierignore
20 | .DS_Store
21 | .editorconfig
22 | .eslintignore
23 | **/*.yml
24 |
25 |
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "singleQuote": true,
3 | "trailingComma": "all",
4 | "proseWrap": "never",
5 | "overrides": [{
6 | "files": ".prettierrc",
7 | "options": {
8 | "parser": "json"
9 | }
10 | }],
11 | "tabWidth": 2,
12 | "useTabs": false,
13 | "semi": true,
14 | "jsxSingleQuote": true,
15 | "bracketSpacing": true,
16 | "jsxBracketSameLine": true,
17 | "arrowParens": "avoid",
18 | "endOfLine": "crlf"
19 | }
20 |
--------------------------------------------------------------------------------
/.yarnrc:
--------------------------------------------------------------------------------
1 | omit.js "https://registry.npmjs.org/omit.js"
2 | "@kkb:registry" "https://registry-npm.kaikeba.com"
3 | "@ant-design:registry" "https://registry.npm.taobao.org"
4 | registry "http://vd.kaikeba.com"
5 |
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | // babel-preset-taro 更多选项和默认值:
2 | // https://github.com/NervJS/taro/blob/next/packages/babel-preset-taro/README.md
3 | module.exports = {
4 | presets: [
5 | ['taro', {
6 | framework: 'react',
7 | ts: true
8 | }]
9 | ]
10 | }
11 |
--------------------------------------------------------------------------------
/changelog.md:
--------------------------------------------------------------------------------
1 | ## 更新到Taro v1.3.9
2 | > Taro v1.3.9
3 |
4 | ## 2018年11月26日
5 | 优化action 代码
6 |
--------------------------------------------------------------------------------
/config/dev.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | env: {
3 | NODE_ENV: '"development"',
4 | FIG_ENV: '"dev"',
5 | },
6 | defineConstants: {},
7 | mini: {},
8 | h5: {
9 | esnextModules: ['taro-ui'],
10 | },
11 | };
12 |
--------------------------------------------------------------------------------
/config/index.js:
--------------------------------------------------------------------------------
1 | const config = {
2 | projectName: 'taro-kit',
3 | date: '2020-10-16',
4 | designWidth: 750,
5 | deviceRatio: {
6 | 640: 2.34 / 2,
7 | 750: 1,
8 | 828: 1.81 / 2,
9 | },
10 | sourceRoot: 'src',
11 | outputRoot: 'dist',
12 | plugins: [],
13 | defineConstants: {},
14 | copy: {
15 | patterns: [],
16 | options: {},
17 | },
18 | framework: 'react',
19 | mini: {
20 | postcss: {
21 | pxtransform: {
22 | enable: true,
23 | config: {},
24 | },
25 | url: {
26 | enable: true,
27 | config: {
28 | limit: 1024, // 设定转换尺寸上限
29 | },
30 | },
31 | cssModules: {
32 | enable: true, // 默认为 false,如需使用 css modules 功能,则设为 true
33 | config: {
34 | namingPattern: 'module', // 转换模式,取值为 global/module
35 | generateScopedName: '[name]__[local]___[hash:base64:5]',
36 | },
37 | },
38 | },
39 | },
40 | h5: {
41 | publicPath: '/',
42 | staticDirectory: 'static',
43 | postcss: {
44 | autoprefixer: {
45 | enable: true,
46 | config: {},
47 | },
48 | cssModules: {
49 | enable: true, // 默认为 false,如需使用 css modules 功能,则设为 true
50 | config: {
51 | namingPattern: 'module', // 转换模式,取值为 global/module
52 | generateScopedName: '[name]__[local]___[hash:base64:5]',
53 | },
54 | },
55 | },
56 | // 小程序端
57 | weapp: {
58 | module: {
59 | postcss: {
60 | cssModules: {
61 | enable: true,
62 | config: {
63 | namingPattern: 'module',
64 | generateScopedName: '[name]__[local]___[hash:base64:5]',
65 | },
66 | },
67 | },
68 | },
69 | },
70 | },
71 | };
72 |
73 | module.exports = function (merge) {
74 | if (process.env.NODE_ENV === 'development') {
75 | return merge({}, config, require('./dev'));
76 | }
77 | return merge({}, config, require('./prod'));
78 | };
79 |
--------------------------------------------------------------------------------
/config/prod.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | env: {
3 | NODE_ENV: '"production"',
4 | FIG_ENV: '"prod"',
5 | },
6 | defineConstants: {},
7 | mini: {},
8 | h5: {
9 | /**
10 | * 如果h5端编译后体积过大,可以使用webpack-bundle-analyzer插件对打包体积进行分析。
11 | * 参考代码如下:
12 | * webpackChain (chain) {
13 | * chain.plugin('analyzer')
14 | * .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, [])
15 | * }
16 | */
17 | esnextModules: ['taro-ui'],
18 | },
19 | };
20 |
--------------------------------------------------------------------------------
/global.d.ts:
--------------------------------------------------------------------------------
1 | declare module "*.png";
2 | declare module "*.gif";
3 | declare module "*.jpg";
4 | declare module "*.jpeg";
5 | declare module "*.svg";
6 | declare module "*.css";
7 | declare module "*.less";
8 | declare module "*.scss";
9 | declare module "*.sass";
10 | declare module "*.styl";
11 |
12 | // @ts-ignore
13 | declare const process: {
14 | env: {
15 | TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'quickapp' | 'qq' | 'jd';
16 | [key: string]: any;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "taro-kit",
3 | "version": "1.0.1",
4 | "private": true,
5 | "description": "taro-kit",
6 | "templateInfo": {
7 | "name": "redux",
8 | "typescript": true,
9 | "css": "less"
10 | },
11 | "scripts": {
12 | "build:weapp": "taro build --type weapp",
13 | "build:swan": "taro build --type swan",
14 | "build:alipay": "taro build --type alipay",
15 | "build:tt": "taro build --type tt",
16 | "build:h5": "taro build --type h5",
17 | "build:rn": "taro build --type rn",
18 | "build:qq": "taro build --type qq",
19 | "build:jd": "taro build --type jd",
20 | "build:quickapp": "taro build --type quickapp",
21 | "dev:weapp": "npm run build:weapp -- --watch",
22 | "dev:swan": "npm run build:swan -- --watch",
23 | "dev:alipay": "npm run build:alipay -- --watch",
24 | "dev:tt": "npm run build:tt -- --watch",
25 | "dev:h5": "npm run build:h5 -- --watch",
26 | "dev:rn": "npm run build:rn -- --watch",
27 | "dev:qq": "npm run build:qq -- --watch",
28 | "dev:jd": "npm run build:jd -- --watch",
29 | "dev:quickapp": "npm run build:quickapp -- --watch"
30 | },
31 | "browserslist": [
32 | "last 3 versions",
33 | "Android >= 4.1",
34 | "ios >= 8"
35 | ],
36 | "author": "",
37 | "license": "MIT",
38 | "dependencies": {
39 | "@babel/runtime": "^7.7.7",
40 | "@rematch/core": "^1.4.0",
41 | "@rematch/loading": "^1.2.1",
42 | "@tarojs/components": "3.3.15",
43 | "@tarojs/react": "3.3.15",
44 | "@tarojs/runtime": "3.3.15",
45 | "@tarojs/taro": "3.3.15",
46 | "react": "^16.10.0",
47 | "react-dom": "^16.10.0",
48 | "react-redux": "^7.2.0",
49 | "redux": "^4.0.0",
50 | "redux-logger": "^3.0.6",
51 | "redux-thunk": "^2.3.0",
52 | "taro-ui": "^3.0.0-alpha.3",
53 | "taro-weapp-poster": "^1.3.0"
54 | },
55 | "devDependencies": {
56 | "@babel/core": "^7.8.0",
57 | "@tarojs/mini-runner": "3.3.15",
58 | "@tarojs/webpack-runner": "3.3.15",
59 | "@types/react": "^16.0.0",
60 | "@types/react-redux": "^7.1.9",
61 | "@types/webpack-env": "^1.13.6",
62 | "@typescript-eslint/eslint-plugin": "^2.x",
63 | "@typescript-eslint/parser": "^2.x",
64 | "babel-preset-taro": "3.3.15",
65 | "eslint": "^6.8.0",
66 | "eslint-config-taro": "3.3.15",
67 | "eslint-plugin-import": "^2.12.0",
68 | "eslint-plugin-react": "^7.8.2",
69 | "eslint-plugin-react-hooks": "^1.6.1",
70 | "stylelint": "9.3.0",
71 | "typescript": "^3.7.0"
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/project.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "miniprogramRoot": "dist/",
3 | "projectname": "taro-kit",
4 | "description": "taro-kit",
5 | "appid": "touristappid",
6 | "setting": {
7 | "urlCheck": true,
8 | "es6": false,
9 | "enhance": false,
10 | "postcss": false,
11 | "preloadBackgroundData": false,
12 | "minified": false,
13 | "newFeature": false,
14 | "coverView": true,
15 | "nodeModules": false,
16 | "autoAudits": false,
17 | "showShadowRootInWxmlPanel": true,
18 | "scopeDataCheck": false,
19 | "uglifyFileName": false,
20 | "checkInvalidKey": true,
21 | "checkSiteMap": true,
22 | "uploadWithSourceMap": true,
23 | "compileHotReLoad": false,
24 | "useMultiFrameRuntime": true,
25 | "useApiHook": true,
26 | "useApiHostProcess": true,
27 | "babelSetting": {
28 | "ignore": [],
29 | "disablePlugins": [],
30 | "outputPath": ""
31 | },
32 | "bundle": false,
33 | "useIsolateContext": true,
34 | "useCompilerModule": true,
35 | "userConfirmedUseCompilerModuleSwitch": false,
36 | "userConfirmedBundleSwitch": false,
37 | "packNpmManually": false,
38 | "packNpmRelationList": [],
39 | "minifyWXSS": true
40 | },
41 | "compileType": "miniprogram",
42 | "condition": {}
43 | }
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 |
9 |
10 | ## 可以 watch 这个项目,有更新,及时知道
11 |
12 | > 项目会不断迭代,有需求欢迎 issue 如果能帮到你,那就给个 star 呗!
13 |
14 | > 1 年前输出了一套 taro-kit 脚手架,有不少人加我微信,咨询一些问题,这段时间把这个脚手架升级后,总结并录制了课程,希望能帮助到大家,提高效率,节约时间。
15 |
16 | CLI 工具安装首先,你需要使用 npm 或者 yarn 全局安装@tarojs/cli,或者直接使用 npx:
17 |
18 | ```js
19 | # 使用 npm 安装 CLI
20 | $ npm install -g @tarojs/cli
21 | # OR 使用 yarn 安装 CLI
22 | $ yarn global add @tarojs/cli
23 | # OR 安装了 cnpm,使用 cnpm 安装 CLI
24 | $ cnpm install -g @tarojs/cli
25 | ```
26 |
27 | ## 项目更新:
28 |
29 | > 2021年11月30日
30 |
31 | - 更新@tarojs/taro到:3.3.15
32 |
33 | - 添加海报生成插件:[taro-weapp-poster](https://github.com/Clycheng/taro-weapp-poster)
34 |
35 |
36 | > 2021 年 02 月 03 日 星期三
37 |
38 | - 更新依赖到:3.0.26
39 | - 更新.eslintrc
40 | - 添加 babel 配置
41 | - 添加 global.d.ts
42 | - 添加 tsconfig
43 | - 添加 yarn.lock 文件
44 | - 更新 config 文件
45 |
46 |
47 | ```
48 | taro update project v版本号
49 | ```
50 |
51 | > 
52 |
53 | ## 文章
54 |
55 | - [【小程序 taro 最佳实践】http 请求封装(方便使用,增加 token,统一错误日志记录和上报)](https://segmentfault.com/a/1190000016533592)
56 | - [【小程序 taro 最佳实践】异步 action 优雅实践(简化流程)](https://segmentfault.com/a/1190000016534001)
57 | - [【taro 最佳实践】设置好基础开发字体尺寸](https://segmentfault.com/a/1190000016514478)
58 |
59 | - [Taro 小程序,从 0 到 1 架构项目,打造自己的完美脚手架。 ](https://segmentfault.com/a/1190000019020009)
60 |
61 | ## 功能列表
62 |
63 | - [x] 封装 api 请求方式
64 | - [x] 更方便的创建 action:增加 createApiAction
65 | - [x] 基础像素试着为 1 倍即:1px 会编译成 2rpx(小程序默认是 2 倍)符合习惯
66 | - [x] 基础 demo 案列
67 | - [x] 增加生成海报类
68 |
69 | ## 升级功能列表
70 |
71 | - [x] 01.taro 从 0 到 1 项目架构课程介绍
72 | - [x] 02.初始化项目流程介绍、目录设计
73 | - [x] 03.让 alias 别名解决路径引用的烦恼
74 | - [x] 04.请求 api 返回 redux 的状态流程
75 | - [x] 05.封装 request get 请求,给 url 添加时间戳防止浏览器缓存
76 | - [x] 06.封装 request post Content-Type 分类请求
77 | - [x] 07.把 taro-advance 脚手架推送到私有仓库
78 | - [x] 08.弱网请求失败时自动发起 api 重试
79 | - [x] 09.异常日志上报封装设计思路
80 | - [x] 10.异常日志上报封装,五种级别输出。
81 | - [x] 11.上报收集日志平台系统介绍
82 | - [x] 12.实战接入日志平台
83 | - [x] 13.深度序列化错误 error 控制台上报
84 | - [x] 14.登录流程讲解(前端和后端实现流程)
85 | - [x] 15.登录实现详细讲解(token 附加到请求 header 头)
86 | - [x] 16.用户授权后更新用户信息流程
87 | - [x] 17.设计 createApiAction 自动 dispatch 优化开发体验
88 | - [x] 18.改造 actionType 支持庞大业务
89 | - [x] 19.Action 三种 ActionType 的集合
90 | - [x] 20.简化 reducers 的 swich 繁琐操作
91 | - [x] 21.增加 request 的状态
92 | - [x] 22.课程总结
93 | - [x] 23.添加 Prettier 格式化配置
94 |
95 | > 这个可以让你的 Taro 小程序跑的更优雅一些
96 |
97 | #### 升级后的项目仓库地址: 观看视频的同学加微信,发送你的 gitlab 账号,添加权限,你就看源代码了。
98 |
99 | https://gitlab.com/itxishu/taro-advance.git
100 |
101 | ## 观看地址:segmentfault
102 |
103 | #### 购买路径
104 | 在 https://shudong.wang 加我微信
105 |
106 | https://segmentfault.com/ls/1650000018991514
107 |
108 | ## 适宜人群
109 |
110 | - taro 小程序开发者
111 | - 需要 taro 基础架构开发人员
112 |
113 | ## 课程说明
114 |
115 | 本次课程主要针对于,正在使用 taro 小程序框架的同学,通过课程,你可以学到,框架的 request 请求优雅封装,异常自动重试,日志异常上报, redux 的三剑客优雅的配合使用, reducer 的 swich 简化繁琐操作,增加 state 的请求前,请求成功和失败的状态等。从开始架构足以支撑庞大业务小程序项目
116 |
117 | 课程有问题可以在 https://shudong.wang 我的博客扎到我,添加微信咨询
118 |
119 | 
120 |
121 | #### 有问题加微信问吧
122 |
123 | https://www.shudong.wang/about
124 |
--------------------------------------------------------------------------------
/src/app.config.ts:
--------------------------------------------------------------------------------
1 | export default {
2 | pages: ['pages/index/index', 'pages/home2/index'],
3 | window: {
4 | backgroundTextStyle: 'light',
5 | navigationBarBackgroundColor: '#fff',
6 | navigationBarTitleText: 'WeChat',
7 | navigationBarTextStyle: 'black',
8 | },
9 | };
10 |
--------------------------------------------------------------------------------
/src/app.less:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wsdo/taro-kit/e894de3cb066a80ceaba63f049562789776d8fa2/src/app.less
--------------------------------------------------------------------------------
/src/app.tsx:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 | import { Provider } from 'react-redux';
3 | import configStore from './store';
4 |
5 | import './app.less';
6 |
7 | const store = configStore();
8 |
9 | class App extends Component {
10 | componentDidMount() {}
11 |
12 | componentDidShow() {}
13 |
14 | componentDidHide() {}
15 |
16 | componentDidCatchError() {}
17 |
18 | // 在 App 类中的 render() 函数没有实际作用
19 | // 请勿修改此函数
20 | render() {
21 | return