root 2 роки тому
батько
коміт
d7f6732b97
2 змінених файлів з 102 додано та 97 видалено
  1. 3 97
      app.html
  2. 99 0
      pages/app/header-json.js

+ 3 - 97
app.html

@@ -84,110 +84,16 @@
 <script src="./lang/zh-CN.js"></script>
 <!-- 引入多语言js处理文件,必须先引入语言包 -->
 <script src="./public/static/tools/common.js"></script>
+<!-- 引入header的JSON -->
+<script src="./pages/app/header-json.js"></script>
 <script>
-  
     (function () {
       let amis = amisRequire('amis/embed');
       const match = amisRequire('path-to-regexp').match;
-      
       // 如果想用 browserHistory 请切换下这处代码, 其他不用变
       // const history = History.createBrowserHistory();
       const history = History.createHashHistory();
-      const header = {
-  "type": "page",
-  "initApi": "/api/sys_user_info",
-  "body": [
-    {
-      "type": "flex",
-      "justify": "flex-end",
-      "items": [
-        {
-          "type": "dropdown-button",
-          "label": "",
-          "className": "header-menu",
-          "buttons": [
-            {
-              "type": "button",
-              "label": "中文",
-              "id": "u:6911502c8fcc",
-              "onEvent": {
-                "click": {
-                  "actions": [
-                    {
-                      "script": "localStorage.setItem('language', 'zh-CN')\nlocation.reload()",
-                      "actionType": "custom",
-                      "args": {
-                      }
-                    }
-                  ],
-                  "weight": 0
-                }
-              }
-            },
-            {
-              "type": "button",
-              "label": "English",
-              "id": "u:e702685a7a45",
-              "onEvent": {
-                "click": {
-                  "actions": [
-                    {
-                      "script": "localStorage.setItem('language', 'en-US')\r\nlocation.reload()",
-                      "actionType": "custom"
-                    }
-                  ],
-                  "weight": 0
-                }
-              },
-              "actionType": "",
-              "link": "/view/user_info"
-            }
-          ],
-          "id": "u:4fedf7a987bf",
-          "size": "md",
-          "level": "default",
-          "align": "right",
-          "block": false,
-          "hideCaret": true,
-          "trigger": "hover",
-          "icon": "./public/static/icon/language-change.png",
-          "btnClassName": "no-border"
-        },
-        {
-          "type": "dropdown-button",
-          "label": "名字e",
-          "className": "header-menu",
-          "buttons": [
-            {
-              "type": "button",
-              "label": "个人信息",
-              "actionType": "link",
-              "link": "/view/user_info",
-              "id": "u:57cf3ed9c568"
-            },
-            {
-              "type": "button",
-              "actionType": "url",
-              "url": "/login/out",
-              "blank": false,
-              "confirmText": "确定要退出吗",
-              "label": "退出登录",
-              "id": "u:88d8afc464b5"
-            }
-          ],
-          "id": "u:d324269526b9",
-          "size": "md",
-          "level": "default",
-          "align": "right",
-          "block": true,
-          "trigger": "hover"
-        }
-      ],
-      "id": "u:e7752d0c1dbe"
-    }
-  ],
-  "id": "u:d16525b6aae6"
-}
+      const header = getHeaderJson()
       const app = {
         type: 'app',
         brandName: 'ROMA',

+ 99 - 0
pages/app/header-json.js

@@ -0,0 +1,99 @@
+function getHeaderJson() {
+    let headerJson = {
+        "type": "page",
+        "initApi": "/api/sys_user_info",
+        "body": [
+          {
+            "type": "flex",
+            "justify": "flex-end",
+            "items": [
+              {
+                "type": "dropdown-button",
+                "label": "",
+                "className": "header-menu",
+                "buttons": [
+                  {
+                    "type": "button",
+                    "label": "中文",
+                    "id": "u:6911502c8fcc",
+                    "onEvent": {
+                      "click": {
+                        "actions": [
+                          {
+                            "script": "localStorage.setItem('language', 'zh-CN')\nlocation.reload()",
+                            "actionType": "custom",
+                            "args": {
+                            }
+                          }
+                        ],
+                        "weight": 0
+                      }
+                    }
+                  },
+                  {
+                    "type": "button",
+                    "label": "English",
+                    "id": "u:e702685a7a45",
+                    "onEvent": {
+                      "click": {
+                        "actions": [
+                          {
+                            "script": "localStorage.setItem('language', 'en-US')\r\nlocation.reload()",
+                            "actionType": "custom"
+                          }
+                        ],
+                        "weight": 0
+                      }
+                    },
+                    "actionType": "",
+                    "link": "/view/user_info"
+                  }
+                ],
+                "id": "u:4fedf7a987bf",
+                "size": "md",
+                "level": "default",
+                "align": "right",
+                "block": false,
+                "hideCaret": true,
+                "trigger": "hover",
+                "icon": "./public/static/icon/language-change.png",
+                "btnClassName": "no-border"
+              },
+              {
+                "type": "dropdown-button",
+                "label": "名字e",
+                "className": "header-menu",
+                "buttons": [
+                  {
+                    "type": "button",
+                    "label": "个人信息",
+                    "actionType": "link",
+                    "link": "/view/user_info",
+                    "id": "u:57cf3ed9c568"
+                  },
+                  {
+                    "type": "button",
+                    "actionType": "url",
+                    "url": "/login/out",
+                    "blank": false,
+                    "confirmText": "确定要退出吗",
+                    "label": "退出登录",
+                    "id": "u:88d8afc464b5"
+                  }
+                ],
+                "id": "u:d324269526b9",
+                "size": "md",
+                "level": "default",
+                "align": "right",
+                "block": true,
+                "trigger": "hover"
+              }
+            ],
+            "id": "u:e7752d0c1dbe"
+          }
+        ],
+        "id": "u:d16525b6aae6"
+    }
+
+    return headerJson
+}