Prechádzať zdrojové kódy

1.0.67 增加单点登录页

liuyanpeng 2 rokov pred
rodič
commit
8cce4ffe90
3 zmenil súbory, kde vykonal 171 pridanie a 4 odobranie
  1. 3 2
      package.json
  2. 162 0
      public/oalogin.html
  3. 6 2
      webpack.prod.js

+ 3 - 2
package.json

@@ -1,7 +1,7 @@
 {
 {
   "name": "prodog-pc-client",
   "name": "prodog-pc-client",
   "description": "Leanwo Prodog Client",
   "description": "Leanwo Prodog Client",
-  "version": "1.0.65",
+  "version": "1.0.67",
   "author": "yangzhijie1488 <yangzhijie1488@163.com>",
   "author": "yangzhijie1488 <yangzhijie1488@163.com>",
   "scripts": {
   "scripts": {
     "dev": "cross-env webpack serve --config ./webpack.dev.js",
     "dev": "cross-env webpack serve --config ./webpack.dev.js",
@@ -22,8 +22,8 @@
     "client-dic-v3": "^3.0.9",
     "client-dic-v3": "^3.0.9",
     "client-eam-v3": "^3.0.35",
     "client-eam-v3": "^3.0.35",
     "client-role-v3": "^3.0.8",
     "client-role-v3": "^3.0.8",
-    "client-wms-v3": "^3.0.4",
     "client-trace-v3": "^1.0.18",
     "client-trace-v3": "^1.0.18",
+    "client-wms-v3": "^3.0.4",
     "dayjs": "^1.11.6",
     "dayjs": "^1.11.6",
     "dingtalk-jsapi": "^2.8.33",
     "dingtalk-jsapi": "^2.8.33",
     "js-cookie": "^2.2.1",
     "js-cookie": "^2.2.1",
@@ -49,6 +49,7 @@
     "@vue/babel-preset-jsx": "^1.4.0",
     "@vue/babel-preset-jsx": "^1.4.0",
     "babel-loader": "^8.2.3",
     "babel-loader": "^8.2.3",
     "clean-webpack-plugin": "^4.0.0",
     "clean-webpack-plugin": "^4.0.0",
+    "copy-webpack-plugin": "^11.0.0",
     "cross-env": "^7.0.3",
     "cross-env": "^7.0.3",
     "css-loader": "^6.7.0",
     "css-loader": "^6.7.0",
     "eslint": "^8.10.0",
     "eslint": "^8.10.0",

+ 162 - 0
public/oalogin.html

@@ -0,0 +1,162 @@
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="utf-8" />
+    <meta
+      name="viewport"
+      content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
+    />
+  </head>
+
+  <body>
+    <div id="app1" class="container">
+      <div style="margin-top: 30px">
+        <h1>登录中</h1>
+        <p>{{ message }}</p>
+      </div>
+    </div>
+    <script
+      type="text/javascript"
+      src="/static/jquery/dist/jquery.min.js"
+    ></script>
+    <script
+      type="text/javascript"
+      src="/static/vue/dist/vue.global.prod.js"
+    ></script>
+    <script>
+      Vue.createApp({
+        data: function () {
+          return {
+            userId: undefined, //用户ID
+            clientId: undefined, //公司ID
+            userName: undefined, //用户姓名
+            checkCode: undefined, // 校验码
+            loginDateMs: undefined, //当前登录时间
+            message: "正在检查您的权限,请稍等...",
+            urlRoot: "",
+          };
+        },
+        mounted: function () {
+          this.urlRoot = this.getRootPath() + "/";
+          this.getParams();
+        },
+        methods: {
+          // 获取参数后登录
+          getParams: function () {
+            var _self = this;
+            const url = window.location.href
+            const params = _self.getQueryString(url)
+            _self.userId = params.userId;
+            _self.userName = params.userName;
+            _self.clientId = params.clientId;
+            _self.checkCode = params.checkCode;
+            _self.loginDateMs = params.loginDateMs;
+            this.azureSamlLogin();
+          },
+
+          // 单点登录
+          azureSamlLogin: function () {
+            let _self = this;
+            var loginData = {
+              userId: _self.userId,
+              userName: _self.userName,
+              clientId: _self.clientId,
+              checkCode: _self.checkCode,
+              loginDateMs: _self.loginDateMs,
+            };
+            $.ajax({
+              url: "authApi/LoginResource/loginPoint",
+              type: "post",
+              data: loginData,
+              success: function (loginInfo) {
+                if (loginInfo.errorCode == 0) {
+                  _self.setTokenClient();
+                  _self.setLoginInfo(loginInfo.data);
+                } else {
+                  _self.message = loginInfo.errorMessage;
+                }
+              },
+              error: function (XMLHttpRequest, textStatus, errorThrown) {},
+            });
+          },
+          // 设置LoginInfo
+          setLoginInfo: function (loginInfo) {
+            var _self = this;
+            _self.clearLocalStorage();
+            localStorage.setItem("#token", loginInfo.token);
+            localStorage.setItem("#accountId", loginInfo.accountId);
+            localStorage.setItem("#LoginInfo", JSON.stringify(loginInfo));
+            window.location.href = _self.urlRoot + "#/desktop/dashboard";
+          },
+
+          // 获取参数函数
+          getQueryString: function (url) {
+            let urlStr = url.split("?")[1];
+            const urlSearchParams = new URLSearchParams(urlStr);
+            const result = Object.fromEntries(urlSearchParams.entries());
+            return result;
+          },
+
+          // 获取主机地址
+          getRootPath: function () {
+            var protocol = window.location.protocol;
+            var host = window.location.host;
+            var localhostPath = protocol + "//" + host;
+            return localhostPath;
+          },
+
+          // 设置TokenClient
+          setTokenClient: function () {
+            var _self = this;
+            $.ajax({
+              url: "TokenClientResource/saveTokenClient",
+              type: "post",
+              contentType: "application/json",
+              beforeSend: function (request) {
+                var token = localStorage.getItem("#token");
+                var account = localStorage.getItem("#accountId");
+                request.setRequestHeader("account", account);
+                request.setRequestHeader("token", token);
+              },
+              success: function (data) {},
+              error: function (XMLHttpRequest, textStatus, errorThrown) {},
+            });
+          },
+          // 清理localStorage
+          clearLocalStorage: function () {
+            // 需要保留的参数列表
+            var reserveParams = [
+              "hostPageBaseURL",
+              "workShopId",
+              "resourceInstanceId",
+              "resourceInstanceName",
+              "apsBaseUrl",
+              "cameraBaseURL",
+            ];
+            //存放的信息
+            var reserveParamValues = [];
+
+            //获取参数信息
+            var len = reserveParams.length;
+            for (let i = 0; i < len; i++) {
+              var reserveParam = reserveParams[i];
+              var reserveParamValue = "";
+              if (localStorage.getItem(reserveParam) != undefined) {
+                reserveParamValue = localStorage.getItem(reserveParam);
+              }
+              reserveParamValues.push(reserveParamValue);
+            }
+
+            //清理localStorage
+            window.localStorage.clear();
+
+            //还原参数信息
+            for (let i = 0; i < len; i++) {
+              localStorage.setItem(reserveParams[i], reserveParamValues[i]);
+            }
+          },
+        },
+      }).mount("#app1");
+    </script>
+  </body>
+</html>

+ 6 - 2
webpack.prod.js

@@ -6,7 +6,7 @@ const WebpackMerge = require('webpack-merge');
 const baseConfig = require('./webpack.base.js');
 const baseConfig = require('./webpack.base.js');
 const TerserPlugin = require('terser-webpack-plugin');
 const TerserPlugin = require('terser-webpack-plugin');
 const { CleanWebpackPlugin } = require('clean-webpack-plugin');
 const { CleanWebpackPlugin } = require('clean-webpack-plugin');
-
+const CopyPlugin = require("copy-webpack-plugin");
 module.exports =  WebpackMerge.merge(baseConfig, {
 module.exports =  WebpackMerge.merge(baseConfig, {
   mode: 'production',
   mode: 'production',
   //开发环境下默认启用cache,在内存中对已经构建的部分进行缓存
   //开发环境下默认启用cache,在内存中对已经构建的部分进行缓存
@@ -73,6 +73,10 @@ module.exports =  WebpackMerge.merge(baseConfig, {
     new MiniCssExtractPlugin({
     new MiniCssExtractPlugin({
       filename: './client-v4-style/[name].[contenthash:8].css',
       filename: './client-v4-style/[name].[contenthash:8].css',
     }),
     }),
-
+    new CopyPlugin({
+      patterns: [
+        { from: "./public/oalogin.html", to: "" },
+      ],
+    }),
   ]),
   ]),
 });
 });