张涛 1 year ago
parent
commit
a6bcd5e134
8 changed files with 1995 additions and 1989 deletions
  1. 9
    9
      babel.config.js
  2. 2
    2
      config/dev.js
  3. 22
    3
      config/index.js
  4. 2
    9
      src/app.js
  5. 0
    2
      src/components/Icon.jsx
  6. 45
    40
      src/layouts/index.jsx
  7. 1
    1
      src/pages/home/index.jsx
  8. 1914
    1923
      yarn.lock

+ 9
- 9
babel.config.js View File

8
     }]
8
     }]
9
   ],
9
   ],
10
   plugins: [
10
   plugins: [
11
-    [
12
-      "import",
13
-      {
14
-        libraryName: "@antmjs/vantui",
15
-        libraryDirectory: "es",
16
-        style: (name) => `${name}/style/less`,
17
-      },
18
-      "@antmjs/vantui"
19
-    ]
11
+    // [
12
+    //   "import",
13
+    //   {
14
+    //     libraryName: "@antmjs/vantui",
15
+    //     libraryDirectory: "es",
16
+    //     style: (name) => `${name}/style/less`,
17
+    //   },
18
+    //   "@antmjs/vantui"
19
+    // ]
20
   ]
20
   ]
21
 }
21
 }

+ 2
- 2
config/dev.js View File

3
     NODE_ENV: '"development"',
3
     NODE_ENV: '"development"',
4
   },
4
   },
5
   defineConstants: {
5
   defineConstants: {
6
-    HOST: '"http://127.0.0.1:9087"',
7
-    // HOST: '"http://192.168.89.13:9087"',
6
+    // HOST: '"http://127.0.0.1:9087"',
7
+    HOST: '"http://192.168.89.13:9087"',
8
     // HOST: '"https://wmcj.huoshannews.com"',
8
     // HOST: '"https://wmcj.huoshannews.com"',
9
     AD_IMAGE: '"https://h5.njyunzhi.com/images/citizen_banner.png"',
9
     AD_IMAGE: '"https://h5.njyunzhi.com/images/citizen_banner.png"',
10
     DEFAULT_POS: '"116.3476917447715,31.409912844296578"', // 霍山县人民政府 gcj02
10
     DEFAULT_POS: '"116.3476917447715,31.409912844296578"', // 霍山县人民政府 gcj02

+ 22
- 3
config/index.js View File

10
   const config = {
10
   const config = {
11
     projectName: "civilized-miniapp",
11
     projectName: "civilized-miniapp",
12
     date: "2024-03-21",
12
     date: "2024-03-21",
13
-    designWidth: 750,
13
+    designWidth(input) {
14
+      console.log('---->', input?.file)
15
+      // if (input?.file.replace(/\\+/g, '/').indexOf('@antmjs/vantui') > -1) {
16
+      //   return 750
17
+      // }
18
+      return 750
19
+    },
14
     deviceRatio: {
20
     deviceRatio: {
15
       640: 2.34 / 2,
21
       640: 2.34 / 2,
16
       750: 1,
22
       750: 1,
61
       router: {
67
       router: {
62
         mode: "hash",
68
         mode: "hash",
63
       },
69
       },
70
+      esnextModules: ['@antmjs'],
71
+      // miniCssExtractPluginOption: {
72
+      //   ignoreOrder: true,
73
+      //   filename: "css/[name].[hash].css",
74
+      //   chunkFilename: "css/[id].css",
75
+      // },
76
+
64
       postcss: {
77
       postcss: {
78
+        autoprefixer: {
79
+          enable: true,
80
+          config: {
81
+          }
82
+        },
83
+     
65
         pxtransform: {
84
         pxtransform: {
66
           enable: true,
85
           enable: true,
67
           config: {
86
           config: {
68
-            // // 设置rpx转换为目标单位为rem
87
+            // 设置rpx转换为目标单位为rem
69
             // unitToRem: true,
88
             // unitToRem: true,
70
             // // 设计稿宽度与 rem 基准值,默认设计稿宽度为 750,即 1rem = 75px
89
             // // 设计稿宽度与 rem 基准值,默认设计稿宽度为 750,即 1rem = 75px
71
             // designWidth: 750,
90
             // designWidth: 750,
72
             // // 可选,选择器黑名单
91
             // // 可选,选择器黑名单
73
-            // selectorBlackList: ["body"],
92
+            // selectorBlackList: [],
74
             // // // 可选,替换rpx为其他单位后缀,例如 'px' 或 'rem'
93
             // // // 可选,替换rpx为其他单位后缀,例如 'px' 或 'rem'
75
             // propList: ["*"],
94
             // propList: ["*"],
76
             // // 可选,媒体查询中是否禁用转换
95
             // // 可选,媒体查询中是否禁用转换

+ 2
- 9
src/app.js View File

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

+ 0
- 2
src/components/Icon.jsx View File

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

+ 45
- 40
src/layouts/index.jsx View File

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
 export default (props) => {
11
 export default (props) => {
12
   const { className, style, roles, tabBar = false, loading } = props;
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
   // React.useEffect(() => {
19
   // React.useEffect(() => {
18
   //   if (person && !user) {
20
   //   if (person && !user) {
25
   //   }
27
   //   }
26
   // }, [person, user]);
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
   Taro.useShareAppMessage(() => {
41
   Taro.useShareAppMessage(() => {
29
     return {
42
     return {
30
-      title: '文明霍山'
43
+      title: "文明霍山",
31
     };
44
     };
32
   });
45
   });
33
 
46
 
34
   return (
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
       </View>
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 View File

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

+ 1914
- 1923
yarn.lock
File diff suppressed because it is too large
View File