Your Name 3 年之前
當前提交
01e91de24d

+ 12
- 0
.editorconfig 查看文件

@@ -0,0 +1,12 @@
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

+ 7
- 0
.eslintrc 查看文件

@@ -0,0 +1,7 @@
1
+{
2
+  "extends": ["taro/react"],
3
+  "rules": {
4
+    "react/jsx-uses-react": "off",
5
+    "react/react-in-jsx-scope": "off"
6
+  }
7
+}

+ 7
- 0
.gitignore 查看文件

@@ -0,0 +1,7 @@
1
+dist/
2
+deploy_versions/
3
+.temp/
4
+.rn_temp/
5
+node_modules/
6
+.DS_Store
7
+*.lock

+ 10
- 0
babel.config.js 查看文件

@@ -0,0 +1,10 @@
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: false
8
+    }]
9
+  ]
10
+}

+ 9
- 0
config/dev.js 查看文件

@@ -0,0 +1,9 @@
1
+module.exports = {
2
+  env: {
3
+    NODE_ENV: '"development"'
4
+  },
5
+  defineConstants: {
6
+  },
7
+  mini: {},
8
+  h5: {}
9
+}

+ 76
- 0
config/index.js 查看文件

@@ -0,0 +1,76 @@
1
+const path = require('path')
2
+
3
+const config = {
4
+  projectName: 'miniapp',
5
+  date: '2021-8-9',
6
+  designWidth: 750,
7
+  deviceRatio: {
8
+    640: 2.34 / 2,
9
+    750: 1,
10
+    828: 1.81 / 2
11
+  },
12
+  sourceRoot: 'src',
13
+  outputRoot: 'dist',
14
+  plugins: [],
15
+  defineConstants: {
16
+  },
17
+  copy: {
18
+    patterns: [
19
+    ],
20
+    options: {
21
+    }
22
+  },
23
+  alias: {
24
+    '@/components': path.resolve(__dirname, '..', 'src/components'),
25
+    '@/layouts': path.resolve(__dirname, '..', 'src/layouts'),
26
+  },
27
+  framework: 'react',
28
+  mini: {
29
+    postcss: {
30
+      pxtransform: {
31
+        enable: true,
32
+        config: {
33
+
34
+        }
35
+      },
36
+      url: {
37
+        enable: true,
38
+        config: {
39
+          limit: 1024 // 设定转换尺寸上限
40
+        }
41
+      },
42
+      cssModules: {
43
+        enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
44
+        config: {
45
+          namingPattern: 'module', // 转换模式,取值为 global/module
46
+          generateScopedName: '[name]__[local]___[hash:base64:5]'
47
+        }
48
+      }
49
+    }
50
+  },
51
+  h5: {
52
+    publicPath: '/',
53
+    staticDirectory: 'static',
54
+    postcss: {
55
+      autoprefixer: {
56
+        enable: true,
57
+        config: {
58
+        }
59
+      },
60
+      cssModules: {
61
+        enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
62
+        config: {
63
+          namingPattern: 'module', // 转换模式,取值为 global/module
64
+          generateScopedName: '[name]__[local]___[hash:base64:5]'
65
+        }
66
+      }
67
+    }
68
+  }
69
+}
70
+
71
+module.exports = function (merge) {
72
+  if (process.env.NODE_ENV === 'development') {
73
+    return merge({}, config, require('./dev'))
74
+  }
75
+  return merge({}, config, require('./prod'))
76
+}

+ 18
- 0
config/prod.js 查看文件

@@ -0,0 +1,18 @@
1
+module.exports = {
2
+  env: {
3
+    NODE_ENV: '"production"'
4
+  },
5
+  defineConstants: {
6
+  },
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
+  }
18
+}

+ 8
- 0
jsconfig.json 查看文件

@@ -0,0 +1,8 @@
1
+{
2
+  "compilerOptions": {
3
+    "baseUrl": ".",
4
+    "paths": {
5
+      "@/*": ["./src/*"]
6
+    }
7
+  }
8
+}

+ 60
- 0
package.json 查看文件

@@ -0,0 +1,60 @@
1
+{
2
+  "name": "miniapp",
3
+  "version": "1.0.0",
4
+  "private": true,
5
+  "description": "十公里",
6
+  "templateInfo": {
7
+    "name": "default",
8
+    "typescript": false,
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
+  "dependencies": {
38
+    "@babel/runtime": "^7.7.7",
39
+    "@tarojs/components": "3.3.2",
40
+    "@tarojs/runtime": "3.3.2",
41
+    "@tarojs/taro": "3.3.2",
42
+    "@tarojs/react": "3.3.2",
43
+    "react-dom": "^17.0.0",
44
+    "react": "^17.0.0"
45
+  },
46
+  "devDependencies": {
47
+    "@types/webpack-env": "^1.13.6",
48
+    "@types/react": "^17.0.2",
49
+    "@tarojs/mini-runner": "3.3.2",
50
+    "@babel/core": "^7.8.0",
51
+    "@tarojs/webpack-runner": "3.3.2",
52
+    "babel-preset-taro": "3.3.2",
53
+    "eslint-config-taro": "3.3.2",
54
+    "eslint": "^6.8.0",
55
+    "eslint-plugin-react": "^7.8.2",
56
+    "eslint-plugin-import": "^2.12.0",
57
+    "eslint-plugin-react-hooks": "^4.2.0",
58
+    "stylelint": "9.3.0"
59
+  }
60
+}

+ 13
- 0
project.config.json 查看文件

@@ -0,0 +1,13 @@
1
+{
2
+  "miniprogramRoot": "./dist",
3
+  "projectname": "miniapp",
4
+  "description": "十公里",
5
+  "appid": "touristappid",
6
+  "setting": {
7
+    "urlCheck": true,
8
+    "es6": false,
9
+    "postcss": false,
10
+    "minified": false
11
+  },
12
+  "compileType": "miniprogram"
13
+}

+ 9
- 0
project.tt.json 查看文件

@@ -0,0 +1,9 @@
1
+{
2
+  "miniprogramRoot": "./",
3
+  "projectname": "miniapp",
4
+  "appid": "touristappid",
5
+  "setting": {
6
+    "es6": false,
7
+    "minified": false
8
+  }
9
+}

+ 20
- 0
src/app.config.js 查看文件

@@ -0,0 +1,20 @@
1
+export default {
2
+  pages: [
3
+    'pages/index/index',
4
+    'pages/test/index'
5
+  ],
6
+  window: {
7
+    backgroundTextStyle: 'light',
8
+    navigationBarBackgroundColor: '#fff',
9
+    navigationBarTitleText: 'WeChat',
10
+    navigationBarTextStyle: 'black'
11
+  },
12
+  useExtendedLib: {
13
+    weui: true,
14
+  },
15
+  permission: {
16
+    'scope.userLocation': {
17
+      desc: '您的位置信息将方便您更好的小程序体验'
18
+    }
19
+  }
20
+}

+ 20
- 0
src/app.js 查看文件

@@ -0,0 +1,20 @@
1
+import { Component } from 'react'
2
+import './app.less'
3
+
4
+class App extends Component {
5
+
6
+  componentDidMount () {}
7
+
8
+  componentDidShow () {}
9
+
10
+  componentDidHide () {}
11
+
12
+  componentDidCatchError () {}
13
+
14
+  // this.props.children 是将要会渲染的页面
15
+  render () {
16
+    return this.props.children
17
+  }
18
+}
19
+
20
+export default App

+ 0
- 0
src/app.less 查看文件


+ 19
- 0
src/index.html 查看文件

@@ -0,0 +1,19 @@
1
+<!DOCTYPE html>
2
+<html>
3
+<head>
4
+  <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
5
+  <meta content="width=device-width,initial-scale=1,user-scalable=no" name="viewport">
6
+  <meta name="apple-mobile-web-app-capable" content="yes">
7
+  <meta name="apple-touch-fullscreen" content="yes">
8
+  <meta name="format-detection" content="telephone=no,address=no">
9
+  <meta name="apple-mobile-web-app-status-bar-style" content="white">
10
+  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" >
11
+  <title></title>
12
+  <script>
13
+    !function(n){function e(){var e=n.document.documentElement,t=e.getBoundingClientRect().width;e.style.fontSize=t>=640?"40px":t<=320?"20px":t/320*20+"px"}n.addEventListener("resize",(function(){e()})),e()}(window);
14
+  </script>
15
+</head>
16
+<body>
17
+  <div id="app"></div>
18
+</body>
19
+</html>

+ 7
- 0
src/layouts/Demo1.jsx 查看文件

@@ -0,0 +1,7 @@
1
+import React from 'react'
2
+
3
+export default (props) => {
4
+  return (
5
+    <view>demo1</view>
6
+  )
7
+}

+ 7
- 0
src/layouts/Demo2.jsx 查看文件

@@ -0,0 +1,7 @@
1
+import React from 'react'
2
+
3
+export default (props) => {
4
+  return (
5
+    <view>demo2</view>
6
+  )
7
+}

+ 31
- 0
src/layouts/index.jsx 查看文件

@@ -0,0 +1,31 @@
1
+import React, { Suspense, useState } from 'react'
2
+import tabList from './tabbar'
3
+import './style.less'
4
+
5
+const Demo1 = React.lazy(() => import('./Demo1'))
6
+const Demo2 = React.lazy(() => import('./Demo2'))
7
+
8
+export default (props) => {
9
+  const [currentTab, setCurrentTab] = useState(1)
10
+
11
+  const handleTabChange = (e) => {
12
+    const { item } = e.detail
13
+    setCurrentTab(item.id)
14
+  }
15
+
16
+  const Comp = currentTab === 1 ? Demo1 : Demo2
17
+
18
+  return (
19
+    <Suspense fallback='loading...'>
20
+      <view className='main-layout'>
21
+        <view className='main-navbar'></view>
22
+        <view className='main-container'>
23
+          <Comp />  
24
+        </view>
25
+        <view className='main-tabbar'>
26
+          <mp-tabbar list={tabList} onChange={handleTabChange}></mp-tabbar>
27
+        </view>
28
+      </view>
29
+    </Suspense>
30
+  )
31
+}

+ 20
- 0
src/layouts/style.less 查看文件

@@ -0,0 +1,20 @@
1
+.main-layout {
2
+  display: flex;
3
+  flex-direction: column;
4
+  width: 100vw;
5
+  height: 100vh;
6
+  overflow: hidden;
7
+  box-sizing: border-box;
8
+
9
+  .main-navbar {
10
+    flex: none;
11
+  }
12
+
13
+  .main-tabber {
14
+    flex: none;
15
+  }
16
+
17
+  .main-container {
18
+    flex: auto;
19
+  }
20
+}

+ 13
- 0
src/layouts/tabbar.js 查看文件

@@ -0,0 +1,13 @@
1
+
2
+const tabbar = [
3
+  {
4
+    id: 1,
5
+    text: '首页',
6
+  },
7
+  {
8
+    id: 2,
9
+    text: '其他页',
10
+  }
11
+]
12
+
13
+export default tabbar

+ 3
- 0
src/pages/index/index.config.js 查看文件

@@ -0,0 +1,3 @@
1
+export default {
2
+  navigationBarTitleText: '首页'
3
+}

+ 24
- 0
src/pages/index/index.jsx 查看文件

@@ -0,0 +1,24 @@
1
+import { Component } from 'react'
2
+import { View, Text } from '@tarojs/components'
3
+import './index.less'
4
+
5
+export default class Index extends Component {
6
+
7
+  componentWillMount () { }
8
+
9
+  componentDidMount () { }
10
+
11
+  componentWillUnmount () { }
12
+
13
+  componentDidShow () { }
14
+
15
+  componentDidHide () { }
16
+
17
+  render () {
18
+    return (
19
+      <View className='index'>
20
+        <Text>Hello world!</Text>
21
+      </View>
22
+    )
23
+  }
24
+}

+ 0
- 0
src/pages/index/index.less 查看文件


+ 6
- 0
src/pages/test/index.config.js 查看文件

@@ -0,0 +1,6 @@
1
+export default {
2
+  navigationBarTitleText: '测试页面',
3
+  usingComponents: {
4
+    "mp-tabbar": "weui-miniprogram/tabbar/tabbar"
5
+  }
6
+}

+ 7
- 0
src/pages/test/index.jsx 查看文件

@@ -0,0 +1,7 @@
1
+import Layout from '@/layouts'
2
+
3
+export default (props) => {
4
+  return (
5
+    <Layout>123</Layout>
6
+  )
7
+}

+ 0
- 0
src/pages/test/index.less 查看文件