| | |
| | | </template> |
| | | |
| | | <script> |
| | | import html2canvas from "html2canvas"; |
| | | import Desktop from "./components/Desktop"; |
| | | import NotificationCenter from "./components/NotificationCenter"; |
| | | import NoticeTip from "./components/NoticeTip"; |
| | | import Tools from "./components/Tools"; |
| | | import ToolsEntry from "./components/ToolsEntry"; |
| | | import { getServerName } from "./api.ts"; |
| | | import html2canvas from "html2canvas" |
| | | import Desktop from "./components/Desktop" |
| | | import NotificationCenter from "./components/NotificationCenter" |
| | | import NoticeTip from "./components/NoticeTip" |
| | | import Tools from "./components/Tools" |
| | | import ToolsEntry from "./components/ToolsEntry" |
| | | import { getServerName } from "./api.ts" |
| | | |
| | | import { getApps } from "@/api/app"; |
| | | import { getDevInfo } from "@/api/login"; |
| | | import { getApps } from "@/api/app" |
| | | import { getDevInfo } from "@/api/login" |
| | | |
| | | import config from "../../../../package.json"; |
| | | import config from "../../../../package.json" |
| | | |
| | | export default { |
| | | name: "app", |
| | |
| | | NotificationCenter, |
| | | NoticeTip, |
| | | Tools, |
| | | ToolsEntry, |
| | | ToolsEntry |
| | | }, |
| | | data() { |
| | | return { |
| | | buttonAuthority: sessionStorage.getItem("buttonAuthoritys") || [], |
| | | buttonAuthority: sessionStorage.getItem("buttonAuthoritys") || [] |
| | | // defaultBgUrl:"/images/desktop/background.png" |
| | | }; |
| | | } |
| | | }, |
| | | computed: { |
| | | isAdmin() { |
| | | if ( |
| | | sessionStorage.getItem("userInfo") && |
| | | sessionStorage.getItem("userInfo") !== "" |
| | | ) { |
| | | let loginName = JSON.parse(sessionStorage.getItem("userInfo")).username; |
| | | return loginName === "superadmin" || loginName === "basic"; |
| | | if (sessionStorage.getItem("userInfo") && sessionStorage.getItem("userInfo") !== "") { |
| | | let loginName = JSON.parse(sessionStorage.getItem("userInfo")).username |
| | | return loginName === "superadmin" || loginName === "basic" |
| | | } |
| | | return false; |
| | | return false |
| | | }, |
| | | defaultBgUrl() { |
| | | if (JSON.parse(sessionStorage.getItem("userInfo"))) { |
| | | return JSON.parse(sessionStorage.getItem("userInfo")).backgroundpic; |
| | | return JSON.parse(sessionStorage.getItem("userInfo")).backgroundpic |
| | | } |
| | | return ""; |
| | | }, |
| | | return "" |
| | | } |
| | | }, |
| | | created() { |
| | | this.getServerName(); |
| | | this.getDevInfo(); |
| | | this.getServerName() |
| | | this.getDevInfo() |
| | | }, |
| | | mounted() { |
| | | document.getElementById("app").style.backgroundImage = `url(${ |
| | | this.defaultBgUrl || "/images/desktop/background.png" |
| | | })`; |
| | | this.showApps(); |
| | | let _that = this; |
| | | let msgResp = require("./mock/messages.json"); |
| | | document.getElementById("app").style.backgroundImage = `url(${this.defaultBgUrl || |
| | | "/images/desktop/background.png"})` |
| | | this.showApps() |
| | | let _that = this |
| | | let msgResp = require("./mock/messages.json") |
| | | if (msgResp.success) { |
| | | msgResp.data.forEach(function (item) { |
| | | _that.addMessage(item); |
| | | }); |
| | | msgResp.data.forEach(function(item) { |
| | | _that.addMessage(item) |
| | | }) |
| | | } |
| | | let weather = require("./mock/weather.json"); |
| | | let weather = require("./mock/weather.json") |
| | | if (weather.success) { |
| | | _that.addWeather(weather.data.data); |
| | | _that.addWeather(weather.data.data) |
| | | } |
| | | setTimeout(function () { |
| | | setTimeout(function() { |
| | | _that.addMessage( |
| | | { |
| | | id: "N2", |
| | |
| | | tip: "消息", |
| | | title: "SmartAI", |
| | | body: "V" + config.version, |
| | | time: new Date(), |
| | | time: new Date() |
| | | }, |
| | | true |
| | | ); |
| | | }, 1000); |
| | | ) |
| | | }, 1000) |
| | | window.addEventListener("message", (e) => { |
| | | if (e.data.msg == "AppUpdate") { |
| | | this.showApps(); |
| | | this.showApps() |
| | | } |
| | | if (e.data.msg == "checkSN") { |
| | | this.$refs.desktop.validateSn(); |
| | | this.$refs.desktop.validateSn() |
| | | } |
| | | if (e.data.msg === "changeColor") { |
| | | const iframeArr = document.querySelectorAll("iframe"); |
| | | const iframeArr = document.querySelectorAll("iframe") |
| | | iframeArr.forEach((item) => { |
| | | item.contentWindow.postMessage( |
| | | { msg: "changeColor", color: e.data.color }, |
| | | "*" |
| | | ); |
| | | }); |
| | | item.contentWindow.postMessage({ msg: "changeColor", color: e.data.color }, "*") |
| | | }) |
| | | } |
| | | }); |
| | | }) |
| | | }, |
| | | methods: { |
| | | quit() { |
| | | this.$refs.tools.toLogout(); |
| | | this.$refs.tools.toLogout() |
| | | }, |
| | | onJumpToDock(name) { |
| | | this.$refs.dock_model.onJumpToDock(name); |
| | | this.$refs.dock_model.onJumpToDock(name) |
| | | }, |
| | | onChangeBg(v) { |
| | | document.getElementById("app").style.backgroundImage = "url(" + v + ")"; |
| | | document.getElementById("app").style.backgroundImage = "url(" + v + ")" |
| | | }, |
| | | showApps() { |
| | | let _that = this; |
| | | let _that = this |
| | | |
| | | getApps().then((rsp) => { |
| | | if (rsp && rsp.success) { |
| | | _that.$store.state.desktop.docks = []; |
| | | let installedApps = []; |
| | | rsp.data; |
| | | rsp.data.forEach(function (item) { |
| | | _that.$store.state.desktop.docks = [] |
| | | let installedApps = [] |
| | | rsp.data |
| | | rsp.data.forEach(function(item) { |
| | | if (item.installed) { |
| | | let temp = { |
| | | id: item.id, |
| | |
| | | create_time: item.create_time, |
| | | height: item.height, |
| | | icon: item.icon, |
| | | src: item.iconBlob |
| | | ? "data:image/png;base64," + item.iconBlob |
| | | : item.icon, |
| | | src: item.iconBlob ? "data:image/png;base64," + item.iconBlob : item.icon, |
| | | installed: item.installed, |
| | | isDelete: item.isDelete, |
| | | isUpgrade: item.isUpgrade, |
| | |
| | | url: item.url, |
| | | version: item.version, |
| | | width: item.width, |
| | | isDefault: item.isDefault, |
| | | }; |
| | | |
| | | // 判断权限 |
| | | if ( |
| | | _that.isAdmin || |
| | | _that.buttonAuthority.indexOf(item.package) >= 0 |
| | | ) { |
| | | _that.$store.commit("desktop/addDock", temp); |
| | | isDefault: item.isDefault |
| | | } |
| | | |
| | | installedApps.push(item.package); |
| | | } |
| | | }); |
| | | // 判断权限 |
| | | // if (_that.isAdmin || _that.buttonAuthority.indexOf(item.package) >= 0) { |
| | | _that.$store.commit("desktop/addDock", temp) |
| | | // } |
| | | |
| | | sessionStorage.setItem("apps", installedApps.join(",")); |
| | | installedApps.push(item.package) |
| | | } |
| | | }) |
| | | sessionStorage.setItem("apps", installedApps.join(",")) |
| | | } |
| | | }); |
| | | }) |
| | | }, |
| | | addMessage: function (message, ding) { |
| | | this.$store.dispatch("desktop/addMessage", message); |
| | | addMessage: function(message, ding) { |
| | | this.$store.dispatch("desktop/addMessage", message) |
| | | // if (ding) { |
| | | // new Audio('sounds/ping.mp3').play(); |
| | | // } |
| | | this.$refs.notice_tip_model.showTip(message); |
| | | this.$refs.notice_tip_model.showTip(message) |
| | | }, |
| | | addWeather: function (weather) { |
| | | this.$store.commit("desktop/addWeather", weather); |
| | | addWeather: function(weather) { |
| | | this.$store.commit("desktop/addWeather", weather) |
| | | }, |
| | | screenShot(dock) { |
| | | //找到当前的iframe |
| | | let curIframe = Array.from(document.querySelectorAll("iframe")).find( |
| | | (iframe) => iframe.src.indexOf(dock.url) >= 0 |
| | | ); |
| | | ) |
| | | //保存当前应用快照 |
| | | html2canvas(curIframe.contentWindow.document.body, { |
| | | dpi: window.devicePixelRatio * 4, |
| | | logging: true, //查看html2canvas内部执行流程 |
| | | removeContainer: true, |
| | | imageTimeout: 0, |
| | | useCORS: true, //开启跨域配置 |
| | | useCORS: true //开启跨域配置 |
| | | //allowTaint: true |
| | | }) |
| | | .then((canvas) => { |
| | | let shotSrc = canvas.toDataURL(); |
| | | let shotSrc = canvas.toDataURL() |
| | | // this.$store.commit('desktop/addMinDock', { |
| | | // id: dock.id, |
| | | // src: dock.icon, |
| | |
| | | // }); |
| | | this.$store.commit("desktop/shotscreen", { |
| | | id: dock.id, |
| | | src: shotSrc, |
| | | }); |
| | | src: shotSrc |
| | | }) |
| | | }) |
| | | .catch((e) => { |
| | | this.$store.commit("desktop/shotscreen", { id: dock.id, src: "" }); |
| | | }); |
| | | this.$store.commit("desktop/shotscreen", { id: dock.id, src: "" }) |
| | | }) |
| | | }, |
| | | async getServerName() { |
| | | let res = await getServerName(); |
| | | let res = await getServerName() |
| | | if (res && res.success) { |
| | | this.serverTitle = res.data.serverName; |
| | | window.document.title = res.data.serverName |
| | | ? res.data.serverName |
| | | : "SmartAI"; |
| | | sessionStorage.setItem("title", res.data.serverName); |
| | | this.serverTitle = res.data.serverName |
| | | window.document.title = res.data.serverName ? res.data.serverName : "SmartAI" |
| | | sessionStorage.setItem("title", res.data.serverName) |
| | | } |
| | | }, |
| | | async getDevInfo() { |
| | | const res = await getDevInfo(); |
| | | const res = await getDevInfo() |
| | | if (res && res.success && res.data.deviceType.substr(0, 2) === "DS") { |
| | | sessionStorage.setItem("isShowPolling", "show"); |
| | | sessionStorage.setItem("isShowPolling", "show") |
| | | } |
| | | }, |
| | | }, |
| | | }; |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style> |
| | |
| | | {{ x.name }} |
| | | </div> |
| | | </div> |
| | | <div class="bot"> |
| | | <div class="set" @click="clickFastPath('系统设置')"> |
| | | <span class="icon iconfont">{{ "\ue60f" }}</span> |
| | | <span>设置</span> |
| | | </div> |
| | | <div class="exit" @click="toLogout"> |
| | | <span class="icon iconfont">{{ "\ue60f" }}</span> |
| | | <span>退出</span> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div class="tools-icon no-hover-style"> |
| | | <img class="smart-ai" :src="`${publicPath}images/desktop/header-icon/SmartAI-新.png`" alt /> |
| | |
| | | <div class="tools-icon" @click="notificationCenterClick()"> |
| | | <img :src="`${publicPath}images/desktop/header-icon/notice.png`" alt /> |
| | | </div> |
| | | <div class="tools-icon"> |
| | | <div class="tools-icon" v-show="false"> |
| | | <el-dropdown size="small" placement="bottom"> |
| | | <span class="el-dropdown-link"> |
| | | <img :src="`${publicPath}images/desktop/header-icon/user.png`" alt /> |
| | |
| | | } |
| | | } |
| | | .fast-path { |
| | | height: 310px; |
| | | height: 188px; |
| | | position: absolute; |
| | | width: 200px; |
| | | top: 55px; |
| | |
| | | </template>
|
| | |
|
| | | <script>
|
| | | import draggable from "vuedraggable";
|
| | | import { findAllSdk } from "@/api/taskMange";
|
| | | import bus from "@/plugin/bus";
|
| | | import draggable from "vuedraggable"
|
| | | import { findAllSdk } from "@/api/taskMange"
|
| | | import bus from "@/plugin/bus"
|
| | | export default {
|
| | | name: "toolsEntry",
|
| | | data() {
|
| | |
| | | // ],
|
| | | //rowSize: 3,
|
| | | // badgeNum: 0,
|
| | | };
|
| | | }
|
| | | },
|
| | | computed: {
|
| | | stateDocks() {
|
| | | return this.$store.state.desktop.docks;
|
| | | console.log("carousels", this.$store.state.desktop.docks)
|
| | | return this.$store.state.desktop.docks
|
| | | },
|
| | | carousels() {
|
| | | let pages = 0;
|
| | | let tempArr = this.stateDocks.concat(this.installedSdk);
|
| | | let upgradeArr = tempArr.filter((item) => item.isUpgrade);
|
| | | let arr = null;
|
| | | let pages = 0
|
| | | let tempArr = this.stateDocks.concat(this.installedSdk)
|
| | | let upgradeArr = tempArr.filter((item) => item.isUpgrade)
|
| | | let arr = null
|
| | | //根据屏幕高度来判断是展示3排还是4排 阈值:970
|
| | | if (window.innerHeight >= 930) {
|
| | | //this.rowSize = 4;
|
| | | arr = this.chunk(tempArr, 24);
|
| | | arr = this.chunk(tempArr, 24)
|
| | | } else {
|
| | | //this.rowSize = 3;
|
| | | arr = this.chunk(tempArr, 18);
|
| | | arr = this.chunk(tempArr, 18)
|
| | | }
|
| | | return arr;
|
| | |
|
| | | return arr
|
| | | },
|
| | | badgeNum() {
|
| | | let tempArr = this.stateDocks.concat(this.installedSdk);
|
| | | return tempArr.filter((item) => item.isUpgrade).length;
|
| | | let tempArr = this.stateDocks.concat(this.installedSdk)
|
| | | return tempArr.filter((item) => item.isUpgrade).length
|
| | | },
|
| | | rowSize() {
|
| | | if (window.innerHeight >= 930) {
|
| | | return 4;
|
| | | return 4
|
| | | } else {
|
| | | return 3;
|
| | | return 3
|
| | | }
|
| | | }
|
| | | },
|
| | | mounted() {
|
| | | this.getAllSdk();
|
| | | let _this = this;
|
| | | this.getAllSdk()
|
| | | let _this = this
|
| | | window.addEventListener("message", (e) => {
|
| | | if (e.data && e.data.msg) {
|
| | | let msg = e.data.msg;
|
| | | let msg = e.data.msg
|
| | | if (msg === "logout") {
|
| | | location.assign("/");
|
| | | return;
|
| | | location.assign("/")
|
| | | return
|
| | | }
|
| | | if (msg.indexOf("toSearch") >= 0) {
|
| | | let params = msg.substring(7);
|
| | | this.addFrameByName("search", params);
|
| | | let params = msg.substring(7)
|
| | | this.addFrameByName("search", params)
|
| | | }
|
| | | if (msg.indexOf("toCluster") >= 0) {
|
| | | let params = msg.substring(8);
|
| | | this.addFrameByName("searchForCluster", params);
|
| | | let params = msg.substring(8)
|
| | | this.addFrameByName("searchForCluster", params)
|
| | | }
|
| | | if (msg.indexOf("toSetting") > -1) {
|
| | | const str = msg.split("?")[1];
|
| | | this.addFrameByName("settings", str);
|
| | | const str = msg.split("?")[1]
|
| | | this.addFrameByName("settings", str)
|
| | | }
|
| | | if (msg.indexOf("toVindicate") > -1) {
|
| | | const str = msg.split("?")[1];
|
| | | this.addFrameByName("vindicate", str);
|
| | | const str = msg.split("?")[1]
|
| | | this.addFrameByName("vindicate", str)
|
| | | }
|
| | | if (msg.indexOf("toAI") > -1) {
|
| | | const str = msg.split("?")[1];
|
| | | this.addFrameByName("algorithmManage", str);
|
| | | const str = msg.split("?")[1]
|
| | | this.addFrameByName("algorithmManage", str)
|
| | | }
|
| | | if (msg.indexOf("toOpenApp") >= 0) {
|
| | | let id = msg.substring(10);
|
| | | this.addFrameByID(id);
|
| | | let id = msg.substring(10)
|
| | | this.addFrameByID(id)
|
| | | }
|
| | | if (msg.indexOf("changeBackground") > -1) {
|
| | | const name = e.data.msg.split("?")[1];
|
| | | _this.$emit("changeBackground", `/images/desktop/${name}.png`);
|
| | | const name = e.data.msg.split("?")[1]
|
| | | _this.$emit("changeBackground", `/images/desktop/${name}.png`)
|
| | | }
|
| | | if (msg == "AppUpdate") {
|
| | | this.getAllSdk();
|
| | | this.getAllSdk()
|
| | | }
|
| | | }
|
| | | });
|
| | | })
|
| | | },
|
| | | methods: {
|
| | | chunk(arr, size) {
|
| | | size = Math.max(size, 0);
|
| | | const len = arr == null ? 0 : arr.length;
|
| | | size = Math.max(size, 0)
|
| | | const len = arr == null ? 0 : arr.length
|
| | | if (!len || size < 1) {
|
| | | return [];
|
| | | return []
|
| | | }
|
| | | let index = 0;
|
| | | let resIndex = 0;
|
| | | const result = new Array(Math.ceil(len / size));
|
| | | let index = 0
|
| | | let resIndex = 0
|
| | | const result = new Array(Math.ceil(len / size))
|
| | | while (index < len) {
|
| | | result[resIndex++] = arr.slice(index, (index += size));
|
| | | result[resIndex++] = arr.slice(index, (index += size))
|
| | | }
|
| | | return result;
|
| | | return result
|
| | | },
|
| | | onJumpToDock(name) {
|
| | | let togo;
|
| | | let togo
|
| | | this.carousels.forEach((arr) => {
|
| | | arr.forEach((x) => {
|
| | | if (x.title == name) {
|
| | | togo = x;
|
| | | togo = x
|
| | | }
|
| | | });
|
| | | });
|
| | | this.dockClick(togo);
|
| | | })
|
| | | })
|
| | | this.dockClick(togo)
|
| | | },
|
| | | getAllSdk() {
|
| | | findAllSdk()
|
| | | .then((res) => {
|
| | | this.installedSdk = res.data.filter((item) => item.installed);
|
| | | this.installedSdk = res.data.filter((item) => item.installed)
|
| | | })
|
| | | .catch((e) => {
|
| | | console.log(e);
|
| | | });
|
| | | console.log(e)
|
| | | })
|
| | | },
|
| | | dockClick(dock) {
|
| | | if (dock.type === "1") {
|
| | | window.open(dock.url);
|
| | | window.open(dock.url)
|
| | | } else if (dock.type === "2" && !dock.isOpen) {
|
| | | if(dock.url== "/view/debuggTool/"){
|
| | | return true;
|
| | | if (dock.url == "/view/debuggTool/") {
|
| | | return true
|
| | | }
|
| | | this.$store.dispatch("desktop/addFrame", {
|
| | | id: dock.id,
|
| | | icon: dock.src,
|
| | | title: dock.title,
|
| | | url: dock.url
|
| | | });
|
| | | })
|
| | | this.$store.commit("desktop/addMinDock", {
|
| | | id: dock.id,
|
| | | src: dock.src,
|
| | |
| | | highlight: true,
|
| | | url: dock.url,
|
| | | screenshot: ""
|
| | | });
|
| | | })
|
| | | //打开应用后异步抓拍,之后的抓拍采用这张固定的
|
| | | //if(dock.name=='cameraVideo'||dock.name=='search'||dock.name=='library'||dock.name=='cameraAccess'||dock.name=='dataStack'){
|
| | | setTimeout(() => {
|
| | | this.$parent.screenShot(dock);
|
| | | }, 1500);
|
| | | this.$parent.screenShot(dock)
|
| | | }, 1500)
|
| | | //}
|
| | | } else if (dock.type === "2" && dock.isOpen) {
|
| | | this.$store.commit("desktop/resetMinFrame", dock.id);
|
| | | this.$store.commit("desktop/resetMinFrame", dock.id)
|
| | | }
|
| | | },
|
| | | resetDockItem() {
|
| | | const dockItems = document.getElementsByClassName("dock-item");
|
| | | const dockMask = document.getElementsByClassName("dock-mask")[0];
|
| | | const dockItems = document.getElementsByClassName("dock-item")
|
| | | const dockMask = document.getElementsByClassName("dock-mask")[0]
|
| | | for (let i = 0; i < dockItems.length; i++) {
|
| | | dockItems[i].width = 60;
|
| | | dockItems[i].width = 60
|
| | | if (dockItems[i].parentNode.nextElementSibling) {
|
| | | dockItems[i].parentNode.nextElementSibling.style.marginLeft = "-35px";
|
| | | dockItems[i].parentNode.nextElementSibling.style.marginLeft = "-35px"
|
| | | }
|
| | | }
|
| | | dockMask.style.width = dockItems.length * 60 + 40 + "px";
|
| | | dockMask.style.width = dockItems.length * 60 + 40 + "px"
|
| | | },
|
| | | addFrameByName(name, params) {
|
| | | let dock = null;
|
| | | let dock = null
|
| | | this.$store.state.desktop.docks.forEach((app) => {
|
| | | if (app.name === name) {
|
| | | dock = app;
|
| | | dock = app
|
| | | }
|
| | | });
|
| | | })
|
| | | if (dock.isOpen) {
|
| | | this.$store.dispatch("desktop/closeFrame", dock);
|
| | | this.$store.dispatch("desktop/closeFrame", dock)
|
| | | }
|
| | | this.$store.dispatch("desktop/addFrame", {
|
| | | id: dock.id,
|
| | | icon: dock.src,
|
| | | title: dock.title,
|
| | | url: dock.url + "?" + params
|
| | | });
|
| | | })
|
| | | this.$store.commit("desktop/addMinDock", {
|
| | | id: dock.id,
|
| | | src: dock.src,
|
| | |
| | | highlight: true,
|
| | | url: dock.url,
|
| | | screenshot: ""
|
| | | });
|
| | | })
|
| | | },
|
| | | addFrameByID(id, params) {
|
| | | let dock = null;
|
| | | let toClose = null;
|
| | | let dock = null
|
| | | let toClose = null
|
| | | this.$store.state.desktop.docks.forEach((app) => {
|
| | | if (app.id == id) {
|
| | | dock = app;
|
| | | dock = app
|
| | | }
|
| | | if (app.name == "algorithmManage") {
|
| | | toClose = app;
|
| | | toClose = app
|
| | | }
|
| | | });
|
| | | this.dockClick(dock);
|
| | | })
|
| | | this.dockClick(dock)
|
| | | }
|
| | | }
|
| | | };
|
| | | }
|
| | | </script>
|
| | |
|
| | | <style lang="scss">
|
| | |
| | | import formAccount from "@/pages/index/components/formAccount"
|
| | | import formNet from "@/pages/index/components/formNet"
|
| | | import formInfo from "@/pages/index/components/formInfo"
|
| | | import { getInitInfo, savePassword, initNetwork, saveRegInfo, getRegInfo, isOnNet } from "./api"
|
| | | import { tologin, getLoginUserData, getServerName } from "./api.ts"
|
| | | import { getMenuListData } from "@/api/utils"
|
| | |
|
| | | export default {
|
| | | name: "smartai init",
|
| | |
| | | }
|
| | | },
|
| | | mounted() {
|
| | | location.assign("/view/desktop/")
|
| | | return
|
| | |
|
| | | this.getInitInfo()
|
| | | let message = "网络正常"
|
| | |
|
| | | function onLine(callback) {
|
| | | var img = new Image()
|
| | | //临时判断网络是否通畅
|
| | | img.src = "http://apps.smartai.com/img/icons/favicon-32x32.png"
|
| | | img.onload = function() {
|
| | | if (callback) callback(true)
|
| | | }
|
| | | img.onerror = function() {
|
| | | if (callback) callback(false)
|
| | | }
|
| | | }
|
| | |
|
| | | onLine((flag) => {
|
| | | let message = ""
|
| | | if (flag) {
|
| | | this.isOnline = true
|
| | | message = "已有网络"
|
| | | } else {
|
| | | //网络断网效果图出来后,将此地改为跳转路径到效果图上
|
| | | message = "无法连接互联网"
|
| | | this.$notify({
|
| | | message: message
|
| | | })
|
| | | }
|
| | | })
|
| | | this.testLogin()
|
| | | },
|
| | |
|
| | | methods: {
|
| | | preForm() {
|
| | | if (this.active == this.createUser) {
|
| | | return
|
| | | }
|
| | | this.active--
|
| | | async testLogin() {
|
| | | // location.assign("/view/desktop/")
|
| | | tologin({ username: "basic", password: "basic2019" })
|
| | | .then((json) => {
|
| | | const loginedInfo = {
|
| | | access_token: json.token_type + " " + json.access_token,
|
| | | refresh_token: json.refresh_token
|
| | | }
|
| | | sessionStorage.setItem("expires_in", json.expires_in)
|
| | | sessionStorage.setItem("loginedInfo", JSON.stringify(loginedInfo))
|
| | | sessionStorage.setItem("userInfo", JSON.stringify(json.userInfo))
|
| | |
|
| | | // 如果网络正常, 直接跳过
|
| | | if (this.active == this.configNet && this.isOnline) {
|
| | | this.active--
|
| | | }
|
| | |
|
| | | this.$refs["carousel"].setActiveItem(this.active)
|
| | | location.assign("/view/desktop/")
|
| | | })
|
| | | .catch()
|
| | | },
|
| | | async nextForm() {
|
| | | // 提交注册信息
|
| | | if (this.active == this.registerInfo) {
|
| | | const data = this.$refs[`form${this.active}`].getFormData()
|
| | | await saveRegInfo(data)
|
| | | location.assign("/view/login/")
|
| | | return
|
| | | async getLoginUserData() {
|
| | | let res = await getLoginUserData()
|
| | | if (res.success) {
|
| | | sessionStorage.setItem("userInfo", JSON.stringify(res.data))
|
| | | // 获取权限
|
| | | // await this.getMenuList()
|
| | |
|
| | | return res.data
|
| | | } else {
|
| | | }
|
| | |
|
| | | // 配置网络
|
| | | if (this.active == this.configNet) {
|
| | | const data = this.$refs[`form${this.active}`].getFormData()
|
| | | initNetwork(data)
|
| | | }
|
| | |
|
| | | // 创建用户
|
| | | if (this.active == this.createUser) {
|
| | | const data = this.$refs[`form${this.active}`].getFormData()
|
| | | if (!data) {
|
| | | return false
|
| | | }
|
| | |
|
| | | await savePassword(data)
|
| | |
|
| | | // 如果网络正常, 直接跳到第三部
|
| | | if (this.isOnline) {
|
| | | this.active++
|
| | | }
|
| | | }
|
| | |
|
| | | this.active++
|
| | | this.$refs["carousel"].setActiveItem(this.active)
|
| | | },
|
| | | async nextFormNot() {
|
| | | await this.getInitInfo()
|
| | |
|
| | | this.active++
|
| | | this.$refs["carousel"].next()
|
| | | },
|
| | | async getInitInfo() {
|
| | | const res = await getInitInfo().catch((err) => {
|
| | | this.isWhite = false
|
| | | })
|
| | |
|
| | | if (res.data && res.data.initPwd && !res.data.initRegInfo) {
|
| | | this.active = this.isOnline ? this.registerInfo : this.configNet
|
| | | async getMenuList() {
|
| | | let results = await getMenuListData({})
|
| | | if (results && results.success) {
|
| | | /* 存储权限 */
|
| | | let buttonAuthoritys = results.data
|
| | | sessionStorage.setItem("buttonAuthoritys", "," + buttonAuthoritys + ",")
|
| | | sessionStorage.setItem("menuInfo", JSON.stringify(results))
|
| | | }
|
| | |
|
| | | if (res.data && res.data.initPwd && res.data.initRegInfo) {
|
| | | location.assign("/view/login/")
|
| | | return
|
| | | }
|
| | |
|
| | | this.isWhite = false
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | import request from '@/scripts/httpRequest' |
| | | import qs from 'qs' |
| | | import request from "@/scripts/httpRequest" |
| | | import qs from "qs" |
| | | |
| | | //获取是否保存过用户名密码 以及是否保存过注册信息 |
| | | //获取是否保存过用户名密码 以及是否保存过注册信息 |
| | | export const getInitInfo = (query: any) => { |
| | | return request({ |
| | | url: "/data/api-v/sysinit/getInitInfo", |
| | | method: "get", |
| | | params: query |
| | | }); |
| | | }; |
| | | }) |
| | | } |
| | | |
| | | //获取注册信息 |
| | | export const getRegInfo = (query: any) => { |
| | | return request({ |
| | | url: "/data/api-v/sysinit/getRegInfo" , |
| | | url: "/data/api-v/sysinit/getRegInfo", |
| | | method: "get", |
| | | params: query |
| | | }); |
| | | }; |
| | | |
| | | }) |
| | | } |
| | | |
| | | //获取网卡列表 |
| | | export const networkList = (query: any) => { |
| | |
| | | url: "/data/api-v/sysinit/networkList", |
| | | method: "get", |
| | | params: query |
| | | }); |
| | | }; |
| | | |
| | | }) |
| | | } |
| | | |
| | | //保存用户名密码 |
| | | export const savePassword = (data: any) => { |
| | |
| | | url: "/data/api-v/sysinit/savePassword", |
| | | method: "post", |
| | | data |
| | | }); |
| | | }; |
| | | |
| | | }) |
| | | } |
| | | |
| | | //初始化网络 |
| | | export const initNetwork = (data: any) => { |
| | |
| | | url: "/data/api-v/sysinit/initNetwork", |
| | | method: "post", |
| | | data |
| | | }); |
| | | }; |
| | | }) |
| | | } |
| | | |
| | | //保存注册信息 |
| | | export const saveRegInfo = (data: any) => { |
| | | return request({ |
| | | url: "/data/api-v/sysinit/saveRegInfo" , |
| | | url: "/data/api-v/sysinit/saveRegInfo", |
| | | method: "post", |
| | | data |
| | | }); |
| | | }; |
| | | }) |
| | | } |
| | | |
| | | export const getList = (query: any) => { |
| | | return request({ |
| | | url: "/data/api-v/gb28181/findAreaByParentId", |
| | | method: "get", |
| | | params: query |
| | | }); |
| | | }; |
| | | }) |
| | | } |
| | | |
| | | export const isOnNet = (query: any) => { |
| | | return request({ |
| | | url: "http://apps.smartai.com/data/api-u/user/login", |
| | | method: "get", |
| | | params: query |
| | | }); |
| | | }; |
| | | }) |
| | | } |
| | | |
| | | // 登录 |
| | | export const tologin = (query: any) => { |
| | | // let query = 'username=' + user.loginName + '&password=' + user.password |
| | | return request({ |
| | | url: "/data/api-u/sys/login", |
| | | method: "post", |
| | | data: qs.stringify(query) |
| | | }) |
| | | } |
| | | |
| | | // 退出 |
| | | export const logout = () => { |
| | | return request({ |
| | | url: "/data/api-u/sys/logout", |
| | | method: "get" |
| | | }) |
| | | } |
| | | |
| | | // 获取用户信息 |
| | | // export const getLoginUserData = () => { |
| | | // let token = |
| | | // sessionStorage.getItem('loginedInfo') && |
| | | // JSON.parse(sessionStorage.getItem('loginedInfo')).access_token |
| | | // return request({ |
| | | // url: '/data/api-u/users/current', |
| | | // method: 'get', |
| | | // headers: { |
| | | // 'Content-Type': 'application/x-www-form-urlencoded', |
| | | // Authorization: token || '' |
| | | // } |
| | | // }) |
| | | // } |
| | | |
| | | export const getLoginUserData = () => { |
| | | let token = sessionStorage.getItem("loginedInfo") && JSON.parse(sessionStorage.getItem("loginedInfo")).access_token |
| | | return request({ |
| | | url: "/data/api-u/users/profile", |
| | | method: "get", |
| | | headers: { |
| | | "Content-Type": "application/x-www-form-urlencoded", |
| | | Authorization: token || "" |
| | | } |
| | | }) |
| | | } |
| | | |
| | | //修改密码 |
| | | export const updatePwd = (query: any) => { |
| | | return request({ |
| | | url: "/data/api-u/users/updatePwd", |
| | | method: "post", |
| | | data: qs.stringify(query) |
| | | }) |
| | | } |
| | | |
| | | //获取项目名称 |
| | | export const getServerName = (query: any) => { |
| | | return request({ |
| | | url: "/data/api-v/info/getServerName", |
| | | method: "get" |
| | | }) |
| | | } |
| | |
| | | const menu = getUrlKey("menu") |
| | | if (menu) { |
| | | this.showWelcome = false |
| | | this.activeIndex = this.menuArr.findIndex((x) => x.name == menu) |
| | | this.activeIndex = menu |
| | | this.$nextTick(() => { |
| | | this.$refs.view_3.openRight(2) |
| | | this.$refs[menu].openRight(2) |
| | | }) |
| | | } |
| | | this.fetchUserList() |