Yansen 1年前
父节点
当前提交
a36adbf4b5
共有 8 个文件被更改,包括 47 次插入59540 次删除
  1. 1
    1
      config/index.js
  2. 0
    59473
      package-lock.json
  3. 0
    2
      package.json
  4. 0
    9
      src/app.js
  5. 0
    2
      src/components/Icon.jsx
  6. 44
    39
      src/layouts/index.jsx
  7. 1
    1
      src/pages/home/index.jsx
  8. 1
    13
      yarn.lock

+ 1
- 1
config/index.js 查看文件

@@ -60,6 +60,7 @@ export default defineConfig(async (merge, { command, mode }) => {
60 60
     //   },
61 61
     // },
62 62
     h5: {
63
+      esnextModules: ["@antmjs"],
63 64
       publicPath: "/",
64 65
       staticDirectory: "static",
65 66
       outputDir: "dist",
@@ -95,7 +96,6 @@ export default defineConfig(async (merge, { command, mode }) => {
95 96
             // mediaQuery: false,
96 97
             // // 可选,是否转换页面根节点字体大小,如body: font-size: 16px
97 98
             // minPixelValue: 0,
98
-
99 99
           },
100 100
         },
101 101
         cssModules: {

+ 0
- 59473
package-lock.json
文件差异内容过多而无法显示
查看文件


+ 0
- 2
package.json 查看文件

@@ -70,7 +70,6 @@
70 70
     "@types/node": "^18.15.11",
71 71
     "@types/react": "^18.0.0",
72 72
     "@types/webpack-env": "^1.13.6",
73
-    "babel-plugin-import": "^1.13.5",
74 73
     "babel-preset-taro": "3.6.25",
75 74
     "eslint": "^8.12.0",
76 75
     "eslint-config-taro": "3.6.25",
@@ -80,7 +79,6 @@
80 79
     "jest": "^29.3.1",
81 80
     "jest-environment-jsdom": "^29.5.0",
82 81
     "postcss": "^8.4.18",
83
-    "postcss-pxtorem": "^6.1.0",
84 82
     "react-refresh": "^0.11.0",
85 83
     "stylelint": "^14.4.0",
86 84
     "webpack": "4.46.0"

+ 0
- 9
src/app.js 查看文件

@@ -7,16 +7,7 @@ import '@antmjs/vantui/lib/index.less'
7 7
 // import '@antmjs/vantui/lib/index.css'
8 8
 
9 9
 const App = (props) => {
10
-  // useEffect(async() => {
11
-  //   const userState = store.getState("user");
12 10
 
13
-  //   // 等待组件挂载完成
14
-  //   await Promise.resolve();
15
-
16
-  //   // 然后执行异步操作
17
-  //   await userState.login(123);
18
-  //   userState.current();
19
-  // }, []);
20 11
   const init = async () => {
21 12
     console.log(11111111111)
22 13
     const userState = store.getState("user");

+ 0
- 2
src/components/Icon.jsx 查看文件

@@ -1,6 +1,4 @@
1 1
 import React from 'react';
2
-import Taro from '@tarojs/taro';
3
-import { Image } from '@tarojs/components';
4 2
 import { Icon } from '@antmjs/vantui';
5 3
 import icon1 from '@/assets/icons/icon1.png';
6 4
 import icon2 from '@/assets/icons/icon2.png';

+ 44
- 39
src/layouts/index.jsx 查看文件

@@ -1,18 +1,20 @@
1
-import React from 'react';
2
-import Taro from '@tarojs/taro';
3
-import { View, Image } from '@tarojs/components';
4
-import { useModel } from '@/store';
5
-import { Loading, Notify, Dialog } from '@antmjs/vantui';
6
-import NavLoading from '@/components/NavLoading';
7
-import Auth from '@/components/Auth';
8
-import TabBar from './TabBar';
9
-import laySty from './layout.module.less';
1
+import React from "react";
2
+import Taro from "@tarojs/taro";
3
+import { View, Image } from "@tarojs/components";
4
+import { useModel } from "@/store";
5
+import { Loading, Notify, Dialog } from "@antmjs/vantui";
6
+import NavLoading from "@/components/NavLoading";
7
+import Auth from "@/components/Auth";
8
+import TabBar from "./TabBar";
9
+import laySty from "./layout.module.less";
10 10
 
11 11
 export default (props) => {
12 12
   const { className, style, roles, tabBar = false, loading } = props;
13 13
 
14
-  const { person, user, duty } = useModel('user');
15
-  const containerClass = `${laySty['page-conatiner']} ${tabBar ? laySty['with-tabbar'] : ''} ${className}`;
14
+  const { person, user, duty } = useModel("user");
15
+  const containerClass = `${laySty["page-conatiner"]} ${
16
+    tabBar ? laySty["with-tabbar"] : ""
17
+  } ${className}`;
16 18
 
17 19
   // React.useEffect(() => {
18 20
   //   if (person && !user) {
@@ -25,6 +27,17 @@ export default (props) => {
25 27
   //   }
26 28
   // }, [person, user]);
27 29
 
30
+  React.useMemo(() => {
31
+    if (person && !user) {
32
+      const currentPage = Taro.getCurrentPages().slice().pop();
33
+      if ("pages/login/index" !== currentPage.route) {
34
+        Taro.navigateTo({
35
+          url: "/pages/login/index",
36
+        });
37
+      }
38
+    }
39
+  }, []);
40
+
28 41
   Taro.useShareAppMessage(() => {
29 42
     return {
30 43
       title: '文明城市'
@@ -32,33 +45,25 @@ export default (props) => {
32 45
   });
33 46
 
34 47
   return (
35
-      <View className={laySty['page-wrapper']}>
36
-        <Notify id="vanNotify" />
37
-        <Dialog id="vanDialog" />
38
-        <NavLoading loading={loading} />
39
-        <View className={containerClass} style={style}>
40
-          {
41
-            !person && (
42
-              <View className={laySty.loading}>
43
-                <Loading size="32px" vertical>
44
-                  加载中...
45
-                </Loading>
46
-              </View>
47
-            )
48
-          }
49
-          <Auth roles={roles}>
50
-            {props.children}
51
-          </Auth>
48
+    <View className={laySty["page-wrapper"]}>
49
+      <Notify id="vanNotify" />
50
+      <Dialog id="vanDialog" />
51
+      <NavLoading loading={loading} />
52
+      <View className={containerClass} style={style}>
53
+        {!person && (
54
+          <View className={laySty.loading}>
55
+            <Loading size="32px" vertical>
56
+              加载中...
57
+            </Loading>
58
+          </View>
59
+        )}
60
+        <Auth roles={roles}>{props.children}</Auth>
52 61
 
53
-          {
54
-            !tabBar && (
55
-              <View className={laySty['pdm-space']}></View>
56
-            )
57
-          }
58
-        </View>
59
-        {
60
-          tabBar && <TabBar className={laySty['page-tabbar']} active={tabBar} duty={duty} />
61
-        }
62
+        {!tabBar && <View className={laySty["pdm-space"]}></View>}
62 63
       </View>
63
-  )
64
-}
64
+      {tabBar && (
65
+        <TabBar className={laySty["page-tabbar"]} active={tabBar} duty={duty} />
66
+      )}
67
+    </View>
68
+  );
69
+};

+ 1
- 1
src/pages/home/index.jsx 查看文件

@@ -84,7 +84,7 @@ export default (props) => {
84 84
 
85 85
     return menus[duty];
86 86
   }, [duty])
87
-
87
+console.log(menuArr)
88 88
   return (
89 89
     <Page tabBar="home" className="home-page">
90 90
       <Head

+ 1
- 13
yarn.lock 查看文件

@@ -167,7 +167,7 @@
167 167
   dependencies:
168 168
     "@babel/types" "^7.23.0"
169 169
 
170
-"@babel/helper-module-imports@^7.0.0", "@babel/helper-module-imports@^7.22.15", "@babel/helper-module-imports@^7.24.1", "@babel/helper-module-imports@^7.24.3":
170
+"@babel/helper-module-imports@^7.22.15", "@babel/helper-module-imports@^7.24.1", "@babel/helper-module-imports@^7.24.3":
171 171
   version "7.24.3"
172 172
   resolved "https://registry.npmmirror.com/@babel/helper-module-imports/-/helper-module-imports-7.24.3.tgz"
173 173
   integrity sha512-viKb0F9f2s0BCS22QSF308z/+1YWKV/76mwt61NBzS5izMzDPwdq1pTrzf+Li3npBWX9KdQbkeCt1jSAM7lZqg==
@@ -3591,13 +3591,6 @@ babel-plugin-dynamic-import-node@2.3.3:
3591 3591
   dependencies:
3592 3592
     object.assign "^4.1.0"
3593 3593
 
3594
-babel-plugin-import@^1.13.5:
3595
-  version "1.13.8"
3596
-  resolved "https://registry.npmmirror.com/babel-plugin-import/-/babel-plugin-import-1.13.8.tgz"
3597
-  integrity sha512-36babpjra5m3gca44V6tSTomeBlPA7cHUynrE2WiQIm3rEGD9xy28MKsx5IdO45EbnpJY7Jrgd00C6Dwt/l/2Q==
3598
-  dependencies:
3599
-    "@babel/helper-module-imports" "^7.0.0"
3600
-
3601 3594
 babel-plugin-istanbul@^6.1.1:
3602 3595
   version "6.1.1"
3603 3596
   resolved "https://registry.npmmirror.com/babel-plugin-istanbul/-/babel-plugin-istanbul-6.1.1.tgz"
@@ -11323,11 +11316,6 @@ postcss-plugin-constparse@3.6.25:
11323 11316
   resolved "https://registry.npmmirror.com/postcss-plugin-constparse/-/postcss-plugin-constparse-3.6.25.tgz"
11324 11317
   integrity sha512-x7dYIIZyRXef5ceYd3k2ozb8fbwUbQnTlbfYn2Gv84U3MaR1KiihPLupB4iinxIf42K4i6sX8e4uQQnm0yYtlg==
11325 11318
 
11326
-postcss-pxtorem@^6.1.0:
11327
-  version "6.1.0"
11328
-  resolved "https://registry.npmmirror.com/postcss-pxtorem/-/postcss-pxtorem-6.1.0.tgz"
11329
-  integrity sha512-ROODSNci9ADal3zUcPHOF/K83TiCgNSPXQFSbwyPHNV8ioHIE4SaC+FPOufd8jsr5jV2uIz29v1Uqy1c4ov42g==
11330
-
11331 11319
 postcss-pxtransform@3.6.25:
11332 11320
   version "3.6.25"
11333 11321
   resolved "https://registry.npmmirror.com/postcss-pxtransform/-/postcss-pxtransform-3.6.25.tgz"