张涛 1年前
父节点
当前提交
3b8e039bcf
共有 8 个文件被更改,包括 50 次插入46 次删除
  1. 1
    0
      config/dev.js
  2. 3
    2
      config/index.js
  3. 26
    28
      config/prod.js
  4. 6
    1
      src/components/Auth.jsx
  5. 6
    3
      src/layouts/index.jsx
  6. 6
    10
      src/pages/issue/components/Issue/index.jsx
  7. 1
    1
      src/utils/authorize.js
  8. 1
    1
      src/utils/map.js

+ 1
- 0
config/dev.js 查看文件

@@ -6,6 +6,7 @@ module.exports = {
6 6
     // HOST: '"http://127.0.0.1:9087"',
7 7
     HOST: '""',
8 8
     // HOST: '"https://wmcj.huoshannews.com"',
9
+    MAPHOST: '"/api2"',
9 10
     AD_IMAGE: '"https://h5.njyunzhi.com/images/citizen_banner.png"',
10 11
     DEFAULT_POS: '"116.34761502876347,31.40974743425614"', // 霍山县人民政府 gcj02
11 12
     VERSION: '"1.1.13-20230325"',

+ 3
- 2
config/index.js 查看文件

@@ -61,11 +61,12 @@ export default defineConfig(async (merge, { command, mode }) => {
61 61
     //   },
62 62
     // },
63 63
     h5: {
64
-      // publicPath: "/",
64
+      publicPath: "/h5",
65 65
       // staticDirectory: "static",
66 66
       // outputDir: "dist",
67
+      // uglify:false,
67 68
       router: {
68
-        // mode: "hash",
69
+        mode: "browser",
69 70
         basename:"/h5"
70 71
       },
71 72
       esnextModules: ["@antmjs"],

+ 26
- 28
config/prod.js 查看文件

@@ -6,6 +6,7 @@ module.exports = {
6 6
     // HOST: '"http://192.168.89.147:9087"',
7 7
     // HOST: '"https://wmcj.ycjcjy.com"',
8 8
     HOST: '""',
9
+    MAPHOST: '"/api2"',
9 10
     AD_IMAGE: '"https://h5.njyunzhi.com/images/citizen_banner.png"',
10 11
     DEFAULT_POS: '"116.34761502876347,31.40974743425614"', // 霍山县人民政府 gcj02
11 12
     VERSION: '"1.1.29-20240224"',
@@ -17,33 +18,30 @@ module.exports = {
17 18
      * @docs https://github.com/neutrinojs/webpack-chain
18 19
      */
19 20
     // webpackChain(chain) {
20
-      /**
21
-       * 如果 h5 端编译后体积过大,可以使用 webpack-bundle-analyzer 插件对打包体积进行分析。
22
-       * @docs https://github.com/webpack-contrib/webpack-bundle-analyzer
23
-       */
24
-      // chain
25
-      //   .plugin("analyzer")
26
-      //   .use(require("webpack-bundle-analyzer").BundleAnalyzerPlugin, []);
27
-
28
-      /**
29
-       * 如果 h5 端首屏加载时间过长,可以使用 prerender-spa-plugin 插件预加载首页。
30
-       * @docs https://github.com/chrisvfritz/prerender-spa-plugin
31
-       */
32
-      // const path = require("path");
33
-      // const Prerender = require("prerender-spa-plugin");
34
-      // const staticDir = path.join(__dirname, "..", "dist");
35
-      // chain.plugin("prerender").use(
36
-      //   new Prerender({
37
-      //     staticDir,
38
-      //     routes: ["/pages/index/index"],
39
-      //     postProcess: (context) => ({
40
-      //       ...context,
41
-      //       outputPath: path.join(staticDir, "index.html"),
42
-      //     }),
43
-      //   })
44
-      // );
45
-    },
21
+    /**
22
+     * 如果 h5 端编译后体积过大,可以使用 webpack-bundle-analyzer 插件对打包体积进行分析。
23
+     * @docs https://github.com/webpack-contrib/webpack-bundle-analyzer
24
+     */
25
+    // chain
26
+    //   .plugin("analyzer")
27
+    //   .use(require("webpack-bundle-analyzer").BundleAnalyzerPlugin, []);
28
+    /**
29
+     * 如果 h5 端首屏加载时间过长,可以使用 prerender-spa-plugin 插件预加载首页。
30
+     * @docs https://github.com/chrisvfritz/prerender-spa-plugin
31
+     */
32
+    // const path = require("path");
33
+    // const Prerender = require("prerender-spa-plugin");
34
+    // const staticDir = path.join(__dirname, "..", "dist");
35
+    // chain.plugin("prerender").use(
36
+    //   new Prerender({
37
+    //     staticDir,
38
+    //     routes: ["/pages/index/index"],
39
+    //     postProcess: (context) => ({
40
+    //       ...context,
41
+    //       outputPath: path.join(staticDir, "index.html"),
42
+    //     }),
43
+    //   })
44
+    // );
45
+  },
46 46
   // },
47
-
48
-
49 47
 };

+ 6
- 1
src/components/Auth.jsx 查看文件

@@ -16,8 +16,13 @@ export default (props) => {
16 16
   console.log("roles", roles);
17 17
   console.log("!roles.length || hasRights", !roles.length || hasRights);
18 18
 
19
+
20
+  const filteredChildren = React.Children.toArray(props.children).filter(
21
+    child => React.isValidElement(child)
22
+  );
23
+
19 24
   return !roles.length || hasRights ? (
20
-   <div>{props.children}</div>
25
+   <div>{filteredChildren}</div>
21 26
   ) : (
22 27
     <View
23 28
       style={{

+ 6
- 3
src/layouts/index.jsx 查看文件

@@ -16,7 +16,7 @@ export default (props) => {
16 16
     tabBar ? laySty["with-tabbar"] : ""
17 17
   } ${className}`;
18 18
 
19
-  // const userRef = useRef();
19
+  const userRef = useRef();
20 20
   // const personRef = useRef();
21 21
 
22 22
   // React.useEffect(() => {
@@ -50,8 +50,11 @@ export default (props) => {
50 50
     console.log("userRef******************");
51 51
     console.log(user);
52 52
     console.log(!user);
53
+    if (!userRef.current&&user) {
54
+      userRef.current = user;
55
+    }
53 56
 
54
-    if (!user) {
57
+    if (!userRef.current) {
55 58
       const currentPage = Taro.getCurrentPages().slice().pop();
56 59
       if (!currentPage.route.includes("pages/login/index")) {
57 60
         Taro.navigateTo({
@@ -80,7 +83,7 @@ export default (props) => {
80 83
             </Loading>
81 84
           </View>
82 85
         )} */}
83
-        <Auth roles={roles} >{props.children}</Auth>
86
+        <Auth roles={roles}>{props.children}</Auth>
84 87
 
85 88
         {!tabBar && <View className={laySty["pdm-space"]}></View>}
86 89
       </View>

+ 6
- 10
src/pages/issue/components/Issue/index.jsx 查看文件

@@ -1,6 +1,6 @@
1 1
 import React, { useEffect } from "react";
2 2
 import Taro from "@tarojs/taro";
3
-import { View } from "@tarojs/components";
3
+import { Textarea, View } from "@tarojs/components";
4 4
 import { Field, Cell, CellGroup } from "@antmjs/vantui";
5 5
 import LocType from "@/components/LocType";
6 6
 import IssueType from "@/components/IssueType";
@@ -116,7 +116,7 @@ export default (props) => {
116 116
     if (loc) {
117 117
       // 交换经纬度位置
118 118
       const [x, y] = loc.split(",");
119
-      const location = [y,x].join(",");
119
+      const location = [y, x].join(",");
120 120
       geocoder(location)
121 121
         .then((e) => {
122 122
           console.log(e?.address_component?.street_number || e?.address);
@@ -141,9 +141,6 @@ export default (props) => {
141 141
     }
142 142
   }, [issue]);
143 143
 
144
-  useEffect(() => {
145
-    container;
146
-  }, []);
147 144
   return (
148 145
     <View>
149 146
       <LocType
@@ -183,7 +180,6 @@ export default (props) => {
183 180
         onChange={onLocationChange}
184 181
       />
185 182
 
186
-
187 183
       <CellGroup>
188 184
         {issue?.issueId && <Cell title="ID" value={issue.issueId} />}
189 185
         <Cell
@@ -217,13 +213,13 @@ export default (props) => {
217 213
         />
218 214
         <Cell title="问题描述" border={false} />
219 215
 
220
-        <Field
221
-          type="textarea"
216
+        <Textarea 
217
+          // type="textarea"
222 218
           placeholder="请输入问题描述"
223
-          readonly={readOnly}
219
+          disabled={readOnly}
224 220
           autosize={{ minHeight: "120px" }}
225 221
           value={formData.content}
226
-          onChange={(e) => setFieldChange("content", e.detail)}
222
+          onInput={(e) => setFieldChange("content", e.detail.value)}
227 223
         />
228 224
       </CellGroup>
229 225
 

+ 1
- 1
src/utils/authorize.js 查看文件

@@ -47,7 +47,7 @@ export const getLocation = async (options) => {
47 47
 const key = "HTPBZ-HHJA7-XD2XD-PRS37-H3HVJ-U5BAA";
48 48
 export const h5GetLocation = () => {
49 49
   return new Promise((resolve, reject) => {
50
-    const url = `/api2/ws/location/v1/ip?key=${key}`;
50
+    const url = `${MAPHOST}/ws/location/v1/ip?key=${key}`;
51 51
     const res = Taro.request({
52 52
       url: url,
53 53
       method: "GET",

+ 1
- 1
src/utils/map.js 查看文件

@@ -11,7 +11,7 @@ export function geocoder(location, getPoi = 0) {
11 11
   }
12 12
 
13 13
   return new Promise((resolve, reject) => {
14
-    const url = `/api2/ws/geocoder/v1/?location=${location}&key=${QMAP_WEBSERVICE_KEY}&get_poi=${getPoi}`
14
+    const url = `${MAPHOST}/ws/geocoder/v1/?location=${location}&key=${QMAP_WEBSERVICE_KEY}&get_poi=${getPoi}`
15 15
 
16 16
     Taro.request({ url }).then(({ data }) => {
17 17
       const { status, message, result } = data || {};