merge: merge changes in BaaS
This commit is contained in:
@@ -248,14 +248,14 @@ function showContractResult(requestID) {
|
||||
result = data;
|
||||
$("#statusSpan")[0].innerHTML = result.status;
|
||||
$("#timeSpan")[0].innerHTML = "调用耗时:" + data.executeTime + "(ms)";
|
||||
if (result.result instanceof Object){
|
||||
$("#responseArea")[0].value = JSON.stringify(result.result);
|
||||
$("#timeSpan")[0].innerHTML +="<br> JSON格式";
|
||||
}else{
|
||||
$("#timeSpan")[0].innerHTML +="<br> 字符串格式";
|
||||
$("#responseArea")[0].value = result.result;
|
||||
if (result.result instanceof Object) {
|
||||
$("#responseArea")[0].value = JSON.stringify(result.result);
|
||||
$("#timeSpan")[0].innerHTML += "<br> JSON格式";
|
||||
} else {
|
||||
$("#timeSpan")[0].innerHTML += "<br> 字符串格式";
|
||||
$("#responseArea")[0].value = result.result;
|
||||
}
|
||||
if (global.responseCollector[requestID].hashCode!=undefined)
|
||||
if (global.responseCollector[requestID].hashCode != undefined)
|
||||
$("#hashDisplayDiv").html("溯源指纹:" + global.responseCollector[requestID].hashCode);
|
||||
}
|
||||
|
||||
@@ -344,7 +344,7 @@ function onGetNodeSessionID(data) {
|
||||
global.session = data.session;
|
||||
const loginParam = {
|
||||
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"
|
||||
};
|
||||
global.wssocket.send(JSON.stringify(loginParam));
|
||||
@@ -450,8 +450,8 @@ function triggerExecuteCurrentContract() {
|
||||
return;
|
||||
}
|
||||
var funNode;
|
||||
for(var i = 0;i < global.currentContract.exportedFunctions.length;i++){
|
||||
if(global.currentContract.exportedFunctions[i].functionName == funPos){
|
||||
for (var i = 0; i < global.currentContract.exportedFunctions.length; i++) {
|
||||
if (global.currentContract.exportedFunctions[i].functionName == funPos) {
|
||||
funNode = global.currentContract.exportedFunctions[i];
|
||||
break;
|
||||
}
|
||||
@@ -466,7 +466,7 @@ function triggerExecuteCurrentContract() {
|
||||
+ "&pubkey=" + global.sm2Key.publicKey + "&signature=";
|
||||
const toSign = global.currentContract.name + "|" + funNode.functionName + "|"
|
||||
+ 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;
|
||||
if (urlPre.startsWith("ws")) {
|
||||
urlPre = urlPre.replace("ws", "http");
|
||||
@@ -480,8 +480,8 @@ function showDescription() {
|
||||
console.log(funPos);
|
||||
console.log(global.currentContract.exportedFunctions);
|
||||
var funNode;
|
||||
for(var i = 0;i < global.currentContract.exportedFunctions.length;i++){
|
||||
if(global.currentContract.exportedFunctions[i].functionName == funPos){
|
||||
for (var i = 0; i < global.currentContract.exportedFunctions.length; i++) {
|
||||
if (global.currentContract.exportedFunctions[i].functionName == funPos) {
|
||||
funNode = global.currentContract.exportedFunctions[i];
|
||||
break;
|
||||
}
|
||||
@@ -496,8 +496,8 @@ function showDescription() {
|
||||
}
|
||||
|
||||
function fillResultInternal(result, data) {
|
||||
if (global.responseCollector[data.responseID]==undefined){
|
||||
global.responseCollector[data.responseID]=[];
|
||||
if (global.responseCollector[data.responseID] == undefined) {
|
||||
global.responseCollector[data.responseID] = [];
|
||||
const reqIDSpan = $("#reqIDSpan");
|
||||
reqIDSpan.append("<option value='" + data.responseID + "'>" + data.responseID + "</option>");
|
||||
reqIDSpan[0].value = data.responseID;
|
||||
@@ -505,11 +505,11 @@ function fillResultInternal(result, data) {
|
||||
global.responseCollector[data.responseID].push(data);
|
||||
$("#statusSpan")[0].innerHTML = result.status;
|
||||
$("#timeSpan")[0].innerHTML = "调用耗时:" + data.executeTime + "(ms)";
|
||||
if (result.result instanceof Object){
|
||||
$("#responseArea")[0].value = JSON.stringify(result.result);
|
||||
$("#timeSpan")[0].innerHTML +="<br> JSON格式";
|
||||
}else{
|
||||
$("#timeSpan")[0].innerHTML +="<br> 字符串格式";
|
||||
if (result.result instanceof Object) {
|
||||
$("#responseArea")[0].value = JSON.stringify(result.result);
|
||||
$("#timeSpan")[0].innerHTML += "<br> JSON格式";
|
||||
} else {
|
||||
$("#timeSpan")[0].innerHTML += "<br> 字符串格式";
|
||||
$("#responseArea")[0].value = result.result;
|
||||
}
|
||||
}
|
||||
@@ -531,7 +531,7 @@ function loadMain(data) {
|
||||
global.scriptList = [];
|
||||
global.scriptOrder = 0;
|
||||
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 re = script.getAttribute("fromContract");
|
||||
if (!re) {
|
||||
@@ -543,7 +543,7 @@ function loadMain(data) {
|
||||
executeCurrentContract("loadResource", global.scriptList[0], loadScript);
|
||||
}
|
||||
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 re = link.getAttribute("fromContract");
|
||||
executeCurrentContract("loadResource", re, loadCss);
|
||||
@@ -723,10 +723,9 @@ function killAllContract() {
|
||||
}
|
||||
|
||||
function init() {
|
||||
const urlParams = getRequestParameters();
|
||||
initVue();
|
||||
|
||||
initGlobal();
|
||||
global.urlparam = getRequestParameters();
|
||||
initGlobal(urlParams);
|
||||
|
||||
if (global.urlparam["noRender"] === "true") {
|
||||
switchRenderBtn.innerHTML = "加载界面";
|
||||
@@ -763,15 +762,39 @@ function connectNode() {
|
||||
}
|
||||
|
||||
function getRequestParameters() {
|
||||
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];
|
||||
if (location.href.indexOf("BaaSClient") !== -1) {
|
||||
let params = location.href.replace(/[^#]*(#(\/)?|\?)/, '')
|
||||
let url = location.href.replace(params, '')
|
||||
while (!params) {
|
||||
url = url.replace(/(#(\/)?|\?)$/, '')
|
||||
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() {
|
||||
|
||||
436
js/commonutil.js
436
js/commonutil.js
@@ -1,229 +1,243 @@
|
||||
var getDateDaysBefore = function(daysAgo) {
|
||||
var dateStr = new Date().toISOString().substring(0, 10);
|
||||
var ret = new Date(dateStr).getTime() - daysAgo * 24 * 3600 * 1000;
|
||||
return ret;
|
||||
var getDateDaysBefore = function (daysAgo) {
|
||||
var dateStr = new Date().toISOString().substring(0, 10);
|
||||
var ret = new Date(dateStr).getTime() - daysAgo * 24 * 3600 * 1000;
|
||||
return ret;
|
||||
};
|
||||
var primaryColor = "#2E324C";
|
||||
|
||||
let primaryColor = "#2E324C";
|
||||
|
||||
// ======Vue start
|
||||
var headerVue = "";
|
||||
var pubkeyDialogVue = "";
|
||||
var mainVue = "";
|
||||
|
||||
|
||||
var select = "";
|
||||
var initVue = function() {
|
||||
console.log("[nodePortal.js] initVue : ");
|
||||
headerVue = new Vue({
|
||||
el : 'header',
|
||||
data : {
|
||||
shortName : "00000"
|
||||
}
|
||||
});
|
||||
pubkeyDialogVue = new Vue({
|
||||
el : '#pubkeyDialog',
|
||||
data : {
|
||||
sm2KeyStr : "00000",
|
||||
myRole : "匿名用户",
|
||||
test:"0",
|
||||
selectedSM2Key:"0",
|
||||
productList:[{id:0,title:"ContractProvider"},{id:1,title:"ContractUser"},{id:2,title:"ContractInstanceManager"}],
|
||||
sm2KeyList:[]
|
||||
},
|
||||
methods : {
|
||||
importPubkey : function() {
|
||||
console.log("importkey trigged");
|
||||
try {
|
||||
var sm2Key = JSON.parse(this.sm2KeyStr);
|
||||
if (sm2Key.publicKey == undefined
|
||||
|| sm2Key.privateKey == undefined) {
|
||||
this.sm2KeyStr = (JSON.stringify(global.sm2Key));
|
||||
} else {
|
||||
global.sm2Key = sm2Key;
|
||||
localStorage.setItem("PrivKey", JSON
|
||||
.stringify(sm2Key));
|
||||
headerVue.shortName = global.sm2Key.publicKey
|
||||
.substr(0, 5);
|
||||
var newKey = {};
|
||||
newKey.id = this.sm2KeyList.length;
|
||||
newKey.title = headerVue.shortName;
|
||||
newKey.sm2Key = this.sm2KeyStr;
|
||||
this.sm2KeyList.push(newKey);
|
||||
localStorage.setItem("PrivKeyList",JSON.stringify(this.sm2KeyList));
|
||||
var initVue = function () {
|
||||
console.log("[nodePortal.js] initVue : ");
|
||||
headerVue = new Vue({
|
||||
el: 'header',
|
||||
data: {
|
||||
shortName: "00000"
|
||||
}
|
||||
});
|
||||
pubkeyDialogVue = new Vue({
|
||||
el: '#pubkeyDialog',
|
||||
data: {
|
||||
sm2KeyStr: "00000",
|
||||
myRole: "匿名用户",
|
||||
test: "0",
|
||||
selectedSM2Key: "0",
|
||||
productList: [{id: 0, title: "ContractProvider"}, {id: 1, title: "ContractUser"}, {
|
||||
id: 2,
|
||||
title: "ContractInstanceManager"
|
||||
}],
|
||||
sm2KeyList: []
|
||||
},
|
||||
methods: {
|
||||
importPubkey: function () {
|
||||
console.log("importkey trigged");
|
||||
try {
|
||||
var sm2Key = JSON.parse(this.sm2KeyStr);
|
||||
if (sm2Key.publicKey == undefined
|
||||
|| sm2Key.privateKey == undefined) {
|
||||
this.sm2KeyStr = (JSON.stringify(global.sm2Key));
|
||||
} else {
|
||||
global.sm2Key = sm2Key;
|
||||
localStorage.setItem("PrivKey", JSON
|
||||
.stringify(sm2Key));
|
||||
headerVue.shortName = global.sm2Key.publicKey
|
||||
.substr(0, 5);
|
||||
var newKey = {};
|
||||
newKey.id = this.sm2KeyList.length;
|
||||
newKey.title = headerVue.shortName;
|
||||
newKey.sm2Key = this.sm2KeyStr;
|
||||
this.sm2KeyList.push(newKey);
|
||||
localStorage.setItem("PrivKeyList", JSON.stringify(this.sm2KeyList));
|
||||
|
||||
getSession();
|
||||
listProjects("priv");
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
this.sm2KeyStr = (JSON.stringify(global.sm2Key));
|
||||
}
|
||||
},
|
||||
generatePubkey : function() {
|
||||
console.log("generate pubkey trigged");
|
||||
var sm2Key = sm2.generateKeyPairHex();
|
||||
this.sm2KeyStr = JSON.stringify(sm2Key);
|
||||
global.sm2Key = sm2Key;
|
||||
localStorage.setItem("PrivKey", JSON
|
||||
.stringify(sm2Key));
|
||||
headerVue.shortName = global.sm2Key.publicKey
|
||||
.substr(0, 5);
|
||||
var newKey = {};
|
||||
newKey.id = this.sm2KeyList.length;
|
||||
newKey.title = headerVue.shortName;
|
||||
newKey.sm2Key = this.sm2KeyStr;
|
||||
this.sm2KeyList.push(newKey);
|
||||
this.selectedSM2Key = newKey.id;
|
||||
localStorage.setItem("PrivKeyList",JSON.stringify(this.sm2KeyList));
|
||||
getSession();
|
||||
},
|
||||
changeProduct(event) {
|
||||
this.test = event.target.value; // 获取option对应的value值
|
||||
this.role = this.productList[this.test].title;
|
||||
console.log("选了",this.role);
|
||||
global.role=this.role;
|
||||
},
|
||||
apply : function() {
|
||||
console.log("apply");
|
||||
global.wssocket
|
||||
.send("{\"action\":\"applyNet\",\"role\":\"NodeManager\"}");
|
||||
getSession();
|
||||
listProjects("priv");
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
this.sm2KeyStr = (JSON.stringify(global.sm2Key));
|
||||
}
|
||||
},
|
||||
generatePubkey: function () {
|
||||
console.log("generate pubkey trigged");
|
||||
var sm2Key = sm2.generateKeyPairHex();
|
||||
this.sm2KeyStr = JSON.stringify(sm2Key);
|
||||
global.sm2Key = sm2Key;
|
||||
localStorage.setItem("PrivKey", JSON
|
||||
.stringify(sm2Key));
|
||||
headerVue.shortName = global.sm2Key.publicKey
|
||||
.substr(0, 5);
|
||||
var newKey = {};
|
||||
newKey.id = this.sm2KeyList.length;
|
||||
newKey.title = headerVue.shortName;
|
||||
newKey.sm2Key = this.sm2KeyStr;
|
||||
this.sm2KeyList.push(newKey);
|
||||
this.selectedSM2Key = newKey.id;
|
||||
localStorage.setItem("PrivKeyList", JSON.stringify(this.sm2KeyList));
|
||||
getSession();
|
||||
},
|
||||
changeProduct(event) {
|
||||
this.test = event.target.value; // 获取option对应的value值
|
||||
this.role = this.productList[this.test].title;
|
||||
console.log("选了", this.role);
|
||||
global.role = this.role;
|
||||
},
|
||||
apply: function () {
|
||||
console.log("apply");
|
||||
global.wssocket
|
||||
.send("{\"action\":\"applyNet\",\"role\":\"NodeManager\"}");
|
||||
|
||||
},
|
||||
applyRole : function() {
|
||||
var role=this.productList[this.test];
|
||||
console.log("applyRole, "+role);
|
||||
applyRole(role.title);
|
||||
},
|
||||
applyRole: function () {
|
||||
var role = this.productList[this.test];
|
||||
console.log("applyRole, " + role);
|
||||
applyRole(role.title);
|
||||
|
||||
},changeSM2Key:function(event){
|
||||
var order = event.target.value; // 获取option对应的value值
|
||||
if (order == undefined)
|
||||
return;
|
||||
console.log("changeSM2Key, -->"+order);
|
||||
headerVue.shortName = this.sm2KeyList[order].title;
|
||||
this.selectedSM2Key = order;
|
||||
this.sm2KeyStr = this.sm2KeyList[order].sm2Key;
|
||||
global.sm2Key = JSON.parse(this.sm2KeyStr);
|
||||
localStorage.setItem("PrivKey", this.sm2KeyStr);
|
||||
getSession();
|
||||
},deletePubkey:function(event){
|
||||
var order = this.selectedSM2Key;
|
||||
var obj = this.sm2KeyList[order];
|
||||
if (this.sm2KeyList.length==1){
|
||||
alert("最后一对密钥不可以删除");
|
||||
return;
|
||||
}
|
||||
var newList = [];
|
||||
for (var i=0;i<order;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;
|
||||
}
|
||||
if (order>=newList.length){
|
||||
order --;
|
||||
}
|
||||
console.log("after delete, size:"+newList.length+" order:"+order);
|
||||
localStorage.setItem("PrivKeyList", JSON.stringify(newList));
|
||||
headerVue.shortName = this.sm2KeyList[order].title;
|
||||
this.selectedSM2Key = order + "";
|
||||
this.sm2KeyStr = this.sm2KeyList[order].sm2Key;
|
||||
global.sm2Key = JSON.parse(this.sm2KeyStr);
|
||||
localStorage.setItem("PrivKey", this.sm2KeyStr);
|
||||
getSession();
|
||||
},exportPubkey : function(event){
|
||||
var uri = "data:text/html,";
|
||||
uri+=localStorage.getItem("PrivKeyList");
|
||||
var link = document.createElement("a");
|
||||
link.download = "sm2keyList.json";
|
||||
link.href = uri;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
delete link;
|
||||
|
||||
}
|
||||
}, changeSM2Key: function (event) {
|
||||
var order = event.target.value; // 获取option对应的value值
|
||||
if (order == undefined)
|
||||
return;
|
||||
console.log("changeSM2Key, -->" + order);
|
||||
headerVue.shortName = this.sm2KeyList[order].title;
|
||||
this.selectedSM2Key = order;
|
||||
this.sm2KeyStr = this.sm2KeyList[order].sm2Key;
|
||||
global.sm2Key = JSON.parse(this.sm2KeyStr);
|
||||
localStorage.setItem("PrivKey", this.sm2KeyStr);
|
||||
getSession();
|
||||
}, deletePubkey: function (event) {
|
||||
var order = this.selectedSM2Key;
|
||||
var obj = this.sm2KeyList[order];
|
||||
if (this.sm2KeyList.length == 1) {
|
||||
alert("最后一对密钥不可以删除");
|
||||
return;
|
||||
}
|
||||
var newList = [];
|
||||
for (var i = 0; i < order; 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;
|
||||
}
|
||||
if (order >= newList.length) {
|
||||
order--;
|
||||
}
|
||||
console.log("after delete, size:" + newList.length + " order:" + order);
|
||||
localStorage.setItem("PrivKeyList", JSON.stringify(newList));
|
||||
headerVue.shortName = this.sm2KeyList[order].title;
|
||||
this.selectedSM2Key = order + "";
|
||||
this.sm2KeyStr = this.sm2KeyList[order].sm2Key;
|
||||
global.sm2Key = JSON.parse(this.sm2KeyStr);
|
||||
localStorage.setItem("PrivKey", this.sm2KeyStr);
|
||||
getSession();
|
||||
}, exportPubkey: function (event) {
|
||||
var uri = "data:text/html,";
|
||||
uri += localStorage.getItem("PrivKeyList");
|
||||
var link = document.createElement("a");
|
||||
link.download = "sm2keyList.json";
|
||||
link.href = uri;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
delete link;
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
mainVue = new Vue({
|
||||
el : "#main",
|
||||
data : {
|
||||
licenceDueDate : "已过期",
|
||||
licenceNodes : 0,
|
||||
offlineLicence : undefined,
|
||||
licenceRemark : undefined,
|
||||
userCount:".",
|
||||
contractCount:".",
|
||||
nodeCount:".",
|
||||
eventCount:".",
|
||||
unitCount:".",
|
||||
pubDialogVue:{},
|
||||
projects:[],
|
||||
contracts:[],
|
||||
contractFunctions:[],
|
||||
openedFiles:[{
|
||||
isDir: false,
|
||||
val: "Please Checkout code from left side!",
|
||||
path: "Hello",
|
||||
name: "Hello"
|
||||
}]
|
||||
}
|
||||
});
|
||||
|
||||
mainVue = new Vue({
|
||||
el: "#main",
|
||||
data: {
|
||||
licenceDueDate: "已过期",
|
||||
licenceNodes: 0,
|
||||
offlineLicence: undefined,
|
||||
licenceRemark: undefined,
|
||||
userCount: ".",
|
||||
contractCount: ".",
|
||||
nodeCount: ".",
|
||||
eventCount: ".",
|
||||
unitCount: ".",
|
||||
pubDialogVue: {},
|
||||
projects: [],
|
||||
contracts: [],
|
||||
contractFunctions: [],
|
||||
openedFiles: [{
|
||||
isDir: false,
|
||||
val: "Please Checkout code from left side!",
|
||||
path: "Hello",
|
||||
name: "Hello"
|
||||
}]
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
// ======Vue done
|
||||
|
||||
var initGlobal = function() {
|
||||
if (window.global==undefined){
|
||||
window.global = {};
|
||||
}
|
||||
global.sm2Key = localStorage.getItem("PrivKey");
|
||||
global.result = "";
|
||||
if (global.sm2Key == undefined || global.sm2Key == null
|
||||
|| global.sm2Key.length < 100) {
|
||||
generate();
|
||||
} else {
|
||||
global.sm2Key = JSON.parse(global.sm2Key);
|
||||
}
|
||||
headerVue.shortName = global.sm2Key.publicKey.substr(0, 5);
|
||||
pubkeyDialogVue.sm2KeyStr = JSON.stringify(global.sm2Key);
|
||||
mainVue.pubDialogVue = pubkeyDialogVue;
|
||||
var keyListStr = localStorage.getItem("PrivKeyList");
|
||||
if (keyListStr==undefined){
|
||||
var keyObj = {};
|
||||
keyObj.id = 0;
|
||||
keyObj.title = headerVue.shortName;
|
||||
keyObj.sm2Key = pubkeyDialogVue.sm2KeyStr;
|
||||
pubkeyDialogVue.sm2KeyList = [];
|
||||
pubkeyDialogVue.sm2KeyList.push(keyObj);
|
||||
pubkeyDialogVue.selectedSM2Key = 0;
|
||||
// mainVue.sm2KeyList = pubkeyDialogVue.sm2KeyList;
|
||||
// mainVue.selectedSM2Key = 0;
|
||||
} else{
|
||||
pubkeyDialogVue.sm2KeyList = JSON.parse(keyListStr);
|
||||
pubkeyDialogVue.selectedSM2Key = -1;
|
||||
for (var i=0;i<pubkeyDialogVue.sm2KeyList.length;i++){
|
||||
var obj = pubkeyDialogVue.sm2KeyList[i];
|
||||
if (obj.sm2Key==pubkeyDialogVue.sm2KeyStr){
|
||||
pubkeyDialogVue.selectedSM2Key = i;
|
||||
// mainVue.sm2KeyList = pubkeyDialogVue.sm2KeyList;
|
||||
// mainVue.selectedSM2Key = pubkeyDialogVue.selectedSM2Key;
|
||||
return;
|
||||
}
|
||||
}
|
||||
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;
|
||||
var initGlobal = function (urlParams) {
|
||||
if (!window.global) {
|
||||
window.global = {};
|
||||
}
|
||||
global.result = "";
|
||||
if (location.href.indexOf("BaaSClient") !== -1) {
|
||||
global.isBaaS = true
|
||||
primaryColor = '#08263a'
|
||||
}
|
||||
if (urlParams && urlParams.keys) {
|
||||
global.urlparam = urlParams;
|
||||
global.sm2Key = urlParams.keys
|
||||
} else {
|
||||
global.sm2Key = localStorage.getItem("PrivKey");
|
||||
if (!global.sm2Key || global.sm2Key.length < 100) {
|
||||
generate();
|
||||
} else {
|
||||
global.sm2Key = JSON.parse(global.sm2Key);
|
||||
}
|
||||
}
|
||||
headerVue.shortName = global.sm2Key.publicKey.substr(0, 5);
|
||||
pubkeyDialogVue.sm2KeyStr = JSON.stringify(global.sm2Key);
|
||||
mainVue.pubDialogVue = pubkeyDialogVue;
|
||||
var keyListStr = localStorage.getItem("PrivKeyList");
|
||||
if (keyListStr == undefined) {
|
||||
var keyObj = {};
|
||||
keyObj.id = 0;
|
||||
keyObj.title = headerVue.shortName;
|
||||
keyObj.sm2Key = pubkeyDialogVue.sm2KeyStr;
|
||||
pubkeyDialogVue.sm2KeyList = [];
|
||||
pubkeyDialogVue.sm2KeyList.push(keyObj);
|
||||
pubkeyDialogVue.selectedSM2Key = 0;
|
||||
// mainVue.sm2KeyList = pubkeyDialogVue.sm2KeyList;
|
||||
// mainVue.selectedSM2Key = 0;
|
||||
} else {
|
||||
pubkeyDialogVue.sm2KeyList = JSON.parse(keyListStr);
|
||||
pubkeyDialogVue.selectedSM2Key = -1;
|
||||
for (var i = 0; i < pubkeyDialogVue.sm2KeyList.length; i++) {
|
||||
var obj = pubkeyDialogVue.sm2KeyList[i];
|
||||
if (obj.sm2Key == pubkeyDialogVue.sm2KeyStr) {
|
||||
pubkeyDialogVue.selectedSM2Key = i;
|
||||
// mainVue.sm2KeyList = pubkeyDialogVue.sm2KeyList;
|
||||
// mainVue.selectedSM2Key = pubkeyDialogVue.selectedSM2Key;
|
||||
return;
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user