Browse Source

feat: 初始化项目

xyh 2 years ago
commit
4e687c8d20

+ 8 - 0
.eslintignore

@@ -0,0 +1,8 @@
+node_modules
+build
+public
+*/reportWebVitals.ts
+*.d.ts
+coverage/
+dist/
+coverage

+ 9 - 0
.eslintrc.js

@@ -0,0 +1,9 @@
+module.exports = {
+  extends: ['proste/reactJS.js', 'prettier'],
+  root: true,
+  globals: {
+    definePageConfig: 'readonly',
+    defineAppConfig: 'readonly',
+    TaroGeneral: 'readonly',
+  },
+};

+ 7 - 0
.gitignore

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

+ 4 - 0
.husky/commit-msg

@@ -0,0 +1,4 @@
+#!/usr/bin/env sh
+. "$(dirname -- "$0")/_/husky.sh"
+
+npx --no-install commitlint --edit 

+ 4 - 0
.husky/pre-commit

@@ -0,0 +1,4 @@
+#!/usr/bin/env sh
+. "$(dirname -- "$0")/_/husky.sh"
+
+pnpm pre-commit

+ 4 - 0
.husky/pre-rebase

@@ -0,0 +1,4 @@
+#!/usr/bin/env sh
+. "$(dirname -- "$0")/_/husky.sh"
+
+pnpm pre-commit

+ 31 - 0
.prettierignore

@@ -0,0 +1,31 @@
+**/*.png
+**/*.svg
+*.yaml
+CODEOWNERS
+.dockerignore
+Dockerfile.ui-test
+AUTHORS.txt
+lib/
+es/
+dist/
+build/
+public/
+coverage/
+CNAME
+LICENSE
+yarn.lock
+netlify.toml
+yarn-error.log
+.DS_Store
+.editorconfig
+.eslintignore
+.history
+.bablerc
+.eslintrc.json
+**/*.yml
+**/.gitkeep
+.stylelintignore
+.temp-cache/
+analyzer/
+node_modules/
+pnpm-lock.yaml

+ 16 - 0
.prettierrc.json

@@ -0,0 +1,16 @@
+{
+  "printWidth": 80,
+  "tabWidth": 2,
+  "useTabs": false,
+  "semi": true,
+  "singleQuote": true,
+  "quoteProps": "as-needed",
+  "jsxSingleQuote": true,
+  "trailingComma": "all",
+  "bracketSpacing": false,
+  "bracketSameLine": false,
+  "arrowParens": "avoid",
+  "proseWrap": "always",
+  "htmlWhitespaceSensitivity": "css",
+  "endOfLine": "lf"
+}

+ 10 - 0
.stylelintignore

@@ -0,0 +1,10 @@
+/build
+*.js
+*.jsx
+*.tsx
+*.ts
+*.html
+*.json
+*.md
+/node_modules
+**/assets/*

+ 32 - 0
.stylelintrc.json

@@ -0,0 +1,32 @@
+{
+  "extends": [
+    "stylelint-config-standard",
+    "stylelint-config-recess-order"
+  ],
+  "rules": {
+    "font-family-name-quotes": null,
+    "font-family-no-missing-generic-family-keyword": null,
+    "max-nesting-depth": [
+      2,
+      {
+        "ignore": [
+          "blockless-at-rules",
+          "pseudo-classes"
+        ]
+      }
+    ],
+    "declaration-block-no-duplicate-properties": true,
+    "no-duplicate-selectors": true,
+    "no-descending-specificity": null,
+    "selector-class-pattern": "^([a-z][a-z0-9]*)((-|__)[a-z0-9]+)*$",
+    "selector-pseudo-class-no-unknown": [
+      true,
+      {
+        "ignorePseudoClasses": [
+          "global",
+          "local"
+        ]
+      }
+    ]
+  }
+}

+ 22 - 0
babel.config.js

@@ -0,0 +1,22 @@
+// babel-preset-taro 更多选项和默认值:
+// https://github.com/NervJS/taro/blob/next/packages/babel-preset-taro/README.md
+module.exports = {
+  presets: [
+    ['taro', {
+      framework: 'react',
+      ts: false
+    }]
+  ],
+  plugins: [
+    [
+      "import",
+      {
+        "libraryName": "@nutui/nutui-react-taro",
+        "libraryDirectory": "dist/esm",
+        "style": true,
+        "camel2DashComponentName": false
+      },
+      'nutui-react-taro'
+    ]
+  ]
+}

+ 28 - 0
commitlint.config.js

@@ -0,0 +1,28 @@
+module.exports = {
+  extends: ['@commitlint/config-conventional'],
+  rules: {
+    'type-enum': [
+      2,
+      'always',
+      [
+        'feat',
+        'fix',
+        'style',
+        'refactor',
+        'perf',
+        'test',
+        'chore',
+        'revert',
+        'update',
+        'merge',
+      ],
+    ],
+    'type-case': [0],
+    'type-empty': [0],
+    'scope-empty': [0],
+    'scope-case': [0],
+    'subject-full-stop': [0, 'never'],
+    'subject-case': [0, 'never'],
+    'header-max-length': [0, 'always', 72],
+  },
+};

+ 8 - 0
config/dev.js

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

+ 115 - 0
config/index.js

@@ -0,0 +1,115 @@
+import {UnifiedWebpackPluginV5} from 'weapp-tailwindcss-webpack-plugin';
+import {resolve} from 'path';
+
+const config = {
+  projectName: 'shougang-wms-mini',
+  date: '2023-4-17',
+  designWidth: 375,
+  deviceRatio: {
+    640: 2.34 / 2,
+    750: 1,
+    828: 1.81 / 2,
+    375: 2 / 1,
+  },
+  sourceRoot: 'src',
+  outputRoot: 'dist',
+  plugins: ['@tarojs/plugin-html'],
+  defineConstants: {},
+  copy: {
+    patterns: [],
+    options: {},
+  },
+  framework: 'react',
+  compiler: 'webpack5',
+  cache: {
+    enable: true, // Webpack 持久化缓存配置,建议开启。默认配置请参考:https://docs.taro.zone/docs/config-detail#cache
+  },
+  alias: {
+    '@styles': resolve(__dirname, '..', 'src/styles'),
+    '@assets': resolve(__dirname, '..', 'src/assets'),
+    '@routes': resolve(__dirname, '..', 'src/routes'),
+    '@apis': resolve(__dirname, '..', 'src/apis'),
+    '@components': resolve(__dirname, '..', 'src/components'),
+    '@hooks': resolve(__dirname, '..', 'src/hooks'),
+    '@pages': resolve(__dirname, '..', 'src/pages'),
+    '@stores': resolve(__dirname, '..', 'src/stores'),
+    '@utils': resolve(__dirname, '..', 'src/utils'),
+    '@models': resolve(__dirname, '..', 'src/models'),
+  },
+  sass: {
+    data: `@import "@nutui/nutui-react-taro/dist/styles/variables.scss";`,
+  },
+  mini: {
+    hot: true,
+    optimizeMainPackage: {
+      enable: true,
+    },
+    webpackChain(chain) {
+      chain.merge({
+        plugin: {
+          install: {
+            plugin: UnifiedWebpackPluginV5,
+            args: [
+              {
+                appType: 'taro',
+              },
+              'taro',
+            ],
+          },
+        },
+      });
+    },
+    postcss: {
+      pxtransform: {
+        enable: false,
+        config: {
+          selectorBlackList: ['nut-'],
+        },
+      },
+      url: {
+        enable: true,
+        config: {
+          limit: 1024, // 设定转换尺寸上限
+        },
+      },
+      cssModules: {
+        enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
+        config: {
+          namingPattern: 'module', // 转换模式,取值为 global/module
+          generateScopedName: '[local]-[hash:base64:5]',
+        },
+      },
+    },
+  },
+  h5: {
+    publicPath: '/',
+    staticDirectory: 'static',
+    // esnextModules: ['nutui-react'],
+    postcss: {
+      pxtransform: {
+        enable: true,
+        config: {
+          selectorBlackList: ['nut-'],
+        },
+      },
+      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'));
+};

+ 35 - 0
config/prod.js

@@ -0,0 +1,35 @@
+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') })
+    //     }))
+    // }
+  },
+};

+ 40 - 0
jsconfig.json

@@ -0,0 +1,40 @@
+{
+  "compilerOptions": {
+    "baseUrl": "./src",
+    "paths": {
+      "@styles/*": [
+        "./styles/*"
+      ],
+      "@assets/*": [
+        "./assets/*"
+      ],
+      "@routes": [
+        "./routes/index"
+      ],
+      "@apis": [
+        "./apis/index"
+      ],
+      "@components": [
+        "./components/index"
+      ],
+      "@hooks": [
+        "./hooks/index"
+      ],
+      "@pages": [
+        "./pages/index"
+      ],
+      "@pages/*": [
+        "./pages/*"
+      ],
+      "@stores": [
+        "./stores/index"
+      ],
+      "@models": [
+        "./models/index"
+      ],
+      "@utils": [
+        "./utils/index"
+      ],
+    }
+  }
+}

+ 153 - 0
package.json

@@ -0,0 +1,153 @@
+{
+  "name": "shougang-wms-mini",
+  "version": "1.0.0",
+  "private": true,
+  "description": "首钢收发货小程序",
+  "templateInfo": {
+    "name": "react-NutUI",
+    "typescript": false,
+    "css": "none"
+  },
+  "scripts": {
+    "build": "taro build --type weapp",
+    "dev": "taro build --type weapp --watch",
+    "lint:style": "stylelint src *.*.css",
+    "lint:js": "eslint . --ext .js,.jsx,.ts,.tsx",
+    "lint:style-fix": "pnpm run lint:style --fix",
+    "lint:js-fix": "pnpm run lint:script --fix",
+    "prettier": "prettier -c --write **/*",
+    "prepare": "husky install",
+    "postinstall": "husky install weapp-tw patch",
+    "pre-commit": "lint-staged",
+    "commit": "cz"
+  },
+  "config": {
+    "commitizen": {
+      "path": "./node_modules/cz-conventional-changelog",
+      "types": {
+        "feat": {
+          "description": "A new feature",
+          "title": "Features"
+        },
+        "fix": {
+          "description": "A bug fix",
+          "title": "Bug Fixes"
+        },
+        "update": {
+          "description": "Modify src files",
+          "title": "Updates"
+        },
+        "chore": {
+          "description": "Other changes that don't modify src or test files",
+          "title": "Chores"
+        },
+        "test": {
+          "description": "Adding missing tests or correcting existing tests",
+          "title": "Tests"
+        },
+        "style": {
+          "description": "Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)",
+          "title": "Styles"
+        },
+        "refactor": {
+          "description": "A code change that neither fixes a bug nor adds a feature",
+          "title": "Code Refactoring"
+        },
+        "perf": {
+          "description": "A code change that improves performance",
+          "title": "Performance Improvements"
+        },
+        "revert": {
+          "description": "Reverts a previous commit",
+          "title": "Reverts"
+        },
+        "merge": {
+          "description": "Merge branch",
+          "title": "Merges"
+        }
+      }
+    }
+  },
+  "lint-staged": {
+    "**/*/*.css": [
+      "stylelint",
+      "prettier --write"
+    ],
+    "**/*/*.{js,jsx,ts,tsx}": [
+      "eslint",
+      "prettier --write"
+    ]
+  },
+  "browserslist": [
+    "last 3 versions",
+    "Android >= 4.1",
+    "ios >= 8"
+  ],
+  "author": "",
+  "license": "MIT",
+  "dependencies": {
+    "@babel/runtime": "^7.21.0",
+    "@nutui/nutui-react-taro": "^1.5.0",
+    "@tanstack/react-query": "^4.29.3",
+    "@tarojs/components": "3.6.5",
+    "@tarojs/helper": "3.6.5",
+    "@tarojs/plugin-framework-react": "3.6.5",
+    "@tarojs/plugin-html": "3.6.5",
+    "@tarojs/plugin-platform-alipay": "3.6.5",
+    "@tarojs/plugin-platform-h5": "3.6.5",
+    "@tarojs/plugin-platform-jd": "3.6.5",
+    "@tarojs/plugin-platform-qq": "3.6.5",
+    "@tarojs/plugin-platform-swan": "3.6.5",
+    "@tarojs/plugin-platform-tt": "3.6.5",
+    "@tarojs/plugin-platform-weapp": "3.6.5",
+    "@tarojs/react": "3.6.5",
+    "@tarojs/runtime": "3.6.5",
+    "@tarojs/shared": "3.6.5",
+    "@tarojs/taro": "3.6.5",
+    "ahooks": "^3.7.6",
+    "react": "^18.2.0",
+    "react-dom": "^18.2.0",
+    "react-error-boundary": "^4.0.3",
+    "react-refresh": "^0.11.0",
+    "tailwindcss": "^3.3.1",
+    "zustand": "^4.3.7"
+  },
+  "devDependencies": {
+    "@babel/core": "^7.21.4",
+    "@commitlint/cli": "^17.6.1",
+    "@commitlint/config-conventional": "^17.6.1",
+    "@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
+    "@tarojs/cli": "3.6.5",
+    "@tarojs/webpack5-runner": "3.6.5",
+    "@types/react": "^18.0.35",
+    "@types/react-dom": "^18.0.11",
+    "@types/react-router-dom": "^5.3.3",
+    "@types/react-syntax-highlighter": "^13.5.2",
+    "@types/react-test-renderer": "^18.0.0",
+    "@types/react-transition-group": "^4.4.5",
+    "@types/webpack-env": "^1.18.0",
+    "@typescript-eslint/eslint-plugin": "^5.58.0",
+    "@typescript-eslint/parser": "^5.58.0",
+    "autoprefixer": "^10.4.14",
+    "babel-plugin-import": "^1.13.6",
+    "babel-preset-taro": "3.6.5",
+    "cz-conventional-changelog": "^3.3.0",
+    "eslint": "^8.38.0",
+    "eslint-config-prettier": "^8.8.0",
+    "eslint-config-proste": "^5.1.0",
+    "eslint-plugin-import": "^2.27.5",
+    "eslint-plugin-react": "^7.32.2",
+    "eslint-plugin-react-hooks": "^4.6.0",
+    "husky": "^8.0.3",
+    "lint-staged": "^13.2.1",
+    "postcss": "^8.4.22",
+    "postcss-nesting": "^11.2.2",
+    "prettier": "^2.8.7",
+    "style-loader": "1.3.0",
+    "stylelint": "^15.5.0",
+    "stylelint-config-recess-order": "^4.0.0",
+    "stylelint-config-standard": "^33.0.0",
+    "weapp-tailwindcss-webpack-plugin": "^2.1.1",
+    "webpack": "^5.79.0"
+  }
+}

File diff suppressed because it is too large
+ 12430 - 0
pnpm-lock.yaml


+ 7 - 0
postcss.config.js

@@ -0,0 +1,7 @@
+module.exports = {
+  plugins: {
+    tailwindcss: {},
+    autoprefixer: {},
+    'postcss-nesting': {},
+  },
+};

+ 31 - 0
project.config.json

@@ -0,0 +1,31 @@
+{
+  "miniprogramRoot": "dist/",
+  "projectname": "shougang-wms-mini",
+  "description": "首钢收发货小程序",
+  "appid": "wxbbc727cd608c4336",
+  "setting": {
+    "urlCheck": true,
+    "es6": false,
+    "enhance": false,
+    "compileHotReLoad": false,
+    "postcss": false,
+    "minified": false,
+    "babelSetting": {
+      "ignore": [],
+      "disablePlugins": [],
+      "outputPath": ""
+    }
+  },
+  "compileType": "miniprogram",
+  "libVersion": "2.31.0",
+  "srcMiniprogramRoot": "dist/",
+  "packOptions": {
+    "ignore": [],
+    "include": []
+  },
+  "condition": {},
+  "editorSetting": {
+    "tabIndent": "insertSpaces",
+    "tabSize": 2
+  }
+}

+ 7 - 0
project.private.config.json

@@ -0,0 +1,7 @@
+{
+  "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
+  "projectname": "shougang-wms-mini",
+  "setting": {
+    "compileHotReLoad": false
+  }
+}

+ 13 - 0
project.tt.json

@@ -0,0 +1,13 @@
+{
+  "miniprogramRoot": "./",
+  "projectname": "shougang-wms-mini",
+  "description": "首钢收发货小程序",
+  "appid": "wxbbc727cd608c4336",
+  "setting": {
+    "urlCheck": true,
+    "es6": false,
+    "postcss": false,
+    "minified": false
+  },
+  "compileType": "miniprogram"
+}

+ 9 - 0
src/app.config.js

@@ -0,0 +1,9 @@
+export default defineAppConfig({
+  pages: ['pages/index/index'],
+  window: {
+    backgroundTextStyle: 'light',
+    navigationBarBackgroundColor: '#fff',
+    navigationBarTitleText: '收发货系统',
+    navigationBarTextStyle: 'black',
+  },
+});

+ 12 - 0
src/app.jsx

@@ -0,0 +1,12 @@
+import '@styles/app.css';
+import {QueryClient, QueryClientProvider} from '@tanstack/react-query';
+
+const queryClient = new QueryClient();
+
+const App = function ({children}) {
+  return (
+    <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
+  );
+};
+
+export default App;

+ 17 - 0
src/index.html

@@ -0,0 +1,17 @@
+<!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>shougang-wms-mini</title>
+  <script><%= htmlWebpackPlugin.options.script %></script>
+</head>
+<body>
+  <div id="app"></div>
+</body>
+</html>

+ 4 - 0
src/pages/index/index.config.js

@@ -0,0 +1,4 @@
+export default definePageConfig({
+  navigationBarTitleText: '个人中心',
+  navigationStyle: 'custom',
+});

+ 19 - 0
src/pages/index/index.jsx

@@ -0,0 +1,19 @@
+import {View, Image, Text} from '@tarojs/components';
+
+export default function App() {
+  return (
+    <View className='w-screen h-screen bg-gradient-to-br from-[#EBF1FF] to-[#F4F6F8] pt-20 px-4'>
+      <View className='flex items-center'>
+        <Image
+          className='w-14 h-14 rounded-full'
+          src='https://cdn.novenn.com/random/avatars/1595853168010.jpg'
+          mode='aspectFit'
+        />
+
+        <View className='flex-1 ps-4'>
+          <Text className='block text-base text-[#333]'>谭迪人</Text>
+        </View>
+      </View>
+    </View>
+  );
+}

+ 40 - 0
src/styles/app.css

@@ -0,0 +1,40 @@
+/* stylelint-disable at-rule-no-unknown */
+@tailwind base;
+@tailwind components;
+@tailwind utilities;
+
+view {
+  box-sizing: border-box;
+  text-decoration: none;
+  letter-spacing: 0.5px;
+}
+
+[hidden] {
+  display: none !important;
+}
+
+image {
+  display: block;
+  height: auto;
+}
+
+button {
+  position: relative;
+  box-sizing: border-box;
+  padding: 0;
+  margin: 0;
+  overflow: hidden;
+  line-height: normal;
+  text-align: center;
+  text-decoration: none;
+  background-color: #f8f8f8;
+  border: unset;
+  border-radius: 0;
+  -webkit-tap-highlight-color: transparent;
+
+  &::after {
+    width: auto;
+    height: auto;
+    border: unset;
+  }
+}

+ 12 - 0
tailwind.config.js

@@ -0,0 +1,12 @@
+/** @type {import('tailwindcss').Config} */
+module.exports = {
+  content: ['./public/index.html', './src/**/*.{html,js,ts,jsx,tsx,vue}'],
+  darkMode: 'class',
+  theme: {
+    extend: {},
+  },
+  plugins: [],
+  corePlugins: {
+    preflight: false,
+  },
+};