Compare commits

...

2 Commits
master ... taro

Author SHA1 Message Date
dev
01c3f9e0d0 fix: 修改多端模板 2022-05-26 17:47:50 +08:00
e3ce650ef8 feat: taro 2022-05-25 12:31:42 +08:00
35 changed files with 471 additions and 32 deletions

12
.editorconfig Normal file
View File

@ -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
.eslintrc Normal file
View File

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

6
.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
dist/
deploy_versions/
.temp/
.rn_temp/
node_modules/
.DS_Store

46
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,46 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"eslint.validate": [
"javascript",
"react",
"typescript",
"typescriptreact",
"vue"
],
"editor.formatOnSave": true,
"[typescriptreact]": {
"editor.defaultFormatter": null
},
"[javascript]": {
"editor.defaultFormatter": null
},
"[typescript]": {
"editor.defaultFormatter": null
},
"[javascriptreact]": {
"editor.defaultFormatter": null
},
"[vue]": {
"editor.defaultFormatter": null
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[less]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[scss]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[css]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[md]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}

View File

@ -1,34 +1,7 @@
## 目前已有脚手架列表
# YOUR_PROJECT_NAME
| 名称 | 说明 | 技术栈 |
| ------- | --------------------------- | --------------------- |
| nextJs | 基于 React 的服务端渲染方案 | nextJs + axios + antd |
| ReactJs | 基于 React 的业务型脚手架 | umiJs + axios + antd |
| TaroJs | 基于 React 的多端适配方案 | TaroJs 全家桶 |
| Vue | 基于 Vue 的业务型脚手架 | vueJs 全家桶 |
| Gulp | 基于 Gulp 的清凉型脚手架 | -- |
## 项目介绍
## 技术栈
## 快速上手
### 1. 安装相关依赖
```js
// 推荐
yarn global add @nicecode/cli
// or
// npm install @nicecode/cli -g
```
### 2. 运行命令
```js
// 查看脚手架版本号,是否安装成功
nice - V
```
### 3. 创建项目
```js
nice create ${项目名称}
```
- Taro
- scss

11
babel.config.js Normal file
View File

@ -0,0 +1,11 @@
// babel-preset-taro 更多选项和默认值:
// https://github.com/NervJS/taro/blob/next/packages/babel-preset-taro/README.md
module.exports = {
presets: [
['taro', {
framework: 'react',
ts: true,
'dynamic-import-node': true
}]
]
}

9
config/dev.js Normal file
View File

@ -0,0 +1,9 @@
module.exports = {
env: {
NODE_ENV: '"development"'
},
defineConstants: {
},
mini: {},
h5: {}
}

75
config/index.js Normal file
View File

@ -0,0 +1,75 @@
const config = {
projectName: 'a',
date: '2022-5-26',
designWidth: 750,
deviceRatio: {
640: 2.34 / 2,
750: 1,
828: 1.81 / 2
},
sourceRoot: 'src',
outputRoot: '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]'
}
}
}
},
copy: process.env.TARO_ENV !== 'h5' ? {} : {
patterns: [
{ from: "public", to: "dist" },
]
},
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'))
}

37
config/prod.js Normal file
View File

@ -0,0 +1,37 @@
module.exports = {
env: {
NODE_ENV: '"production"'
},
defineConstants: {
},
mini: {},
h5: {
/**
* WebpackChain 插件配置
* @docs https://github.com/neutrinojs/webpack-chain
*/
// webpackChain (chain) {
// /**
// * 如果 h5 端编译后体积过大,可以使用 webpack-bundle-analyzer 插件对打包体积进行分析。
// * @docs https://github.com/webpack-contrib/webpack-bundle-analyzer
// */
// chain.plugin('analyzer')
// .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, [])
// /**
// * 如果 h5 端首屏加载时间过长,可以使用 prerender-spa-plugin 插件预加载首页。
// * @docs https://github.com/chrisvfritz/prerender-spa-plugin
// */
// const path = require('path')
// const Prerender = require('prerender-spa-plugin')
// const staticDir = path.join(__dirname, '..', 'dist')
// chain
// .plugin('prerender')
// .use(new Prerender({
// staticDir,
// routes: [ '/pages/index/index' ],
// postProcess: (context) => ({ ...context, outputPath: path.join(staticDir, 'index.html') })
// }))
// }
}
}

18
global.d.ts vendored Normal file
View File

@ -0,0 +1,18 @@
/// <reference types="@tarojs/taro" />
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';
declare namespace NodeJS {
interface ProcessEnv {
TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'quickapp' | 'qq' | 'jd'
}
}

65
package.json Normal file
View File

@ -0,0 +1,65 @@
{
"name": "nicecode-taro-template",
"version": "1.0.0",
"private": true,
"description": "nicecode taro 模板",
"templateInfo": {
"name": "pwa",
"typescript": true,
"css": "stylus"
},
"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": "dev",
"dependencies": {
"@babel/runtime": "^7.7.7",
"@tarojs/components": "3.4.10",
"@tarojs/runtime": "3.4.10",
"@tarojs/taro": "3.4.10",
"@tarojs/plugin-framework-react": "3.4.10",
"@tarojs/react": "3.4.10",
"react-dom": "^17.0.0",
"react": "^17.0.0"
},
"devDependencies": {
"@types/webpack-env": "^1.13.6",
"@types/react": "^17.0.2",
"@tarojs/mini-runner": "3.4.10",
"@babel/core": "^7.8.0",
"@tarojs/webpack-runner": "3.4.10",
"babel-preset-taro": "3.4.10",
"eslint-config-taro": "3.4.10",
"eslint": "^8.12.0",
"eslint-plugin-react": "^7.8.2",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-react-hooks": "^4.2.0",
"offline-plugin": "^5.0.7",
"stylelint": "9.3.0",
"@typescript-eslint/parser": "^5.20.0",
"@typescript-eslint/eslint-plugin": "^5.20.0",
"typescript": "^4.1.0"
}
}

13
project.config.json Normal file
View File

@ -0,0 +1,13 @@
{
"miniprogramRoot": "./dist",
"projectname": "a",
"description": "temp",
"appid": "touristappid",
"setting": {
"urlCheck": true,
"es6": false,
"postcss": false,
"minified": false
},
"compileType": "miniprogram"
}

9
project.tt.json Normal file
View File

@ -0,0 +1,9 @@
{
"miniprogramRoot": "./",
"projectname": "a",
"appid": "testAppId",
"setting": {
"es6": false,
"minified": false
}
}

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 473 B

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 20 KiB

BIN
public/icons/icon_x114.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
public/icons/icon_x144.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
public/icons/icon_x150.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
public/icons/icon_x16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 B

BIN
public/icons/icon_x192.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

BIN
public/icons/icon_x32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 B

BIN
public/icons/icon_x512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
public/icons/icon_x57.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 697 B

BIN
public/icons/icon_x72.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

27
public/manifest.json Normal file
View File

@ -0,0 +1,27 @@
{
"short_name": "a",
"name": "a",
"description": "temp",
"scope": "/",
"start_url": "/?source=pwa",
"display": "standalone",
"background_color": "#0000C2",
"theme_color": "#0000C2",
"icons": [
{
"src": "/icons/icon_vector.svg",
"type": "image/svg+xml",
"sizes": "512x512"
},
{
"src": "/icons/icon_x192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "/icons/icon_x512.png",
"type": "image/png",
"sizes": "512x512"
}
]
}

11
src/app.config.ts Normal file
View File

@ -0,0 +1,11 @@
export default defineAppConfig({
pages: [
'pages/index/index'
],
window: {
backgroundTextStyle: 'light',
navigationBarBackgroundColor: '#fff',
navigationBarTitleText: 'WeChat',
navigationBarTextStyle: 'black'
}
})

0
src/app.styl Normal file
View File

25
src/app.ts Normal file
View File

@ -0,0 +1,25 @@
import { install } from 'offline-plugin/runtime'
import { Component } from 'react'
import './app.styl'
if (process.env.TARO_ENV === 'h5') {
install()
}
class App extends Component {
componentDidMount () {}
componentDidShow () {}
componentDidHide () {}
componentDidCatchError () {}
// this.props.children 是将要会渲染的页面
render () {
return this.props.children
}
}
export default App

View File

@ -0,0 +1 @@
{}

0
src/assets/data/enums.ts Normal file
View File

32
src/index.html Normal file
View File

@ -0,0 +1,32 @@
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" >
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta name="apple-mobile-web-app-title" content="a" />
<meta name="apple-mobile-web-app-status-bar-style" content="white">
<meta name="application-name" content="a" />
<meta name="description" content="temp" />
<meta name="format-detection" content="telephone=no, address=no">
<meta name="theme-color" content="#0000C2" />
<meta name="msapplication-TileColor" content="#0000C2" />
<meta name="msapplication-TileImage" content="./icons/icon_x512.png" />
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" >
<link rel="icon" sizes="16x16" href="./icons/icon_x16.png" type="image/png" />
<link rel="icon" sizes="32x32" href="./icons/icon_x32.png" type="image/png" />
<link rel="apple-touch-icon" sizes="57x57" href="./icons/icon_x57.png" />
<link rel="apple-touch-icon" sizes="72x72" href="./icons/icon_x72.png" />
<link rel="apple-touch-icon" sizes="114x114" href="./icons/icon_x114.png" />
<link rel="apple-touch-icon" sizes="144x144" href="./icons/icon_x144.png" />
<link rel="manifest" href="./manifest.json" />
<title>a</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>

View File

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

View File

24
src/pages/index/index.tsx Normal file
View File

@ -0,0 +1,24 @@
import { Component } from 'react'
import { View, Text } from '@tarojs/components'
import './index.styl'
export default class Index extends Component {
componentWillMount () { }
componentDidMount () { }
componentWillUnmount () { }
componentDidShow () { }
componentDidHide () { }
render () {
return (
<View className='index'>
<Text>Hello world!</Text>
</View>
)
}
}

27
tsconfig.json Normal file
View File

@ -0,0 +1,27 @@
{
"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-jsx",
"allowJs": true,
"resolveJsonModule": true,
"typeRoots": [
"node_modules/@types"
]
},
"include": ["./src", "global.d.ts"],
"compileOnSave": false
}