Skip to content

Commit

Permalink
update awesome-qr
Browse files Browse the repository at this point in the history
  • Loading branch information
imloama committed Aug 19, 2018
1 parent 3a4a867 commit 720ef04
Show file tree
Hide file tree
Showing 6 changed files with 9,674 additions and 18 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@
}
},
"dependencies": {
"@xkeshi/vue-qrcode": "^1.0.0",
"animate.css": ">3.5.2",
"awesome-qr": "1.0.9",
"awesome-qr": "^1.2.0",
"axios": ">0.17.1",
"better-scroll": "^1.4.2",
"bip39": "^2.4.0",
Expand Down
18 changes: 14 additions & 4 deletions src/renderer/libs/vue-qr/vue-qr.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const uuidv4 = require('uuid/v4')
import { toBoolean } from './util.js'
import AwesomeQRCode from 'awesome-qr'
let AwesomeQR = require('awesome-qr');
export default {
props: [
'text',
Expand All @@ -24,7 +24,7 @@ export default {
name: 'vue-qr',
data() {
return {
uuid: ''
uuid: '',
}
},
watch: {
Expand Down Expand Up @@ -80,7 +80,7 @@ export default {
},
render(img, logoImg) {
const that = this
new AwesomeQRCode().create({
new AwesomeQR().create({
text: that.text,
size: that.size || 200,
margin: that.margin || 20,
Expand All @@ -98,10 +98,20 @@ export default {
binarize: toBoolean(that.binarize) || false,
binarizeThreshold: that.binarizeThreshold || 128,
callback: function(dataURI) {
that.callback && that.callback(dataURI)
document.getElementById(that.uuid).src = that.arrayBufferToBase64(dataURI)
that.callback && that.callback(that.arrayBufferToBase64(dataURI))
},
bindElement: that.uuid
})
},
arrayBufferToBase64( buffer ) {
var binary = '';
var bytes = new Uint8Array( buffer );
var len = bytes.byteLength;
for (var i = 0; i < len; i++) {
binary += String.fromCharCode( bytes[ i ] );
}
return 'data:image/png;base64,' + window.btoa( binary );
}
}
}
2 changes: 1 addition & 1 deletion src/renderer/libs/vue-qr/vue-qr.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div>
<img v-bind="{id:uuid}">
<img v-bind="{id:uuid}" >
</div>
</template>

Expand Down
4 changes: 2 additions & 2 deletions src/renderer/pages/asset/ReceiveAsset.vue
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ export default {
// use stargaze pattern
//{"stellar":{"payment":{"destination":"GAD2....5UZ6","amount":1,"asset":{"code":"BTC","issuer":"GATEMH....MTCH"}}}}
let data = {stellar:{payment:{destination:this.account.address,amount: this.num}}}
if(isNativeAsset(this.selectedasset)){
data.stellar.payment.asset = {code:this.selectedasset, issuer: this.selectedasset.issuer}
if(!isNativeAsset(this.selectedasset)){
data.stellar.payment.asset = {code:this.selectedasset.code, issuer: this.selectedasset.issuer}
}
return JSON.stringify(data)
}
Expand Down
Loading

0 comments on commit 720ef04

Please sign in to comment.