Skip to content

Commit

Permalink
docs(app): 增加app结构.同步输出小程序页面
Browse files Browse the repository at this point in the history
  • Loading branch information
sssssssugar committed Jun 24, 2021
1 parent 6bb7a10 commit 035f818
Show file tree
Hide file tree
Showing 21 changed files with 333 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# production
/dist
/docs-dist
/app-dist

# misc
.DS_Store
Expand All @@ -20,6 +21,7 @@
.umi-test
.env.local


# ide
/.vscode
/.idea
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@
## 安装

```bash
$ npm i taro-hook --save
$ npm i taro-hooks --save
```

## 使用

```jsx
import { useEnv } from 'taro-hook';
import { useEnv } from 'taro-hooks';
```

## 参与贡献
Expand Down
12 changes: 12 additions & 0 deletions app/.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 app/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
extends: ['taro/react'],
rules: {
'react/jsx-uses-react': 'off',
'react/react-in-jsx-scope': 'off',
},
};
6 changes: 6 additions & 0 deletions app/.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
13 changes: 13 additions & 0 deletions app/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// babel-preset-taro 更多选项和默认值:
// https://github.com/NervJS/taro/blob/next/packages/babel-preset-taro/README.md
module.exports = {
presets: [
[
'taro',
{
framework: 'react',
ts: true,
},
],
],
};
10 changes: 10 additions & 0 deletions app/config/dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
env: {
NODE_ENV: '"development"',
},
defineConstants: {},
mini: {},
h5: {
esnextModules: ['taro-ui'],
},
};
64 changes: 64 additions & 0 deletions app/config/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
const config = {
projectName: 'taro-hooks',
date: '2021-6-24',
designWidth: 750,
deviceRatio: {
640: 2.34 / 2,
750: 1,
828: 1.81 / 2,
},
sourceRoot: 'src',
outputRoot: '../app-dist',
plugins: [],
defineConstants: {},
copy: {
patterns: [],
options: {},
},
framework: 'react',
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'));
};
17 changes: 17 additions & 0 deletions app/config/prod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
env: {
NODE_ENV: '"production"',
},
defineConstants: {},
mini: {},
h5: {
/**
* 如果h5端编译后体积过大,可以使用webpack-bundle-analyzer插件对打包体积进行分析。
* 参考代码如下:
* webpackChain (chain) {
* chain.plugin('analyzer')
* .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, [])
* }
*/
},
};
66 changes: 66 additions & 0 deletions app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"name": "app",
"version": "1.0.0",
"private": true,
"description": "taro-hooks weapp & h5 demo",
"templateInfo": {
"name": "taro-ui",
"typescript": true,
"css": "less"
},
"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:h5": "taro build --type h5",
"build:rn": "taro build --type rn",
"build:qq": "taro build --type qq",
"build:jd": "taro build --type jd",
"build:quickapp": "taro build --type quickapp",
"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:h5": "npm run build:h5 -- --watch",
"dev:rn": "npm run build:rn -- --watch",
"dev:qq": "npm run build:qq -- --watch",
"dev:jd": "npm run build:jd -- --watch",
"dev:quickapp": "npm run build:quickapp -- --watch"
},
"browserslist": [
"last 3 versions",
"Android >= 4.1",
"ios >= 8"
],
"author": "",
"dependencies": {
"@babel/runtime": "^7.7.7",
"@tarojs/cli": "3.2.13",
"@tarojs/components": "3.2.13",
"@tarojs/runtime": "3.2.13",
"@tarojs/taro": "3.2.13",
"lodash": "4.17.15",
"@tarojs/react": "3.2.13",
"react": "^17.0.0",
"react-dom": "^17.0.0",
"taro-ui": "^3.0.0-alpha.3"
},
"devDependencies": {
"@babel/core": "^7.8.0",
"@tarojs/mini-runner": "3.2.13",
"@tarojs/webpack-runner": "3.2.13",
"@types/webpack-env": "^1.13.6",
"babel-preset-taro": "3.2.13",
"eslint": "^6.8.0",
"eslint-config-taro": "3.2.13",
"stylelint": "9.3.0",
"@typescript-eslint/parser": "^4.15.1",
"@typescript-eslint/eslint-plugin": "^4.15.1",
"typescript": "^4.1.0",
"@types/react": "^17.0.2",
"eslint-plugin-react": "^7.8.2",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-react-hooks": "^4.2.0"
}
}
23 changes: 23 additions & 0 deletions app/project.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"miniprogramRoot": "dist/",
"projectname": "app",
"description": "taro-hooks weapp & h5 demo",
"appid": "wx15171eb44c7567ae",
"setting": {
"urlCheck": true,
"es6": false,
"postcss": false,
"preloadBackgroundData": false,
"minified": false,
"newFeature": true,
"autoAudits": false,
"coverView": true,
"showShadowRootInWxmlPanel": false,
"scopeDataCheck": false,
"useCompilerModule": false
},
"compileType": "miniprogram",
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"condition": {}
}
13 changes: 13 additions & 0 deletions app/project.tt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"miniprogramRoot": "./",
"projectname": "app",
"description": "taro-hooks weapp & h5 demo",
"appid": "touristappid",
"setting": {
"urlCheck": true,
"es6": false,
"postcss": false,
"minified": false
},
"compileType": "miniprogram"
}
9 changes: 9 additions & 0 deletions app/src/app.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default {
pages: ['pages/index/index'],
window: {
backgroundTextStyle: 'light',
navigationBarBackgroundColor: '#fff',
navigationBarTitleText: 'WeChat',
navigationBarTextStyle: 'black',
},
};
Empty file added app/src/app.less
Empty file.
19 changes: 19 additions & 0 deletions app/src/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Component } from 'react';
import './app.less';

class App extends Component {
componentDidMount() {}

componentDidShow() {}

componentDidHide() {}

componentDidCatchError() {}

// this.props.children 是将要会渲染的页面
render() {
return this.props.children;
}
}

export default App;
19 changes: 19 additions & 0 deletions app/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 app/src/pages/index/index.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
navigationBarTitleText: '首页',
};
Empty file added app/src/pages/index/index.less
Empty file.
35 changes: 35 additions & 0 deletions app/src/pages/index/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React, { Component } from 'react';
import { View, Text } from '@tarojs/components';
import { AtButton } from 'taro-ui';

import 'taro-ui/dist/style/components/button.scss'; // 按需引入
import './index.less';

export default class Index extends Component {
componentWillMount() {}

componentDidMount() {}

componentWillUnmount() {}

componentDidShow() {}

componentDidHide() {}

render() {
return (
<View className="index">
<Text>Hello world!</Text>
<AtButton type="primary">I need Taro UI</AtButton>
<Text>Taro UI 支持 Vue 了吗?</Text>
<AtButton type="primary" circle>
支持
</AtButton>
<Text>共建?</Text>
<AtButton type="secondary" circle>
</AtButton>
</View>
);
}
}
5 changes: 3 additions & 2 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"packages": ["packages/*"],
"packages": ["packages/*", "app"],
"command": {
"version": {
"allowBranch": "main",
Expand All @@ -11,5 +11,6 @@
},
"useWorkspaces": true,
"ignoreChanges": ["**/*.md", "**/es/*", "**/lib/*", "**/dist/*"],
"version": "0.0.0"
"version": "0.0.0",
"npmClient": "yarn"
}
Loading

0 comments on commit 035f818

Please sign in to comment.