Commit f114c4e7 authored by ChrisZhao 赵思思's avatar ChrisZhao 赵思思

Init Commit

parent ef007ebb
config
*.config.js
ios
android
\ No newline at end of file
{
"extends": ["taro/react"],
"rules": {
"semi": ["error", "always"],
"no-undef": 0,
"import/first": 0,
"space-infix-ops": 1,
"array-bracket-spacing": 0,
"object-curly-spacing": ["error","always"],
"spaced-comment": 2,
"no-unused-vars": 0,
"react/no-unused-state": 0,
"react/sort-comp": 0,
"react/self-closing-comp": 1,
"react/no-multi-comp": 0,
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx", ".tsx"] }],
"@typescript-eslint/no-unused-vars": [1, { "varsIgnorePattern": "React" }],
"@typescript-eslint/no-undef": 0,
"@typescript-eslint/explicit-function-return-type": 0,
"@typescript-eslint/no-empty-function": 0,
"@typescript-eslint/no-explicit-any": 0,
"jsx-quotes": [
"error",
"prefer-double"
],
"import/prefer-default-export": 0,
"@typescript-eslint/camelcase": 0,
"@typescript-eslint/ban-ts-ignore": 0,
"@typescript-eslint/no-inferrable-types": 0,
"@typescript-eslint/no-shadow": 0
}
}
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/
...@@ -4,6 +4,9 @@ module.exports = { ...@@ -4,6 +4,9 @@ module.exports = {
}, },
defineConstants: { defineConstants: {
}, },
isWatch: true,
mini: {}, mini: {},
h5: {} h5: {
esnextModules: ['taro-ui']
}
} }
const path = require("path");
const config = { const config = {
projectName: 'taro-multi', projectName: "LogwireMobile",
date: '2024-3-14', date: "2020-11-7",
designWidth: 750, designWidth: 750,
deviceRatio: { deviceRatio: {
640: 2.34 / 2, 640: 2.34 / 2,
750: 1, 750: 1,
828: 1.81 / 2 828: 1.81 / 2
}, },
sourceRoot: 'src', compiler: {
outputRoot: 'dist', type: 'webpack5',
prebundle: {
enable: false,
},
},
sourceRoot: "src",
outputRoot: `dist/${process.env.TARO_ENV}`,
plugins: [], plugins: [],
defineConstants: { defineConstants: {
IS_H5: process.env.TARO_ENV === "h5",
IS_RN: process.env.TARO_ENV === "rn",
IS_WEAPP: process.env.TARO_ENV === "weapp"
}, },
copy: { alias: {
patterns: [ "@src": path.resolve(__dirname, "..", "src"),
], "@components": path.resolve(__dirname, "..", "src/components"),
options: { "@scss": path.resolve(__dirname, "..", "src/scss"),
} "@utils": path.resolve(__dirname, "..", "src/utils"),
"@service": path.resolve(__dirname, "..", "src/service")
}, },
framework: 'react', copy: {
compiler: 'webpack5', patterns: [],
cache: { options: {}
enable: false // Webpack 持久化缓存配置,建议开启。默认配置请参考:https://docs.taro.zone/docs/config-detail#cache
},
rn: {
output: {
ios: '../bundles/ios/index.jsbundle',
android: '../bundles/android/index.android.bundle'
},
}, },
framework: "react",
mini: { mini: {
postcss: { postcss: {
pxtransform: { pxtransform: {
enable: true, enable: true,
config: { config: {}
}
}, },
url: { url: {
enable: true, enable: true,
...@@ -46,35 +49,26 @@ const config = { ...@@ -46,35 +49,26 @@ const config = {
cssModules: { cssModules: {
enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
config: { config: {
namingPattern: 'module', // 转换模式,取值为 global/module namingPattern: "module", // 转换模式,取值为 global/module
generateScopedName: '[name]__[local]___[hash:base64:5]' generateScopedName: "[name]__[local]___[hash:base64:5]"
} }
} }
} }
}, },
h5: { rn: {
publicPath: '/', appName: 'LogwireNativeApp',
staticDirectory: 'static', output: {
postcss: { ios: 'ios/main.jsbundle',
autoprefixer: { iosAssetsDest: 'ios',
enable: true, android: 'android/index.android.bundle',
config: { androidAssetsDest: 'android'
} },
},
cssModules: {
enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
config: {
namingPattern: 'module', // 转换模式,取值为 global/module
generateScopedName: '[name]__[local]___[hash:base64:5]'
}
}
}
} }
} };
module.exports = function (merge) { module.exports = function(merge) {
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === "development") {
return merge({}, config, require('./dev')) return merge({}, config, require("./dev"));
} }
return merge({}, config, require('./prod')) return merge({}, config, require("./prod"));
} };
module.exports = {
env: {
NODE_ENV: '"production"'
},
defineConstants: {
},
mini: {},
h5: {
/**
* 如果h5端编译后体积过大,可以使用webpack-bundle-analyzer插件对打包体积进行分析。
* 参考代码如下:
* webpackChain (chain) {
* chain.plugin('analyzer')
* .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, [])
* }
*/
}
}
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') })
// }))
// }
}
}
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 module "*.mp4";
declare namespace NodeJS {
interface ProcessEnv {
TARO_ENV:
| "weapp"
| "swan"
| "alipay"
| "h5"
| "rn"
| "tt"
| "quickapp"
| "qq"
| "jd";
}
interface Global {
globalData: object;
}
}
declare const IS_H5: any;
declare const IS_WEAPP: any;
declare const IS_RN: any;
import '@tarojs/rn-supporter/entry-file.js'
\ No newline at end of file
const { mergeConfig } = require('metro-config') module.exports = {
const { getMetroConfig } = require('@tarojs/rn-supporter') server: {
rewriteRequestUrl: (url) => {
module.exports = (async function (){ if (!url.endsWith('.bundle')) {
return mergeConfig({ return url;
// custom your metro config here }
// https://facebook.github.io/metro/docs/configuration // https://github.com/facebook/react-native/issues/36794
resolver: {} // JavaScriptCore strips query strings, so try to re-add them with a best guess.
}, await getMetroConfig()) return url + '?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true';
})() }, // ...
\ No newline at end of file }, // ...
}
This diff is collapsed.
{ {
"name": "taro-multi", "name": "LogwireMobile",
"version": "1.0.0", "version": "1.0.0",
"private": true, "private": true,
"description": "y", "description": "Logwire 移动端代码,包括 APP、小程序",
"templateInfo": { "templateInfo": {
"name": "mobx", "name": "default",
"typescript": true, "typescript": true,
"css": "sass" "css": "sass"
}, },
...@@ -15,74 +15,73 @@ ...@@ -15,74 +15,73 @@
"build:tt": "taro build --type tt", "build:tt": "taro build --type tt",
"build:h5": "taro build --type h5", "build:h5": "taro build --type h5",
"build:rn": "taro build --type rn", "build:rn": "taro build --type rn",
"build:rn-ios": "taro build --type rn --platform ios",
"build:rn-android": "taro build --type rn --platform android",
"build:qq": "taro build --type qq", "build:qq": "taro build --type qq",
"build:jd": "taro build --type jd",
"build:quickapp": "taro build --type quickapp", "build:quickapp": "taro build --type quickapp",
"dev:weapp": "npm run build:weapp -- --watch", "dev:weapp": "npm run build:weapp -- --watch",
"dev:swan": "npm run build:swan -- --watch", "dev:swan": "npm run build:swan -- --watch",
"dev:alipay": "npm run build:alipay -- --watch", "dev:alipay": "npm run build:alipay -- --watch",
"dev:tt": "npm run build:tt -- --watch", "dev:tt": "npm run build:tt -- --watch",
"dev:h5": "npm run build:h5 -- --watch", "dev:h5": "npm run build:h5 -- --watch",
"dev:rn": "npm run build:rn -- --watch", "dev:rn": "npm run build:rn -- --watch --qr",
"dev:qq": "npm run build:qq -- --watch", "dev:qq": "npm run build:qq -- --watch",
"dev:quickapp": "npm run build:quickapp -- --watch" "dev:jd": "npm run build:jd -- --watch",
"dev:quickapp": "npm run build:quickapp -- --watch",
"publish:pages": "yarn build:h5 && yarn gh-pages -d dist/h5 -t"
}, },
"browserslist": [ "browserslist": [
"last 3 versions", "last 3 versions",
"Android >= 4.1", "Android >= 4.1",
"ios >= 8" "ios >= 8"
], ],
"author": "", "author": "qiuz",
"license": "MIT", "lint-staged": {
"*.{js,jsx,ts,tsx}": [
"eslint --fix"
]
},
"dependencies": { "dependencies": {
"@babel/runtime": "^7.7.7", "@babel/runtime": "^7.7.7",
"@tarojs/components": "3.6.16", "@codler/react-native-keyboard-aware-scroll-view": "^2.0.0",
"@tarojs/components-rn": "^3.6.24", "@pmmmwh/react-refresh-webpack-plugin": "^0.5.7",
"@tarojs/helper": "3.6.16", "@tarojs/cli": "^3.5.7",
"@tarojs/plugin-framework-react": "3.6.16", "@tarojs/components": "^3.5.7",
"@tarojs/plugin-platform-alipay": "3.6.16", "@tarojs/plugin-framework-react": "^3.5.7",
"@tarojs/plugin-platform-h5": "3.6.16", "@tarojs/react": "^3.5.7",
"@tarojs/plugin-platform-jd": "3.6.16", "@tarojs/rn-runner": "^3.5.7",
"@tarojs/plugin-platform-qq": "3.6.16", "@tarojs/runtime": "^3.5.7",
"@tarojs/plugin-platform-swan": "3.6.16", "@tarojs/taro": "^3.5.7",
"@tarojs/plugin-platform-tt": "3.6.16", "@tarojs/taro-rn": "^3.5.7",
"@tarojs/plugin-platform-weapp": "3.6.16", "lodash": "4.17.21",
"@tarojs/react": "3.6.16", "react": "^17.0.2",
"@tarojs/rn-runner": "^3.6.24", "react-dom": "^17.0.2",
"@tarojs/rn-supporter": "^3.6.24", "react-native": "^0.68.2",
"@tarojs/runtime": "3.6.16", "react-refresh": "^0.14.0",
"@tarojs/runtime-rn": "^3.6.24", "webpack": "5.69.0",
"@tarojs/shared": "3.6.16", "taro-ui": "^3.0.0-alpha.3"
"@tarojs/taro": "3.6.16",
"@tarojs/taro-rn": "^3.6.24",
"expo": "~47.0.3",
"mobx": "5.0.5",
"mobx-react": "6.1.4",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-native": "0.72.0"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.8.0", "@babel/core": "^7.8.0",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.5", "@commitlint/cli": "^11.0.0",
"@tarojs/cli": "3.6.16", "@commitlint/config-conventional": "^11.0.0",
"@tarojs/taro-loader": "3.6.16", "@tarojs/webpack5-runner": "^3.5.7",
"@tarojs/webpack5-runner": "3.6.16", "@types/react": "^17.0.2",
"@types/node": "^18.15.11",
"@types/react": "^18.0.0",
"@types/webpack-env": "^1.13.6", "@types/webpack-env": "^1.13.6",
"@typescript-eslint/eslint-plugin": "^5.20.0", "@typescript-eslint/eslint-plugin": "^2.x",
"@typescript-eslint/parser": "^5.20.0", "@typescript-eslint/parser": "^2.x",
"babel-preset-taro": "3.6.16", "babel-preset-taro": "^3.5.7",
"eslint": "^8.12.0", "eslint": "^6.8.0",
"eslint-config-taro": "3.6.16", "eslint-config-taro": "^3.5.7",
"eslint-plugin-import": "^2.12.0", "eslint-plugin-import": "^2.12.0",
"eslint-plugin-react": "^7.8.2", "eslint-plugin-react": "^7.8.2",
"eslint-plugin-react-hooks": "^4.2.0", "eslint-plugin-react-hooks": "^4.2.0",
"postcss": "^8.4.18", "gh-pages": "^3.1.0",
"react-refresh": "^0.11.0", "husky": "^4.3.5",
"lint-staged": "^10.5.3",
"react-native-linear-gradient": "^2.5.6",
"stylelint": "9.3.0", "stylelint": "9.3.0",
"ts-node": "^10.9.1", "typescript": "^4.1.0"
"typescript": "^4.1.0",
"webpack": "^5.78.0"
} }
} }
{ {
"miniprogramRoot": "./dist", "miniprogramRoot": ".dist",
"projectname": "taro-multi", "projectname": "Logwire Mobile",
"description": "y", "description": "",
"appid": "touristappid", "appid": "wxb604d548939868ce",
"setting": { "setting": {
"urlCheck": true, "urlCheck": true,
"es6": false, "es6": false,
"enhance": false, "postcss": false,
"compileHotReLoad": false, "preloadBackgroundData": false,
"postcss": false, "minified": false,
"minified": false "newFeature": true,
}, "autoAudits": false,
"compileType": "miniprogram" "coverView": true,
"showShadowRootInWxmlPanel": false,
"scopeDataCheck": false,
"useCompilerModule": false
},
"compileType": "miniprogram",
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"condition": {}
} }
{
"miniprogramRoot": "./",
"projectname": "taro-multi",
"description": "y",
"appid": "touristappid",
"setting": {
"urlCheck": true,
"es6": false,
"postcss": false,
"minified": false
},
"compileType": "miniprogram"
}
export default defineAppConfig({ export default {
pages: [ pages: [
'pages/index/index' "pages/index",
], ],
window: { window: {
backgroundTextStyle: 'light', backgroundTextStyle: "light",
navigationBarBackgroundColor: '#fff', navigationBarBackgroundColor: "#fff",
navigationBarTitleText: 'WeChat', navigationBarTitleText: "WeChat",
navigationBarTextStyle: 'black' navigationBarTextStyle: "black"
},
rn: {
screenOptions: {
// 设置页面的options,参考https://reactnavigation.org/docs/stack-navigator/#options
shadowOffset: { width: 0, height: 0 },
borderWidth: 0,
elevation: 0,
shadowOpacity: 1,
borderBottomWidth: 0
}
} }
}) };
@import "~taro-ui/dist/style/index.scss";
/* #ifdef h5 */
* {
box-sizing: border-box;
}
taro-view-core,
taro-text-core,
div {
font-size: 32px;
}
/* #endif */
/* #ifdef weapp */
view,
text {
box-sizing: border-box;
}
/* #endif */
import { Component } from "react";
import "./app.scss";
class App extends Component {
componentDidMount() {}
componentDidShow() {}
componentDidHide() {}
componentDidCatchError() {}
// this.props.children 是将要会渲染的页面
render() {
return this.props.children;
}
}
export default App;
import { Component, PropsWithChildren } from 'react'
import { Provider } from 'mobx-react'
import counterStore from './store/counter'
import './app.scss'
const store = {
counterStore
}
class App extends Component<PropsWithChildren> {
componentDidMount () {}
componentDidShow () {}
componentDidHide () {}
// this.props.children 就是要渲染的页面
render () {
return (
<Provider store={store}>
{this.props.children}
</Provider>
)
}
}
export default App
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<meta name="format-detection" content="telephone=no,address=no"> <meta name="format-detection" content="telephone=no,address=no">
<meta name="apple-mobile-web-app-status-bar-style" content="white"> <meta name="apple-mobile-web-app-status-bar-style" content="white">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" > <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" >
<title>taro-multi</title> <title>Logwire Mobile</title>
<script><%= htmlWebpackPlugin.options.script %></script> <script><%= htmlWebpackPlugin.options.script %></script>
</head> </head>
<body> <body>
......
import { View, Text } from '@tarojs/components'
import { useLoad } from '@tarojs/taro'
import './index.scss'
export default function Index() {
useLoad(() => {
console.log('Page loaded.')
})
return (
<View className='index'>
<Text>Hello world!</Text>
</View>
)
}
import { Component, PropsWithChildren } from 'react'
import { View, Button, Text } from '@tarojs/components'
import { observer, inject } from 'mobx-react'
import './index.scss'
type PageStateProps = {
store: {
counterStore: {
counter: number,
increment: Function,
decrement: Function,
incrementAsync: Function
}
}
}
interface Index {
props: PageStateProps;
}
@inject('store')
@observer
class Index extends Component<PropsWithChildren> {
componentDidMount () { }
componentWillUnmount () { }
componentDidShow () { }
componentDidHide () { }
increment = () => {
const { counterStore } = this.props.store
counterStore.increment()
}
decrement = () => {
const { counterStore } = this.props.store
counterStore.decrement()
}
incrementAsync = () => {
const { counterStore } = this.props.store
counterStore.incrementAsync()
}
render () {
const { counterStore: { counter } } = this.props.store
return (
<View className='index'>
<Button onClick={this.increment}>+</Button>
<Button onClick={this.decrement}>-</Button>
<Button onClick={this.incrementAsync}>Add Async</Button>
<Text>{counter}</Text>
</View>
)
}
}
export default Index
import { observable } from 'mobx'
const counterStore = observable({
counter: 0,
counterStore() {
this.counter++
},
increment() {
this.counter++
},
decrement() {
this.counter--
},
incrementAsync() {
setTimeout(() => {
this.counter++
}, 1000)
}
})
export default counterStore
\ No newline at end of file
...@@ -15,13 +15,38 @@ ...@@ -15,13 +15,38 @@
"sourceMap": true, "sourceMap": true,
"baseUrl": ".", "baseUrl": ".",
"rootDir": ".", "rootDir": ".",
"jsx": "react-jsx", "jsx": "react",
"jsxFactory": "React.createElement",
"allowJs": true, "allowJs": true,
"resolveJsonModule": true, "resolveJsonModule": true,
"typeRoots": [ "typeRoots": [
"node_modules/@types" "node_modules/@types",
] "global.d.ts"
],
"paths": {
"@components": [
"src/components/"
],
"@components/*": [
"src/components/*"
],
"@utils": [
"src/utils"
],
"@utils/*": [
"src/utils/*"
],
"@service": [
"src/service"
],
"@service/*": [
"src/service/*"
],
},
}, },
"include": ["./src", "./types"], "exclude": [
"node_modules",
"dist"
],
"compileOnSave": false "compileOnSave": false
} }
/// <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 JSX {
interface IntrinsicElements {
'import': React.DetailedHTMLProps<React.EmbedHTMLAttributes<HTMLEmbedElement>, HTMLEmbedElement>
}
}
declare namespace NodeJS {
interface ProcessEnv {
TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'quickapp' | 'qq' | 'jd'
}
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment