merge: merge changes in BaaS

This commit is contained in:
Frank.R.Wu 2021-06-15 21:52:53 +08:00
parent 4379b1745e
commit 43b79ffffc
3 changed files with 453 additions and 243 deletions

173
BaaSClient.html Normal file
View File

@ -0,0 +1,173 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Cache-Control" content="no-cache" />
<title>数瑞客户端</title>
<script src="./js/createWS.js"></script>
<script src="./js/cryptico.js"></script>
<script src="./js/jquery-2.1.4.js"></script>
<script src="./js/bootstrap.min.js"></script>
<script src="./js/commonutil.js"></script>
<link href="./css/common.css" rel="stylesheet">
<link href="./css/bootstrap.min.css" rel="stylesheet">
<script src="./js/vue.js"></script>
<script src="./js/bdwareclient.js"></script>
<script src="./js/sm2.js"></script>
</head>
<body>
<header
class="headerFooter navbar navbar-default navbar-fixed-top navColor ">
<div class="col-10">
<div class="input-group">
<a class="navbar-brand" href="#"> <img alt="Brand"
src="./img/logo-1.png" style="height: 30px">
</a><a class="navbar-brand">数瑞浏览器&nbsp;&nbsp; </a> <input id="urlInput"
type="text" class="form-control" placeholder="输入地址" style="display: none;">
<button class="btn btn-outline-secondary" type="button"
onclick="connectNode()" style="display: none;">GO</button>
<button class="btn btn-outline-secondary" id="switchRenderBtn" type="button"
onclick="changeRender()" style="height: 80%; margin-top: 0.4%;">不加载界面</button>
<span>&nbsp;&nbsp;&nbsp;</span>
<div class="input-group-append" style="display: none;">
<select id="selectContract" class="custom-select"
style="-webkit-appearance: none" onchange="changeApp()">
<option selected>选择合约</option>
</select>
</div>
</div>
</div>
<div class=" nav navbar-right userName" data-toggle="modal"
data-target="#pubkeyDialog">欢迎, {{shortName}}</div>
</header>
<div id="main">
<div class="row h-100" id="mainDiv"></div>
</div>
<!-- 用于配置sm2密钥的对话框 -->
<div class="modal fade" id="pubkeyDialog" tabindex="-1" role="dialog"
aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">用户信息</h5>
<button type="button" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="row" style="padding-left: 16px; padding-right: 16px">
<div class="input-group mb-3">
<div class="input-group-prepend">
<label class="input-group-text" for="localKeyList">本地公钥</label>
</div>
<select class="custom-select"
aria-label="Example select with button addon"
style="appearance: none" v-model="selectedSM2Key"
@change="changeSM2Key($event)">
<option v-for="(item,index) in sm2KeyList" :key="index"
:value='item.id'>{{item.title}}</option>
</select>
<div class="input-group-append">
<button class="btn btn-outline-primary" for="localKeyList"
v-on:click="exportPubkey">导出公钥</button>
</div>
<div class="input-group-append">
<button class="btn btn-outline-danger" for="localKeyList"
v-on:click="deletePubkey">删除公钥</button>
</div>
</div>
</div>
<div class="row" style="padding-left: 16px; padding-right: 16px">
<div class="input-group mb-1">
<div class="input-group-prepend">
<label class="input-group-text" for="localKeyList">当前SM2密钥</label>
</div>
<input type="text" class="form-control" placeholder="(请复制并妥善保存)"
disabled="disabled" aria-label=""
aria-describedby="basic-addon1">
<div class="input-group-append">
<button type="button" class="btn btn-outline-primary"
id="generatePubkeyBtn" v-on:click="generatePubkey">生成新公钥</button>
<button type="button" class="btn btn-outline-primary"
data-dismiss="modal" id="importPubkeyBtn"
v-on:click="importPubkey">导入公钥</button>
</div>
</div>
</div>
<textarea class="form-control mb-3" title="复制密钥,并妥善保存"
id="sm2KeyTextarea" v-model="sm2KeyStr"
style="width: 100%; min-height: 150px" rows="" cols="">
</textarea>
<div class="row" style="padding-left: 16px; padding-right: 16px;">
</div>
<div class="row" style="padding-left: 16px; padding-right: 16px">
<span>我的权限:{{myRole}}</span>
</div>
<div class="input-group">
<select id="inputGroupSelect04" v-model="test"
class="custom-select" style="appearance: none"
@change="changeProduct($event)">
<option v-for="(item,index) in productList" :key="index"
:value='item.id'>{{item.title}}</option>
</select>
<div class="input-group-append">
<button class="btn btn-outline-primary" type="button"
v-on:click="applyRole">角色认证</button>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal fade" id="dialog" tabindex="-1" role="dialog"
aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="dialogTitleH5">Modal title</h5>
<button type="button" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body" id="dialogBodyDiv">...</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-secondary"
data-dismiss="modal">关闭
</button>
<button type="button" id="dialogConfimBtn"
class="btn btn-outline-primary" data-dismiss="modal">确定
</button>
</div>
</div>
</div>
</div>
<script>
var h = document.body.clientHeight
- $("header").css("height").replace("px", "")
$("#main").css("height", h + "px");
init();
//initWSocket();
</script>
</body>
</html>

View File

@ -248,14 +248,14 @@ function showContractResult(requestID) {
result = data; result = data;
$("#statusSpan")[0].innerHTML = result.status; $("#statusSpan")[0].innerHTML = result.status;
$("#timeSpan")[0].innerHTML = "调用耗时:" + data.executeTime + "(ms)"; $("#timeSpan")[0].innerHTML = "调用耗时:" + data.executeTime + "(ms)";
if (result.result instanceof Object){ if (result.result instanceof Object) {
$("#responseArea")[0].value = JSON.stringify(result.result); $("#responseArea")[0].value = JSON.stringify(result.result);
$("#timeSpan")[0].innerHTML +="<br> JSON格式"; $("#timeSpan")[0].innerHTML += "<br> JSON格式";
}else{ } else {
$("#timeSpan")[0].innerHTML +="<br> 字符串格式"; $("#timeSpan")[0].innerHTML += "<br> 字符串格式";
$("#responseArea")[0].value = result.result; $("#responseArea")[0].value = result.result;
} }
if (global.responseCollector[requestID].hashCode!=undefined) if (global.responseCollector[requestID].hashCode != undefined)
$("#hashDisplayDiv").html("溯源指纹:" + global.responseCollector[requestID].hashCode); $("#hashDisplayDiv").html("溯源指纹:" + global.responseCollector[requestID].hashCode);
} }
@ -344,7 +344,7 @@ function onGetNodeSessionID(data) {
global.session = data.session; global.session = data.session;
const loginParam = { const loginParam = {
pubKey: global.sm2Key.publicKey, pubKey: global.sm2Key.publicKey,
signature: sm2.doSignature(global.session, global.sm2Key.privateKey,{hash:true,der:true}), signature: sm2.doSignature(global.session, global.sm2Key.privateKey, {hash: true, der: true}),
action: "login" action: "login"
}; };
global.wssocket.send(JSON.stringify(loginParam)); global.wssocket.send(JSON.stringify(loginParam));
@ -450,8 +450,8 @@ function triggerExecuteCurrentContract() {
return; return;
} }
var funNode; var funNode;
for(var i = 0;i < global.currentContract.exportedFunctions.length;i++){ for (var i = 0; i < global.currentContract.exportedFunctions.length; i++) {
if(global.currentContract.exportedFunctions[i].functionName == funPos){ if (global.currentContract.exportedFunctions[i].functionName == funPos) {
funNode = global.currentContract.exportedFunctions[i]; funNode = global.currentContract.exportedFunctions[i];
break; break;
} }
@ -466,7 +466,7 @@ function triggerExecuteCurrentContract() {
+ "&pubkey=" + global.sm2Key.publicKey + "&signature="; + "&pubkey=" + global.sm2Key.publicKey + "&signature=";
const toSign = global.currentContract.name + "|" + funNode.functionName + "|" const toSign = global.currentContract.name + "|" + funNode.functionName + "|"
+ argInput[0].value + "|" + global.sm2Key.publicKey; + argInput[0].value + "|" + global.sm2Key.publicKey;
const signature = sm2.doSignature(toSign, global.sm2Key.privateKey,{hash:true,der:true}); const signature = sm2.doSignature(toSign, global.sm2Key.privateKey, {hash: true, der: true});
let urlPre = $("#urlInput")[0].value; let urlPre = $("#urlInput")[0].value;
if (urlPre.startsWith("ws")) { if (urlPre.startsWith("ws")) {
urlPre = urlPre.replace("ws", "http"); urlPre = urlPre.replace("ws", "http");
@ -480,8 +480,8 @@ function showDescription() {
console.log(funPos); console.log(funPos);
console.log(global.currentContract.exportedFunctions); console.log(global.currentContract.exportedFunctions);
var funNode; var funNode;
for(var i = 0;i < global.currentContract.exportedFunctions.length;i++){ for (var i = 0; i < global.currentContract.exportedFunctions.length; i++) {
if(global.currentContract.exportedFunctions[i].functionName == funPos){ if (global.currentContract.exportedFunctions[i].functionName == funPos) {
funNode = global.currentContract.exportedFunctions[i]; funNode = global.currentContract.exportedFunctions[i];
break; break;
} }
@ -496,8 +496,8 @@ function showDescription() {
} }
function fillResultInternal(result, data) { function fillResultInternal(result, data) {
if (global.responseCollector[data.responseID]==undefined){ if (global.responseCollector[data.responseID] == undefined) {
global.responseCollector[data.responseID]=[]; global.responseCollector[data.responseID] = [];
const reqIDSpan = $("#reqIDSpan"); const reqIDSpan = $("#reqIDSpan");
reqIDSpan.append("<option value='" + data.responseID + "'>" + data.responseID + "</option>"); reqIDSpan.append("<option value='" + data.responseID + "'>" + data.responseID + "</option>");
reqIDSpan[0].value = data.responseID; reqIDSpan[0].value = data.responseID;
@ -505,11 +505,11 @@ function fillResultInternal(result, data) {
global.responseCollector[data.responseID].push(data); global.responseCollector[data.responseID].push(data);
$("#statusSpan")[0].innerHTML = result.status; $("#statusSpan")[0].innerHTML = result.status;
$("#timeSpan")[0].innerHTML = "调用耗时:" + data.executeTime + "(ms)"; $("#timeSpan")[0].innerHTML = "调用耗时:" + data.executeTime + "(ms)";
if (result.result instanceof Object){ if (result.result instanceof Object) {
$("#responseArea")[0].value = JSON.stringify(result.result); $("#responseArea")[0].value = JSON.stringify(result.result);
$("#timeSpan")[0].innerHTML +="<br> JSON格式"; $("#timeSpan")[0].innerHTML += "<br> JSON格式";
}else{ } else {
$("#timeSpan")[0].innerHTML +="<br> 字符串格式"; $("#timeSpan")[0].innerHTML += "<br> 字符串格式";
$("#responseArea")[0].value = result.result; $("#responseArea")[0].value = result.result;
} }
} }
@ -531,7 +531,7 @@ function loadMain(data) {
global.scriptList = []; global.scriptList = [];
global.scriptOrder = 0; global.scriptOrder = 0;
console.log("listSize:" + scriptList.length); console.log("listSize:" + scriptList.length);
for (var i=0;i<scriptList.length;i++) { for (var i = 0; i < scriptList.length; i++) {
const script = scriptList[i]; const script = scriptList[i];
const re = script.getAttribute("fromContract"); const re = script.getAttribute("fromContract");
if (!re) { if (!re) {
@ -543,7 +543,7 @@ function loadMain(data) {
executeCurrentContract("loadResource", global.scriptList[0], loadScript); executeCurrentContract("loadResource", global.scriptList[0], loadScript);
} }
const linkList = $("#mainDiv link"); const linkList = $("#mainDiv link");
for (var i=0; i<linkList.length;i++) { for (var i = 0; i < linkList.length; i++) {
const link = linkList[i]; const link = linkList[i];
const re = link.getAttribute("fromContract"); const re = link.getAttribute("fromContract");
executeCurrentContract("loadResource", re, loadCss); executeCurrentContract("loadResource", re, loadCss);
@ -723,10 +723,9 @@ function killAllContract() {
} }
function init() { function init() {
const urlParams = getRequestParameters();
initVue(); initVue();
initGlobal(urlParams);
initGlobal();
global.urlparam = getRequestParameters();
if (global.urlparam["noRender"] === "true") { if (global.urlparam["noRender"] === "true") {
switchRenderBtn.innerHTML = "加载界面"; switchRenderBtn.innerHTML = "加载界面";
@ -763,15 +762,39 @@ function connectNode() {
} }
function getRequestParameters() { function getRequestParameters() {
const arr = (location.search || "").replace(/^\?/, '').split("&"); if (location.href.indexOf("BaaSClient") !== -1) {
const params = {}; let params = location.href.replace(/[^#]*(#(\/)?|\?)/, '')
for (const a of arr) { let url = location.href.replace(params, '')
const data = a.split("="); while (!params) {
if (data.length === 2) { url = url.replace(/(#(\/)?|\?)$/, '')
params[data[0]] = data[1]; params = url.replace(/[^#]*(#(\/)?|\?)/, '')
url = url.replace(params, '')
} }
if (url.endsWith('#') || url.endsWith('#\/')) {
let sKey = Math.random().toString()
localStorage.setItem(sKey, params)
location.href = url.replace(/#(\/)?/, '?' + sKey)
} else {
let json = atob(localStorage.getItem(params))
try {
return JSON.parse(json);
} catch (e) {
localStorage.removeItem(params)
alert('链接失效!')
location.href = location.origin
}
}
} else {
const arr = (location.search || "").replace(/^\?/, '').split("&");
const params = {};
for (const a of arr) {
const data = a.split("=");
if (data.length === 2) {
params[data[0]] = data[1];
}
}
return params;
} }
return params;
} }
function changeRender() { function changeRender() {

View File

@ -1,229 +1,243 @@
var getDateDaysBefore = function(daysAgo) { var getDateDaysBefore = function (daysAgo) {
var dateStr = new Date().toISOString().substring(0, 10); var dateStr = new Date().toISOString().substring(0, 10);
var ret = new Date(dateStr).getTime() - daysAgo * 24 * 3600 * 1000; var ret = new Date(dateStr).getTime() - daysAgo * 24 * 3600 * 1000;
return ret; return ret;
}; };
var primaryColor = "#2E324C";
let primaryColor = "#2E324C";
// ======Vue start // ======Vue start
var headerVue = ""; var headerVue = "";
var pubkeyDialogVue = ""; var pubkeyDialogVue = "";
var mainVue = ""; var mainVue = "";
var select = ""; var select = "";
var initVue = function() { var initVue = function () {
console.log("[nodePortal.js] initVue : "); console.log("[nodePortal.js] initVue : ");
headerVue = new Vue({ headerVue = new Vue({
el : 'header', el: 'header',
data : { data: {
shortName : "00000" shortName: "00000"
} }
}); });
pubkeyDialogVue = new Vue({ pubkeyDialogVue = new Vue({
el : '#pubkeyDialog', el: '#pubkeyDialog',
data : { data: {
sm2KeyStr : "00000", sm2KeyStr: "00000",
myRole : "匿名用户", myRole: "匿名用户",
test:"0", test: "0",
selectedSM2Key:"0", selectedSM2Key: "0",
productList:[{id:0,title:"ContractProvider"},{id:1,title:"ContractUser"},{id:2,title:"ContractInstanceManager"}], productList: [{id: 0, title: "ContractProvider"}, {id: 1, title: "ContractUser"}, {
sm2KeyList:[] id: 2,
}, title: "ContractInstanceManager"
methods : { }],
importPubkey : function() { sm2KeyList: []
console.log("importkey trigged"); },
try { methods: {
var sm2Key = JSON.parse(this.sm2KeyStr); importPubkey: function () {
if (sm2Key.publicKey == undefined console.log("importkey trigged");
|| sm2Key.privateKey == undefined) { try {
this.sm2KeyStr = (JSON.stringify(global.sm2Key)); var sm2Key = JSON.parse(this.sm2KeyStr);
} else { if (sm2Key.publicKey == undefined
global.sm2Key = sm2Key; || sm2Key.privateKey == undefined) {
localStorage.setItem("PrivKey", JSON this.sm2KeyStr = (JSON.stringify(global.sm2Key));
.stringify(sm2Key)); } else {
headerVue.shortName = global.sm2Key.publicKey global.sm2Key = sm2Key;
.substr(0, 5); localStorage.setItem("PrivKey", JSON
var newKey = {}; .stringify(sm2Key));
newKey.id = this.sm2KeyList.length; headerVue.shortName = global.sm2Key.publicKey
newKey.title = headerVue.shortName; .substr(0, 5);
newKey.sm2Key = this.sm2KeyStr; var newKey = {};
this.sm2KeyList.push(newKey); newKey.id = this.sm2KeyList.length;
localStorage.setItem("PrivKeyList",JSON.stringify(this.sm2KeyList)); newKey.title = headerVue.shortName;
newKey.sm2Key = this.sm2KeyStr;
this.sm2KeyList.push(newKey);
localStorage.setItem("PrivKeyList", JSON.stringify(this.sm2KeyList));
getSession(); getSession();
listProjects("priv"); listProjects("priv");
} }
} catch (e) { } catch (e) {
console.log(e); console.log(e);
this.sm2KeyStr = (JSON.stringify(global.sm2Key)); this.sm2KeyStr = (JSON.stringify(global.sm2Key));
} }
}, },
generatePubkey : function() { generatePubkey: function () {
console.log("generate pubkey trigged"); console.log("generate pubkey trigged");
var sm2Key = sm2.generateKeyPairHex(); var sm2Key = sm2.generateKeyPairHex();
this.sm2KeyStr = JSON.stringify(sm2Key); this.sm2KeyStr = JSON.stringify(sm2Key);
global.sm2Key = sm2Key; global.sm2Key = sm2Key;
localStorage.setItem("PrivKey", JSON localStorage.setItem("PrivKey", JSON
.stringify(sm2Key)); .stringify(sm2Key));
headerVue.shortName = global.sm2Key.publicKey headerVue.shortName = global.sm2Key.publicKey
.substr(0, 5); .substr(0, 5);
var newKey = {}; var newKey = {};
newKey.id = this.sm2KeyList.length; newKey.id = this.sm2KeyList.length;
newKey.title = headerVue.shortName; newKey.title = headerVue.shortName;
newKey.sm2Key = this.sm2KeyStr; newKey.sm2Key = this.sm2KeyStr;
this.sm2KeyList.push(newKey); this.sm2KeyList.push(newKey);
this.selectedSM2Key = newKey.id; this.selectedSM2Key = newKey.id;
localStorage.setItem("PrivKeyList",JSON.stringify(this.sm2KeyList)); localStorage.setItem("PrivKeyList", JSON.stringify(this.sm2KeyList));
getSession(); getSession();
}, },
changeProduct(event) { changeProduct(event) {
this.test = event.target.value; // 获取option对应的value值 this.test = event.target.value; // 获取option对应的value值
this.role = this.productList[this.test].title; this.role = this.productList[this.test].title;
console.log("选了",this.role); console.log("选了", this.role);
global.role=this.role; global.role = this.role;
}, },
apply : function() { apply: function () {
console.log("apply"); console.log("apply");
global.wssocket global.wssocket
.send("{\"action\":\"applyNet\",\"role\":\"NodeManager\"}"); .send("{\"action\":\"applyNet\",\"role\":\"NodeManager\"}");
}, },
applyRole : function() { applyRole: function () {
var role=this.productList[this.test]; var role = this.productList[this.test];
console.log("applyRole, "+role); console.log("applyRole, " + role);
applyRole(role.title); applyRole(role.title);
},changeSM2Key:function(event){ }, changeSM2Key: function (event) {
var order = event.target.value; // 获取option对应的value值 var order = event.target.value; // 获取option对应的value值
if (order == undefined) if (order == undefined)
return; return;
console.log("changeSM2Key, -->"+order); console.log("changeSM2Key, -->" + order);
headerVue.shortName = this.sm2KeyList[order].title; headerVue.shortName = this.sm2KeyList[order].title;
this.selectedSM2Key = order; this.selectedSM2Key = order;
this.sm2KeyStr = this.sm2KeyList[order].sm2Key; this.sm2KeyStr = this.sm2KeyList[order].sm2Key;
global.sm2Key = JSON.parse(this.sm2KeyStr); global.sm2Key = JSON.parse(this.sm2KeyStr);
localStorage.setItem("PrivKey", this.sm2KeyStr); localStorage.setItem("PrivKey", this.sm2KeyStr);
getSession(); getSession();
},deletePubkey:function(event){ }, deletePubkey: function (event) {
var order = this.selectedSM2Key; var order = this.selectedSM2Key;
var obj = this.sm2KeyList[order]; var obj = this.sm2KeyList[order];
if (this.sm2KeyList.length==1){ if (this.sm2KeyList.length == 1) {
alert("最后一对密钥不可以删除"); alert("最后一对密钥不可以删除");
return; return;
} }
var newList = []; var newList = [];
for (var i=0;i<order;i++){ for (var i = 0; i < order; i++) {
newList.push(this.sm2KeyList[i]); newList.push(this.sm2KeyList[i]);
}; }
for (var i=order/1 +1;i<this.sm2KeyList.length;i++){ ;
newList.push(this.sm2KeyList[i]); for (var i = order / 1 + 1; i < this.sm2KeyList.length; i++) {
}; newList.push(this.sm2KeyList[i]);
this.sm2KeyList = newList; }
for (var i=0;i<newList.length;i++){ ;
newList[i].id = i; this.sm2KeyList = newList;
} for (var i = 0; i < newList.length; i++) {
if (order>=newList.length){ newList[i].id = i;
order --; }
} if (order >= newList.length) {
console.log("after delete, size:"+newList.length+" order:"+order); order--;
localStorage.setItem("PrivKeyList", JSON.stringify(newList)); }
headerVue.shortName = this.sm2KeyList[order].title; console.log("after delete, size:" + newList.length + " order:" + order);
this.selectedSM2Key = order + ""; localStorage.setItem("PrivKeyList", JSON.stringify(newList));
this.sm2KeyStr = this.sm2KeyList[order].sm2Key; headerVue.shortName = this.sm2KeyList[order].title;
global.sm2Key = JSON.parse(this.sm2KeyStr); this.selectedSM2Key = order + "";
localStorage.setItem("PrivKey", this.sm2KeyStr); this.sm2KeyStr = this.sm2KeyList[order].sm2Key;
getSession(); global.sm2Key = JSON.parse(this.sm2KeyStr);
},exportPubkey : function(event){ localStorage.setItem("PrivKey", this.sm2KeyStr);
var uri = "data:text/html,"; getSession();
uri+=localStorage.getItem("PrivKeyList"); }, exportPubkey: function (event) {
var link = document.createElement("a"); var uri = "data:text/html,";
link.download = "sm2keyList.json"; uri += localStorage.getItem("PrivKeyList");
link.href = uri; var link = document.createElement("a");
document.body.appendChild(link); link.download = "sm2keyList.json";
link.click(); link.href = uri;
document.body.removeChild(link); document.body.appendChild(link);
delete link; link.click();
document.body.removeChild(link);
} delete link;
} }
});
mainVue = new Vue({ }
el : "#main", });
data : {
licenceDueDate : "已过期", mainVue = new Vue({
licenceNodes : 0, el: "#main",
offlineLicence : undefined, data: {
licenceRemark : undefined, licenceDueDate: "已过期",
userCount:".", licenceNodes: 0,
contractCount:".", offlineLicence: undefined,
nodeCount:".", licenceRemark: undefined,
eventCount:".", userCount: ".",
unitCount:".", contractCount: ".",
pubDialogVue:{}, nodeCount: ".",
projects:[], eventCount: ".",
contracts:[], unitCount: ".",
contractFunctions:[], pubDialogVue: {},
openedFiles:[{ projects: [],
isDir: false, contracts: [],
val: "Please Checkout code from left side!", contractFunctions: [],
path: "Hello", openedFiles: [{
name: "Hello" isDir: false,
}] val: "Please Checkout code from left side!",
path: "Hello",
name: "Hello"
}]
}
});
}
});
}; };
// ======Vue done // ======Vue done
var initGlobal = function() { var initGlobal = function (urlParams) {
if (window.global==undefined){ if (!window.global) {
window.global = {}; window.global = {};
} }
global.sm2Key = localStorage.getItem("PrivKey"); global.result = "";
global.result = ""; if (location.href.indexOf("BaaSClient") !== -1) {
if (global.sm2Key == undefined || global.sm2Key == null global.isBaaS = true
|| global.sm2Key.length < 100) { primaryColor = '#08263a'
generate(); }
} else { if (urlParams && urlParams.keys) {
global.sm2Key = JSON.parse(global.sm2Key); global.urlparam = urlParams;
} global.sm2Key = urlParams.keys
headerVue.shortName = global.sm2Key.publicKey.substr(0, 5); } else {
pubkeyDialogVue.sm2KeyStr = JSON.stringify(global.sm2Key); global.sm2Key = localStorage.getItem("PrivKey");
mainVue.pubDialogVue = pubkeyDialogVue; if (!global.sm2Key || global.sm2Key.length < 100) {
var keyListStr = localStorage.getItem("PrivKeyList"); generate();
if (keyListStr==undefined){ } else {
var keyObj = {}; global.sm2Key = JSON.parse(global.sm2Key);
keyObj.id = 0; }
keyObj.title = headerVue.shortName; }
keyObj.sm2Key = pubkeyDialogVue.sm2KeyStr; headerVue.shortName = global.sm2Key.publicKey.substr(0, 5);
pubkeyDialogVue.sm2KeyList = []; pubkeyDialogVue.sm2KeyStr = JSON.stringify(global.sm2Key);
pubkeyDialogVue.sm2KeyList.push(keyObj); mainVue.pubDialogVue = pubkeyDialogVue;
pubkeyDialogVue.selectedSM2Key = 0; var keyListStr = localStorage.getItem("PrivKeyList");
// mainVue.sm2KeyList = pubkeyDialogVue.sm2KeyList; if (keyListStr == undefined) {
// mainVue.selectedSM2Key = 0; var keyObj = {};
} else{ keyObj.id = 0;
pubkeyDialogVue.sm2KeyList = JSON.parse(keyListStr); keyObj.title = headerVue.shortName;
pubkeyDialogVue.selectedSM2Key = -1; keyObj.sm2Key = pubkeyDialogVue.sm2KeyStr;
for (var i=0;i<pubkeyDialogVue.sm2KeyList.length;i++){ pubkeyDialogVue.sm2KeyList = [];
var obj = pubkeyDialogVue.sm2KeyList[i]; pubkeyDialogVue.sm2KeyList.push(keyObj);
if (obj.sm2Key==pubkeyDialogVue.sm2KeyStr){ pubkeyDialogVue.selectedSM2Key = 0;
pubkeyDialogVue.selectedSM2Key = i; // mainVue.sm2KeyList = pubkeyDialogVue.sm2KeyList;
// mainVue.sm2KeyList = pubkeyDialogVue.sm2KeyList; // mainVue.selectedSM2Key = 0;
// mainVue.selectedSM2Key = pubkeyDialogVue.selectedSM2Key; } else {
return; pubkeyDialogVue.sm2KeyList = JSON.parse(keyListStr);
} pubkeyDialogVue.selectedSM2Key = -1;
} for (var i = 0; i < pubkeyDialogVue.sm2KeyList.length; i++) {
var keyObj = {}; var obj = pubkeyDialogVue.sm2KeyList[i];
keyObj.id = pubkeyDialogVue.sm2KeyList.length; if (obj.sm2Key == pubkeyDialogVue.sm2KeyStr) {
keyObj.title = headerVue.shortName; pubkeyDialogVue.selectedSM2Key = i;
keyObj.sm2Key = pubkeyDialogVue.sm2KeyStr; // mainVue.sm2KeyList = pubkeyDialogVue.sm2KeyList;
pubkeyDialogVue.sm2KeyList.push(keyObj); // mainVue.selectedSM2Key = pubkeyDialogVue.selectedSM2Key;
pubkeyDialogVue.selectedSM2Key = keyObj.id; return;
// mainVue.sm2KeyList = pubkeyDialogVue.sm2KeyList; }
// mainVue.selectedSM2Key = pubkeyDialogVue.selectedSM2Key; }
var keyObj = {};
keyObj.id = pubkeyDialogVue.sm2KeyList.length;
keyObj.title = headerVue.shortName;
keyObj.sm2Key = pubkeyDialogVue.sm2KeyStr;
pubkeyDialogVue.sm2KeyList.push(keyObj);
pubkeyDialogVue.selectedSM2Key = keyObj.id;
// mainVue.sm2KeyList = pubkeyDialogVue.sm2KeyList;
// mainVue.selectedSM2Key = pubkeyDialogVue.selectedSM2Key;
} }
} }