OSDN Git Service

change readme
[bytom/Byone.git] / src / popup / framework / components / menu / page / recovery.vue
1 <style scoped>
2 .body {
3   padding: 20px 15px;
4 }
5 input {
6   width: 165px;
7 }
8 </style>
9
10 <template>
11     <div class="mc2warp bg-gray">
12         <section>
13             <i class="iconfont btn-close" @click="close">&#xe605;</i>
14             <h3>导入账户</h3>
15         </section>
16         <section class="body">
17           <div class="form-item">
18               <input type="file" ref="file" @change="tirggerFile($event)">
19           </div>
20           <div class="btn bg-green" @click="recovery">从种子导入</div>
21         </section> 
22     </div>
23 </template>
24
25 <script>
26 import bytom from "../../../../script/bytom";
27 export default {
28   name: "",
29   data() {
30     return {
31       fileTxt: ""
32     };
33   },
34   methods: {
35     close: function() {
36       this.$emit("closed", "");
37     },
38     tirggerFile: function(event) {
39       var reader = new FileReader();
40       reader.onload = e => {
41         this.fileTxt = e.target.result;
42       };
43
44       var file = event.target.files[0];
45       reader.readAsText(file);
46     },
47     recovery: function() {
48       bytom
49         .restore(this.fileTxt)
50         .then(res => {
51           this.close();
52           console.log(res);
53         })
54         .catch(error => {
55           alert(error);
56         });
57     }
58   }
59 };
60 </script>