From c0c034b3ef0fdf0fd9c802d5984dbd717db6817a Mon Sep 17 00:00:00 2001 From: zhangzengfei <zhangzengfei@smartai.com> Date: 星期三, 06 九月 2023 17:54:55 +0800 Subject: [PATCH] 定制桌面. --- src/pages/index/App.vue | 127 +++++++++++------------------------------- 1 files changed, 33 insertions(+), 94 deletions(-) diff --git a/src/pages/index/App.vue b/src/pages/index/App.vue index 6a976e0..9a4d3bc 100644 --- a/src/pages/index/App.vue +++ b/src/pages/index/App.vue @@ -39,7 +39,8 @@ 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", @@ -60,107 +61,45 @@ } }, mounted() { - location.assign("/view/desktop/") - return - - this.getInitInfo() - let message = "缃戠粶姝e父" - - 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)) - // 濡傛灉缃戠粶姝e父, 鐩存帴璺宠繃 - 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) - - // 濡傛灉缃戠粶姝e父, 鐩存帴璺冲埌绗笁閮� - 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 } } } -- Gitblit v1.8.0