|
|
@@ -0,0 +1,136 @@
|
|
|
+<!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 {
|
|
|
+ token: "",
|
|
|
+ urlRoot: "",
|
|
|
+ languageId: "zh-CN",
|
|
|
+ message: "正在检查您的权限,请稍等...",
|
|
|
+ };
|
|
|
+ },
|
|
|
+ mounted: function () {
|
|
|
+ this.urlRoot = this.getRootPath() + "/";
|
|
|
+ this.getParams();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 获取参数后登录
|
|
|
+ getParams: function () {
|
|
|
+ var _self = this;
|
|
|
+ const url = window.location.href;
|
|
|
+ const params = _self.getQueryString();
|
|
|
+ _self.token = params.token;
|
|
|
+ this.azureSamlLogin();
|
|
|
+ },
|
|
|
+
|
|
|
+ // 单点登录
|
|
|
+ azureSamlLogin: function () {
|
|
|
+ const _self = this;
|
|
|
+ const params = {
|
|
|
+ token:_self.token,
|
|
|
+ languageId:_self.languageId,
|
|
|
+ }
|
|
|
+ $.ajax({
|
|
|
+ url: _self.urlRoot + `api/SsoResource/login`,
|
|
|
+ type: "post",
|
|
|
+ data:params,
|
|
|
+ success: function (loginInfo) {
|
|
|
+ if (loginInfo.errorCode == 0) {
|
|
|
+ _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("#languageSelected", _self.languageId);
|
|
|
+ localStorage.setItem("#LoginInfo", JSON.stringify(loginInfo));
|
|
|
+ window.location.href = _self.urlRoot + "#/desktop/dashboard";
|
|
|
+ },
|
|
|
+
|
|
|
+ // 获取参数函数
|
|
|
+ getQueryString: function () {
|
|
|
+ const url = window.location.href;
|
|
|
+ const 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;
|
|
|
+ },
|
|
|
+
|
|
|
+ // 清理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>
|