diff --git a/src/collections/account.js b/src/collections/account.js index ce609a0..b5ea8d2 100644 --- a/src/collections/account.js +++ b/src/collections/account.js @@ -10,8 +10,9 @@ class Account { * @param password (密码) * @param mnemonicCode (助记词)-对称加密 * @param mnemonicCodeLanguage (助记词)-语言版本 + * @param state (状态)-N-正常,D-删除 */ - constructor (address, identityId, type, name, password, mnemonicCode, secret, mnemonicCodeLanguage) { + constructor (address, identityId, type, name, password, mnemonicCode, secret, mnemonicCodeLanguage, state) { this.address = address; this.identityId = identityId; this.type = type; @@ -21,6 +22,7 @@ class Account { this.mnemonicCode = mnemonicCode; this.secret = secret; this.mnemonicCodeLanguage = mnemonicCodeLanguage; + this.state = state; } /** @@ -32,6 +34,7 @@ class Account { * @param name * @param password * @param mnemonicCodeLanguage + * @param state * @returns {*} */ static insertAccount ( @@ -43,10 +46,11 @@ class Account { name = '', password = '', mnemonicCode = '', + state = 'N', mnemonicCodeLanguage = 'english' } = {} ) { - let account = new Account(address, identityId, type, name, password, mnemonicCode, secret, mnemonicCodeLanguage); + let account = new Account(address, identityId, type, name, password, mnemonicCode, secret, mnemonicCodeLanguage, state); instance.insert(account); return this; } @@ -57,7 +61,7 @@ class Account { * @returns {*} 返回一个数组,多个 */ static findByIdentityId (identityId) { - let resultRet = instance.find({identityId: identityId}); + let resultRet = instance.find({identityId: identityId, state: 'N'}); return resultRet; } @@ -97,14 +101,14 @@ class Account { * @returns {Object|*} */ static findByType(type) { - return instance.find({type: type}); + return instance.find({type: type, state: 'N'}); } /** *查询全部 */ static findAll () { - return instance.data; + return instance.find({state: 'N'}); } @@ -112,7 +116,7 @@ class Account { *查询全部,按类型排序 */ static findAllSoryByType () { - let resultRet = instance.chain().find() + let resultRet = instance.chain().find({state: 'N'}) .simplesort('type', true).data(); return resultRet; } @@ -123,7 +127,7 @@ class Account { * @returns {*} */ static genAccountName(type) { - let results = instance.find({type: type}); + let results = instance.find({type: type, state: 'N'}); let accountNames = results.map(item => { return item.name; }); diff --git a/src/core/utils/QRCodeScanner.js b/src/core/utils/QRCodeScanner.js index 30b5b18..3b7a58d 100644 --- a/src/core/utils/QRCodeScanner.js +++ b/src/core/utils/QRCodeScanner.js @@ -20,6 +20,11 @@ export default{ 'describeLineSpacing': '8', //(行间距) 'describeColor': '#ffffff', //(文字颜色) + //choose photo button + 'choosePhotoEnable': 'true', //(支持相册选取, 默认false) + 'choosePhotoBtnTitle': vueInstance.$t('scan.album'), //(选取按钮文字) + 'choosePhotoBtnColor': "#4e8dec", //(选取按钮颜色) + //scan border 'borderColor': '#4e8dec', //(扫描框颜色) 'borderScale': '0.6', //(边框大小,0.1 ~ 1) diff --git a/src/core/utils/initScript.js b/src/core/utils/initScript.js index d1c7fd7..0c59a87 100644 --- a/src/core/utils/initScript.js +++ b/src/core/utils/initScript.js @@ -1,9 +1,14 @@ -// import Vue from 'vue'; +import Vue from 'vue'; export default { done () { - // console.info('初始化'); - // console.info('删除的ethereum历史数据....'); - // Vue.collecitons.history.removeHistory({acctType: 'ethereum'}); - // console.info('删除的ethereum历史数据.... end'); + /*console.info('初始化'); + console.info('删除的ethereum历史数据....'); + Vue.collecitons.history.removeHistory({acctType: 'ethereum'}); + console.info('删除的ethereum历史数据.... end');*/ + Vue.collecitons.account.findAndUpdateAcct({}, (account) => { + if (!account.state) { + return account.state = 'N'; + } + }); } }; diff --git a/src/i18n/lang/en-US.json b/src/i18n/lang/en-US.json index 7ac40ac..c649fb0 100644 --- a/src/i18n/lang/en-US.json +++ b/src/i18n/lang/en-US.json @@ -113,7 +113,7 @@ "addAsset": "Add Assets", "scanFailTip": "Non wallet address, please re scan.", "scanDeviceError": "Nonsupport device.", - "scanTitle": "scan", + "scanTitle": "Scan", "scanTip": "Please scan the QR code.", "accountActivatedTitle": "Account not activated", "stellarAccountActivatedMsg": "All Accounts need to hold one XLM balance in Steller network to ensure authenticity of account.", @@ -296,7 +296,8 @@ "confirmPwdPlaceholder": "Please enter repeat password", "oldPwdErrorTip": "Old Password Incorrect", "deleteWallet": "Delete Wallet", - "acctNotexist": "Wallet does not exist" + "acctNotexist": "Wallet does not exist", + "delAcctTip": "After deleting the account, you can add it again" }, "history": { "contractSuccess": "Call contract Succeeded", @@ -325,7 +326,8 @@ "failure": "Fail", "shareWeiXinFail": "No WeChat client installed", "shareQQFail": "No QQ client installed", - "inputIllegal": "Input Illegal" + "inputIllegal": "Input Illegal", + "album": "Album" }, "gesture": { "gestureTitle": "Please set gesture password", diff --git a/src/i18n/lang/ja-JP.json b/src/i18n/lang/ja-JP.json index 4fd08bc..29e3d92 100644 --- a/src/i18n/lang/ja-JP.json +++ b/src/i18n/lang/ja-JP.json @@ -297,7 +297,8 @@ "confirmPwdPlaceholder": "確認用のパスワードを入力してください", "oldPwdErrorTip": "元のパスワードが誤って入力された", "deleteWallet": "ウォレットを削除", - "acctNotexist": "ウォレットは存在しません" + "acctNotexist": "ウォレットは存在しません", + "delAcctTip": "アカウントを削除した後、再度追加することができます" }, "history": { "contractSuccess": "コントラクト呼び出しに成功", @@ -326,7 +327,8 @@ "failure": "共有障害", "shareWeiXinFail": "WeChatクライアントがインストールされていません", "shareQQFail": "QQクライアントがインストールされていない", - "inputIllegal": "不正な入力" + "inputIllegal": "不正な入力", + "album": "アルバム" }, "gesture": { "gestureTitle": "グラフィックパスワードを設定してください", diff --git a/src/i18n/lang/ko-KO.json b/src/i18n/lang/ko-KO.json index 4f1df27..7204f3c 100644 --- a/src/i18n/lang/ko-KO.json +++ b/src/i18n/lang/ko-KO.json @@ -296,7 +296,8 @@ "confirmPwdPlaceholder": "확인 비밀번호를 입력하십시오.", "oldPwdErrorTip": "원래 암호가 잘못 입력되었습니다.", "deleteWallet": "지갑 삭제", - "acctNotexist": "지갑이 존재하지 않습니다." + "acctNotexist": "지갑이 존재하지 않습니다.", + "delAcctTip": "계정을 삭제 한 후 다시 추가 할 수 있습니다." }, "history": { "contractSuccess": "계약을 전용하는데 성공하였습니다.", @@ -325,7 +326,8 @@ "failure": "공유 하지 못했습니다.", "shareWeiXinFail": "Wechat가 설치 되지 않았습니다.", "shareQQFail": "QQ가 설치 되어 있지 않습니다.", - "inputIllegal": "잘못 된 입력" + "inputIllegal": "잘못 된 입력", + "album": "앨범" }, "gesture": { "gestureTitle": "그래픽 암호 설정", diff --git a/src/i18n/lang/zh-CN.json b/src/i18n/lang/zh-CN.json index 54f7732..8698441 100644 --- a/src/i18n/lang/zh-CN.json +++ b/src/i18n/lang/zh-CN.json @@ -184,8 +184,8 @@ "xrpMarketTitle": "瑞波行情", "xrpMarketSubTitle": "瑞波市场行情", "xrpMarketDesc": "由StellarChat社区改进布署。数据从瑞波实时网络和RippleCharts API获取", - "u919Title": "U919溯源", - "u919SubTitle": "U919溯源", + "u919Title": "U919朔源", + "u919SubTitle": "U919朔源", "u919Desc": "由ultiledger.io提供" }, "setting": { @@ -296,7 +296,8 @@ "confirmPwdPlaceholder": "请输入确认密码", "oldPwdErrorTip": "原密码输入不正确", "deleteWallet": "删除钱包", - "acctNotexist": "该钱包不存在" + "acctNotexist": "该钱包不存在", + "delAcctTip": "删除该账户后,您可以重新添加" }, "history": { "contractSuccess": "调用合约成功", @@ -325,7 +326,8 @@ "failure": "分享失败", "shareWeiXinFail": "未安装微信客户端", "shareQQFail": "未安装QQ客户端", - "inputIllegal": "输入非法" + "inputIllegal": "输入非法", + "album": "相册" }, "gesture": { "gestureTitle": "请设置您的图形密码", diff --git a/src/main.js b/src/main.js index 5ef5e97..05c1140 100644 --- a/src/main.js +++ b/src/main.js @@ -116,13 +116,13 @@ const initApp = () => { } else { this.$i18n.locale = setting.language; /* 设置已经设置的语言*/ vantI18n(setting.language); /* 设置已经设置的语言*/ - let currentAcct = this.$collecitons.account.findByAddress(setting.defaultAddress); + /* let currentAcct = this.$collecitons.account.findByAddress(setting.defaultAddress); if (currentAcct && currentAcct.identityId) { let identity = this.$collecitons.identity.findById(currentAcct.identityId); if (identity && !identity.backFlag) { return this.$router.push({name: 'back-mnemonicCode', params: {showVpop: true}}); } - } + } */ } } }); diff --git a/src/pages/acct/acct-detail.vue b/src/pages/acct/acct-detail.vue index 15d65ac..90ee88f 100644 --- a/src/pages/acct/acct-detail.vue +++ b/src/pages/acct/acct-detail.vue @@ -53,7 +53,7 @@ :address="account.address"> -
+
@@ -95,8 +95,6 @@ account: {}, acctName: '', showAcctNameDialog: false, - source: '', - sourceType: SourceType, checkType: '' /*校验类型,主要用于是对那个功能点进行密码输入*/ }; }, @@ -104,14 +102,24 @@ computed: { currentAccount () { return this.$store.state.account; + }, + delFlag () { + let identity = this.$collecitons.identity.findById(this.account.identityId); + if (identity && identity.source === SourceType.CREATED) { + let accounts = this.$collecitons.account.findByIdentityId(identity.id); + // 不能删除 + if (accounts && accounts.length === 1) { + return '0'; + } + return '1'; + } + return '2'; } }, methods: { show (item) { this.account = item; this.acctName = item.name; - let identity = this.$collecitons.identity.findById(item.identityId); - this.source = identity.source; this.showPop = true; }, close () { @@ -137,33 +145,52 @@ this.checkType = checkType; this.$refs.pwdDialog.show(); }, - delWallet () { + removeDataAndUpdateActions (option, identityId) { const toast = this.$toast.loading({ duration: 0, forbidClick: true, loadingType: 'circular' }); + if (this.delFlag === '1') { + this.$collecitons.account.findAndUpdateAcct(option, (account) => { + return account.state = 'D'; + }); + } else { + this.$collecitons.account.findAndRemoveAcct(option); + } + this.$collecitons.history.removeHistory(option); + this.$collecitons.asset.removAssetByAddressAndName(option); + let map = {}; + map[this.account.address] = ''; + this.$store.dispatch('setPasswordMap', map); + let allAccount = this.$collecitons.account.findAll(); + if (allAccount && allAccount.length > 0) { + let account = {...allAccount[0], setBalance: false}; + this.$store.dispatch('setAccount' , account); + this.$emit('afterDelAcct'); + } else { + this.$collecitons.identity.deleteIdentityById(identityId); + } + setTimeout(() => { + toast.clear(); + this.close(); + }, 1000); + }, + delWallet () { + if (this.account) { let identityId = this.currentAccount.identityId; let option = {address: this.account.address}; - this.$collecitons.account.findAndRemoveAcct(option); - this.$collecitons.history.removeHistory(option); - this.$collecitons.asset.removAssetByAddressAndName(option); - let map = {}; - map[this.account.address] = ''; - this.$store.dispatch('setPasswordMap', map); - let allAccount = this.$collecitons.account.findAll(); - if (allAccount && allAccount.length > 0) { - let account = {...allAccount[0], setBalance: false}; - this.$store.dispatch('setAccount' , account); - this.$emit('afterDelAcct'); + if (this.delFlag === '1') { // 逻辑删除操作 + this.$dialog.confirm({ + title: this.$t('common.tip'), + message: this.$t('acct.delAcctTip') + }).then(() => { + this.removeDataAndUpdateActions(option, identityId); + }); } else { - this.$collecitons.identity.deleteIdentityById(identityId); + this.removeDataAndUpdateActions(option, identityId); } - setTimeout(() => { - toast.clear(); - this.close(); - }, 1000); } else { this.$toast(this.$t('acct.acctNotexist')); } @@ -173,7 +200,7 @@ if (this.checkType === '1') { this.$refs.exportSecret.show(password); } else if (this.checkType === '2') { - this.$refs.backupsMemorizing.show(cryptor.decryptAES(this.currentAccount.mnemonicCode, password), password); + this.$refs.backupsMemorizing.show(cryptor.decryptAES(this.currentAccount.mnemonicCode, password), password, 'backups'); } else if (this.checkType === '3') { // 删除钱包 this.delWallet(); } diff --git a/src/pages/assets/popup/view-accounts-pop.vue b/src/pages/assets/popup/view-accounts-pop.vue index 8431560..d536ff3 100644 --- a/src/pages/assets/popup/view-accounts-pop.vue +++ b/src/pages/assets/popup/view-accounts-pop.vue @@ -25,7 +25,7 @@ @close="close"> - +
@@ -69,6 +69,10 @@ afterDelAcct () { this.$emit('afterDelAcct'); }, + refreshAccts () { + this.updateCurrentAcct(); + this.updateImportAcct(); + }, updateCurrentAcct () { let createIdentity = this.$collecitons.identity.findBySource(SourceType.CREATED); if (createIdentity && createIdentity.length > 0) { diff --git a/src/pages/history/tx-detail-bitcoin.vue b/src/pages/history/tx-detail-bitcoin.vue index 37a0fbf..a97a6ef 100644 --- a/src/pages/history/tx-detail-bitcoin.vue +++ b/src/pages/history/tx-detail-bitcoin.vue @@ -1,5 +1,5 @@