Jelajahi Sumber

将登录页页面json,拆成js文件

root 2 tahun lalu
induk
melakukan
e197476ac3
3 mengubah file dengan 187 tambahan dan 179 penghapusan
  1. 7 176
      login.html
  2. 0 3
      pages/login/header.js
  3. 180 0
      pages/login/login-json.js

+ 7 - 176
login.html

@@ -101,6 +101,7 @@
 <script type='text/javascript' src='./public/static/amis-sdk/sdk.js'></script>
 <script src="./lang/en-US.js"></script>
 <script src="./lang/zh-CN.js"></script>
+<script src="./pages/login/login-json.js"></script>
 
 <script type="text/javascript">
     (function () {
@@ -148,182 +149,7 @@
           langReplaceTextIgnoreKeys = {}
         }
       // 页面json内容
-        const amisJSON = {
-            "type": "wrapper",
-            "className": "fixed login_layout m:h-screen m:w-full bg-gray-50",
-            "body": {
-                "type": "form",
-                "className": "h-full pc:p-9 m:p-4 m:pt-20",
-                "api": {
-                    "method":"post",
-                    "url":"/login",
-                    "adaptor": function (data) {
-                        if (data.status !== 0) {
-                            // 登录请求提交后,刷新验证码
-                            refresh_code();
-                        }
-                        return data;
-                    },
-                },
-                "redirect": "/",
-                "wrapWithPanel": false,
-                "body": [
-                {
-  "type": "wrapper",
-  "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"
-        }
-      ],
-      "id": "u:e7752d0c1dbe"
-    }
-  ],
-  "id": "u:d16525b6aae6",
-  "asideResizor": false,
-  "pullRefresh": {
-    "disabled": true
-  }
-},
-                    {
-                        "type":"html",
-                        "className":"text-center",
-                        "html":"<h1 class='title-name'>Roma 平台</h1>"
-                    },
-                    {
-                        "type": "input-group",
-                        "label": "",
-                        "body": [
-                            {
-                                "type": "icon",
-                                "icon": "./public/static/icon/shield-user-line.svg"
-                            },
-                            {
-                                "type": "input-text",
-                                "label": false,
-                                "placeholder": "用户名",
-                                "name": "name",
-                                "required": true
-                            }
-                        ]
-                    },
-                    {
-                        "type": "input-group",
-                        "label": "",
-                        "body": [
-                            {
-                                "type": "icon",
-                                "icon": "./public/static/icon/lock-password-line.svg",
-                            },
-                            {
-                                "type": "input-password",
-                                "label": false,
-                                "placeholder": "密码",
-                                "name": "pwd",
-                                "required": true
-                            }
-                        ]
-                    },
-                    {
-                        "type": "input-group",
-                        "label": "",
-                        "body": [
-                            {
-                                "type": "icon",
-                                "icon": "./public/static/icon/shield-check-line.svg"
-                            },
-                            {
-                                "type": "input-text",
-                                "label": false,
-                                "placeholder": "验证码",
-                                "name": "code",
-                                "required": true
-                            },
-                            {
-                                "type": "action",
-                                "body": {
-                                    "type": "image",
-                                "height": "38px",
-                                "width": "110px",
-                                "name":"codeUrl",
-                                "imageClassName":"code_img b-none",
-                                "imageMode":"original",
-                                "src": "/login/verify"
-                                },
-                                // 点击图片 刷新二维码
-                                "onClick": "refresh_code()"
-                            }
-                        ]
-                    },
-                    {
-                        "label": "登 录",
-                        "type": "action",
-                        "actionType": "submit",
-                        "level": "primary",
-                        "className":"w-full h-2.5",
-                    },
-                    // {
-                    //     "type":"html",
-                    //     "className":"text-center",
-                    //     "html":"<p class='mt-10 text-gray-600'>Roma平台</p>"
-                    // },
-                ]
-
-            }
-
-        };
+        const amisJSON = getLoginJson()
 
         let amisScoped = amis.embed(
           '#root', 
@@ -342,6 +168,11 @@
     {
         document.querySelector('.code_img').src = '/login/verify?' + Math.random();
     }
+
+    // 设置多语言
+    function setLanguage() {
+      
+    }
 </script>
 </body>
 </html>

+ 0 - 3
pages/login/header.js

@@ -1,3 +0,0 @@
-function getHeader() {
-    
-}

+ 180 - 0
pages/login/login-json.js

@@ -0,0 +1,180 @@
+function getLoginJson() {
+    let headerJson = {
+        "type": "wrapper",
+        "className": "fixed login_layout m:h-screen m:w-full bg-gray-50",
+        "body": {
+            "type": "form",
+            "className": "h-full pc:p-9 m:p-4 m:pt-20",
+            "api": {
+                "method":"post",
+                "url":"/login",
+                "adaptor": function (data) {
+                    if (data.status !== 0) {
+                        // 登录请求提交后,刷新验证码
+                        refresh_code();
+                    }
+                    return data;
+                },
+            },
+            "redirect": "/",
+            "wrapWithPanel": false,
+            "body": [
+            {
+"type": "wrapper",
+"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"
+    }
+  ],
+  "id": "u:e7752d0c1dbe"
+}
+],
+"id": "u:d16525b6aae6",
+"asideResizor": false,
+"pullRefresh": {
+"disabled": true
+}
+},
+                {
+                    "type":"html",
+                    "className":"text-center",
+                    "html":"<h1 class='title-name'>Roma 平台</h1>"
+                },
+                {
+                    "type": "input-group",
+                    "label": "",
+                    "body": [
+                        {
+                            "type": "icon",
+                            "icon": "./public/static/icon/shield-user-line.svg"
+                        },
+                        {
+                            "type": "input-text",
+                            "label": false,
+                            "placeholder": "用户名",
+                            "name": "name",
+                            "required": true
+                        }
+                    ]
+                },
+                {
+                    "type": "input-group",
+                    "label": "",
+                    "body": [
+                        {
+                            "type": "icon",
+                            "icon": "./public/static/icon/lock-password-line.svg",
+                        },
+                        {
+                            "type": "input-password",
+                            "label": false,
+                            "placeholder": "密码",
+                            "name": "pwd",
+                            "required": true
+                        }
+                    ]
+                },
+                {
+                    "type": "input-group",
+                    "label": "",
+                    "body": [
+                        {
+                            "type": "icon",
+                            "icon": "./public/static/icon/shield-check-line.svg"
+                        },
+                        {
+                            "type": "input-text",
+                            "label": false,
+                            "placeholder": "验证码",
+                            "name": "code",
+                            "required": true
+                        },
+                        {
+                            "type": "action",
+                            "body": {
+                                "type": "image",
+                            "height": "38px",
+                            "width": "110px",
+                            "name":"codeUrl",
+                            "imageClassName":"code_img b-none",
+                            "imageMode":"original",
+                            "src": "/login/verify"
+                            },
+                            // 点击图片 刷新二维码
+                            "onClick": "refresh_code()"
+                        }
+                    ]
+                },
+                {
+                    "label": "登 录",
+                    "type": "action",
+                    "actionType": "submit",
+                    "level": "primary",
+                    "className":"w-full h-2.5",
+                },
+                // {
+                //     "type":"html",
+                //     "className":"text-center",
+                //     "html":"<p class='mt-10 text-gray-600'>Roma平台</p>"
+                // },
+            ]
+
+        }
+
+    };
+
+    return headerJson;
+}