first commit

This commit is contained in:
liu
2026-07-01 18:50:26 +08:00
commit a9b4d8211c
30 changed files with 12253 additions and 0 deletions
+12
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
View File
@@ -0,0 +1,7 @@
{
"extends": ["taro/react"],
"rules": {
"react/jsx-uses-react": "off",
"react/react-in-jsx-scope": "off"
}
}
+14
View File
@@ -0,0 +1,14 @@
dist/
weapp/
alipay/
kwai/
dd/
qq/
tt/
swan/
deploy_versions/
.swc/
.temp/
.rn_temp/
node_modules/
.DS_Store
+12
View File
@@ -0,0 +1,12 @@
registry "https://registry.npm.taobao.org"
disturl "https://npm.taobao.org/dist"
sass_binary_site "https://npm.taobao.org/mirrors/node-sass/"
sentrycli_cdnurl "https://npm.taobao.org/mirrors/sentry-cli/"
electron_mirror "https://npm.taobao.org/mirrors/electron/"
phantomjs_cdnurl "https://npm.taobao.org/mirrors/phantomjs/"
chromedriver_cdnurl "https://npm.taobao.org/mirrors/chromedriver/"
canvas_binary_host_mirror "https://npm.taobao.org/mirrors/node-canvas-prebuilt/"
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/"
+26
View File
@@ -0,0 +1,26 @@
/* eslint-disable import/no-commonjs */
// babel-preset-taro 更多选项和默认值:
// https://github.com/NervJS/taro/blob/next/packages/babel-preset-taro/README.md
module.exports = {
presets: [
[
'taro',
{
framework: 'react',
ts: true,
useBuiltIns: false,
hot: false,
},
],
],
plugins: [
[
'import',
{
libraryName: '@antmjs/vantui',
libraryDirectory: 'es',
},
'@antmjs/vantui',
],
],
}
+9
View File
@@ -0,0 +1,9 @@
// eslint-disable-next-line import/no-commonjs
module.exports = {
env: {
NODE_ENV: '"development"',
},
defineConstants: {},
mini: {},
h5: {},
}
+138
View File
@@ -0,0 +1,138 @@
/* eslint-disable import/no-commonjs */
/* eslint-disable @typescript-eslint/no-var-requires */
const npath = require("path");
const pkg = require("../package.json");
const miniChain = require("./webpack/miniChain");
const h5Chain = require("./webpack/h5Chain");
process.env.TARO_ENV = process.env.TARO_ENV ?? "weapp"
process.env.NODE_ENV = process.env.NODE_ENV ?? 'production'
process.env.API_ENV = process.env.API_ENV ?? 'real'
const config = {
projectName: pkg.name,
date: "2022-8-10",
designWidth: 750,
deviceRatio: {
640: 2.34 / 2,
750: 1,
828: 1.81 / 2,
},
sourceRoot: "src",
outputRoot: process.env.TARO_ENV === "h5" ? "build" : process.env.TARO_ENV,
alias: {
"@": npath.resolve(process.cwd(), "src"),
},
defineConstants: {},
copy: {
patterns: [],
options: {},
},
framework: "react",
compiler: "webpack5",
cache: {
enable: false, // Webpack 持久化缓存配置,建议开启。默认配置请参考:https://docs.taro.zone/docs/config-detail#cache
},
mini: {
webpackChain(chain) {
miniChain(chain);
},
lessLoaderOption: {
lessOptions: {
modifyVars: {
hack: `true; @import "${npath.join(
process.cwd(),
"src/styles/index.less"
)}";`,
},
},
// 适用于全局引入样式
// additionalData: "@import '~/src/styles/index.less';",
},
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]",
},
},
},
miniCssExtractPluginOption: {
ignoreOrder: true,
},
},
h5: {
webpackChain(chain) {
h5Chain(chain);
if (process.env.NODE_ENV === "production") {
chain.performance.maxEntrypointSize(1000000).maxAssetSize(512000);
}
},
esnextModules: [/@antmjs[\\/]vantui/],
lessLoaderOption: {
lessOptions: {
modifyVars: {
// 或者可以通过 less 文件覆盖(文件路径为绝对路径)
hack: `true; @import "${npath.join(
process.cwd(),
"src/styles/index.less"
)}";`,
},
},
},
router: {
mode: "browser",
},
devServer: {
hot: false,
},
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]",
},
},
},
miniCssExtractPluginOption: {
ignoreOrder: true,
filename: "assets/css/[name].css",
chunkFilename: "assets/css/chunk/[name].css",
},
},
rn: {
appName: "taroDemo",
postcss: {
cssModules: {
enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
},
},
},
plugins: [
["@tarojs/plugin-framework-react", { reactMode: "concurrent" }],
"@tarojs/plugin-platform-alipay-dd",
["@tarojs/plugin-platform-kwai"],
],
};
module.exports = function (merge) {
return merge({}, config, require(`./${process.env.NODE_ENV}`));
};
+36
View File
@@ -0,0 +1,36 @@
// eslint-disable-next-line import/no-commonjs
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') })
// }))
// }
},
}
+23
View File
@@ -0,0 +1,23 @@
module.exports = function (chain) {
// taro内部的配置:scriptRule.exclude = [filename => /css-loader/.test(filename) || (/node_modules/.test(filename) && !(/taro/.test(filename)))];
// 下面重写exclude的配置,部分三方包需要babel,包括taro、@antmjs等
// 根据exclude可以看出,千万不要在项目名称上面带上taro字样,否则所有引用到node_modules的包都会重新被编译一次
// 以下配置将不再使用usage配置,因为根据小程序官方描述,ios9开始基本都已支持了,浏览器可以使用polyfill.io 国内可以用阿里云版的,index.html有引用
/*
* 如果babel.config.js设置useBuiltIns:usage
* /tarojs[\\/](runtime|shared|plugin-platform|components)/.test(filename) 应该被exculde
* /tarojs[\\/](runtime|shared|plugin-platform)/.test(filename) 应该单独babel 且设置useBuiltIns:false
*/
chain.module
.rule('script')
.exclude.clear()
.add(
(filename) =>
/css-loader/.test(filename) ||
(/node_modules/.test(filename) &&
!/(taro)|(inversify)|(@antmjs)|(react-spring)|(recoil)|(buffer)|(qrcode)/.test(
filename,
)),
)
}
+9
View File
@@ -0,0 +1,9 @@
/* eslint-disable import/no-commonjs */
/* eslint-disable @typescript-eslint/no-var-requires */
const H5FixPlugin = require('@antmjs/plugin-h5-fix')
const commonChain = require('./commonChain')
module.exports = function (chain) {
chain.plugin('H5FixPlugin').use(new H5FixPlugin())
commonChain(chain)
}
+16
View File
@@ -0,0 +1,16 @@
/* eslint-disable import/no-commonjs */
/* eslint-disable @typescript-eslint/no-var-requires */
const MiniFixPlugin = require('@antmjs/plugin-mini-fix')
const GlobalFixPlugin = require('@antmjs/plugin-global-fix')
const commonChain = require('./commonChain')
module.exports = function (chain) {
// add @antmjs/plugin-mini-fix and @antmjs/mini-fix
// 解决微信小程序和抖音小程序的path上的params没有自动decode的问题,支付宝和钉钉是有decode过的
// 这个问题是因为微信抖音和支付宝钉钉原生小程序的返回结果就是不一致的,Taro目前是没有去处理的
chain.plugin('MiniFixPlugin').use(new MiniFixPlugin())
//解决支付宝小程序、钉钉小程序、百度小程序没有暴露全局变量global的问题
chain.plugin('GlobalFixPlugin').use(new GlobalFixPlugin())
commonChain(chain)
}
+76
View File
@@ -0,0 +1,76 @@
{
"name": "pure-project-vantui",
"version": "1.0.0",
"private": true,
"description": "",
"templateInfo": {
"name": "default",
"typescript": true,
"css": "less"
},
"scripts": {
"build:weapp": "taro build --type weapp",
"build:h5": "taro build --type h5",
"dev:weapp": "npm run build:weapp -- --watch",
"dev:h5": "npm run build:h5 -- --watch"
},
"browserslist": {
"production": [
"ios >= 9"
],
"development": [
"last 1 version"
]
},
"author": "",
"dependencies": {
"@antmjs/mini-fix": "^2.3.21",
"@antmjs/vantui": "^3.1.6",
"@babel/runtime": "^7.7.7",
"@tarojs/components": "3.6.14",
"@tarojs/helper": "3.6.14",
"@tarojs/plugin-framework-react": "3.6.14",
"@tarojs/plugin-platform-alipay": "3.6.14",
"@tarojs/plugin-platform-alipay-dd": "^0.1.3",
"@tarojs/plugin-platform-h5": "3.6.14",
"@tarojs/plugin-platform-jd": "3.6.14",
"@tarojs/plugin-platform-kwai": "^2.0.0",
"@tarojs/plugin-platform-qq": "3.6.14",
"@tarojs/plugin-platform-swan": "3.6.14",
"@tarojs/plugin-platform-tt": "3.6.14",
"@tarojs/plugin-platform-weapp": "3.6.14",
"@tarojs/react": "3.6.14",
"@tarojs/router": "3.6.14",
"@tarojs/runtime": "3.6.14",
"@tarojs/shared": "3.6.14",
"@tarojs/taro": "3.6.14",
"@tarojs/taro-h5": "3.6.14",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@antmjs/plugin-global-fix": "^2.3.21",
"@antmjs/plugin-h5-fix": "^2.3.21",
"@antmjs/plugin-mini-fix": "^2.3.21",
"@babel/core": "^7.12.9",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.5",
"@tarojs/cli": "3.6.14",
"@tarojs/webpack5-runner": "3.6.14",
"@types/react": "^18.0.26",
"@types/react-dom": "^18.0.10",
"@types/webpack-env": "^1.13.6",
"@typescript-eslint/eslint-plugin": "^5.20.0",
"@typescript-eslint/parser": "^5.20.0",
"babel-plugin-import": "^1.13.5",
"babel-preset-taro": "3.6.14",
"eslint": "^8.12.0",
"eslint-config-taro": "3.6.14",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-react": "^7.8.2",
"eslint-plugin-react-hooks": "^4.2.0",
"react-refresh": "^0.11.0",
"stylelint": "^13.13.1",
"typescript": "^4.1.0",
"webpack": "5.69.0"
}
}
+6
View File
@@ -0,0 +1,6 @@
{
"component2": true,
"enableAppxNg": true,
"enableParallelLoader": false,
"enableHMR": false
}
+14
View File
@@ -0,0 +1,14 @@
{
"miniprogramRoot": "./",
"projectname": "pure-project-vantui",
"description": "",
"appid": "wx7ed74d60503b5ee3",
"setting": {
"urlCheck": true,
"es6": false,
"postcss": false,
"minified": false,
"enhance": false
},
"compileType": "miniprogram"
}
+6
View File
@@ -0,0 +1,6 @@
{
"compileType": "miniprogram",
"miniprogramRoot": "./src",
"component2": true,
"enableAppxNg": true
}
+13
View File
@@ -0,0 +1,13 @@
{
"miniprogramRoot": "./",
"projectname": "pure-project-vantui",
"description": "",
"setting": {
"urlCheck": true,
"es6": false,
"postcss": false,
"minified": false,
"enhance": false
},
"compileType": "miniprogram"
}
+13
View File
@@ -0,0 +1,13 @@
{
"miniprogramRoot": "./",
"projectname": "pure-project-vantui",
"description": "",
"setting": {
"urlCheck": true,
"es6": false,
"postcss": false,
"minified": false,
"enhance": false
},
"compileType": "miniprogram"
}
+18
View File
@@ -0,0 +1,18 @@
{
"projectname": "pure-project-vantui",
"miniprogramRoot": "./",
"compilation-args": {
"common": {
"ignorePrefixCss": true,
"ignoreTransJs": true,
"ignoreUglify": true
}
},
"setting": {
"urlCheck": true,
"es6": false,
"minified": false,
"postcss": false,
"enhance": false
}
}
+10
View File
@@ -0,0 +1,10 @@
{
"miniprogramRoot": "./",
"projectname": "pure-project-vantui",
"setting": {
"urlCheck": true,
"es6": false,
"minified": false,
"postcss": false
}
}
+13
View File
@@ -0,0 +1,13 @@
export default defineAppConfig({
pages: [
'pages/index/index',
],
window: {
backgroundTextStyle: 'light',
navigationBarBackgroundColor: '#fff',
navigationBarTitleText: 'WeChat',
navigationBarTextStyle: 'black'
},
animation: false,
}
)
+44
View File
@@ -0,0 +1,44 @@
@import '@antmjs/vantui/lib/index.less';
page {
background: @pageBack;
font-size: 28px;
font-family: @base-font-family;
color: @black;
}
view,
div {
box-sizing: border-box;
}
::-webkit-scrollbar {
display: none;
}
body,
html {
// NOTE: taro h5 ios上拉遮挡底部fixed元素
overflow: hidden !important;
}
.van-cell-group--inset {
background: @white;
box-shadow: 0 14px 80px 0 rgba(138, 149, 158, 0.2);
}
.van-cell__label {
line-height: 1.4;
}
// 可以用的类
// .van-hairline,
// .van-hairline--top,
// .van-hairline--left,
// .van-hairline--right,
// .van-hairline--bottom,
// .van-hairline--top-bottom,
// .van-hairline--surround
// .van-ellipsis
// .van-multi-ellipsis--l2
// .van-multi-ellipsis--l3
+20
View File
@@ -0,0 +1,20 @@
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
+18
View File
@@ -0,0 +1,18 @@
<!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>antmjs</title>
<script crossorigin="anonymous" src="https://polyfill.alicdn.com/polyfill.min.js?features=es2015%2Ces2016%2Ces2017%2Ces2018%2Ces2019%2Ces2020%2Ces2021%2Ces2022"></script>
<script><%= htmlWebpackPlugin.options.script %></script>
</head>
<body>
<div id="app"></div>
</body>
</html>
+3
View File
@@ -0,0 +1,3 @@
export default definePageConfig({
navigationBarTitleText: '首页'
})
View File
+34
View File
@@ -0,0 +1,34 @@
import { View } from '@tarojs/components'
import { Button } from '@antmjs/vantui'
import './index.less'
export default function Index() {
return (
<View className='index'>
<View><Button type='primary'>Hello world!</Button></View>
<View>src/styles/index.less</View>
</View>
)
}
// export default class Index extends Component {
// componentWillMount () { }
// componentDidMount () { }
// componentWillUnmount () { }
// componentDidShow () { }
// componentDidHide () { }
// render () {
// return (
// <View className='index'>
// <View><Button type='primary'>Hello world!</Button></View>
// <View>上面的按钮的颜色已经通过全局主题重写覆盖了,参见src/style/index.less</View>
// </View>
// )
// }
// }
+73
View File
@@ -0,0 +1,73 @@
@import '@antmjs/vantui/es/style/var.less';
// 这里可以重写主题
@black: #1a1a1a;
@white: #f7f7f7;
@gray-1: #f7f8fa;
@gray-2: #f2f3f5;
@gray-3: #ededed;
@gray-4: #dcdee0;
@gray-5: #c8c9cc;
@gray-6: #969799;
@gray-7: #646566;
@gray-8: #323233;
@red: #ee0a24;
@blue: #1989fa;
@orange: #ff976a;
@orange-dark: #ed6a0c;
@orange-light: #fffbe8;
@green: #0a4d2b;
@pageBack: @gray-3;
@navBack: rgba(237, 237, 237, 0.9);
@popup-background-color: @gray-3;
@backDropFilter: blur(20px);
@popup-close-icon-color: @gray-5;
@popup-close-icon-size: 40px;
@popup-close-icon-margin: 24px;
@button-plain-background-color: @gray-4;
// z-index
@sticky-z-index: 800;
@tabbar-z-index: 805;
@navbar-z-index: 805;
@goods-action-z-index: 806;
@submit-bar-z-index: 806;
@overlay-z-index: 1000;
@dropdown-z-index: 1000;
@popup-z-index: 1010;
@popup-close-icon-z-index: 1010;
@notify-z-index: 1500;
// Padding or Margin
@padding-base: 8px;
@padding-xs: @padding-base * 2;
@padding-sm: @padding-base * 3;
@padding-md: @padding-base * 4;
@padding-lg: @padding-base * 6;
@padding-xl: @padding-base * 8;
// Font
@font-size-xs: 20px;
@font-size-sm: 24px;
@font-size-md: 28px;
@font-size-lg: 32px;
@font-weight-bold: 500;
@line-height-xs: 28px;
@line-height-sm: 36px;
@line-height-md: 40px;
@line-height-lg: 44px;
@base-font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue',
Helvetica, Segoe UI, Arial, Roboto, 'PingFang SC', 'miui', 'Hiragino Sans GB',
'Microsoft Yahei', sans-serif;
@price-integer-font-family: Avenir-Heavy, PingFang SC, Helvetica Neue, Arial,
sans-serif;
// Border
@border-color: @gray-3;
@border-width-base: 2px;
@border-radius-sm: 4px;
@border-radius-md: 8px;
@border-radius-lg: 16px;
@border-radius-max: 999px;
+27
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", "./types"],
"compileOnSave": false
}
+19
View File
@@ -0,0 +1,19 @@
/// <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'
}
}
+11544
View File
File diff suppressed because it is too large Load Diff