forked from homura/mimi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.vue
86 lines (78 loc) · 2.03 KB
/
app.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<template>
<div>
<div class="box">
<div class="field">
<label class="label">Display</label>
<div class="control">
<input v-model="display" class="input" type="text" placeholder="display text">
</div>
</div>
<div class="field">
<label class="label">Secret</label>
<div class="control">
<input v-model="secret" class="input" type="text" placeholder="secret text">
</div>
</div>
<div class="field is-grouped">
<div class="control">
<button @click="encode" class="button is-link">Encode and copy</button>
</div>
</div>
</div>
<div class="box">
<div class="field">
<label class="label">Encoded</label>
<div class="control">
<input v-model="encoded" class="input" type="text" placeholder="paste the encoded text here">
</div>
</div>
<div class="field is-grouped">
<div class="control">
<button @click="decode" class="button is-link">Decode</button>
</div>
</div>
<div class="field">
<div class="control">
<textarea
class="textarea"
disabled
placeholder="Decoded"
v-model="decoded">
</textarea>
</div>
</div>
</div>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
import { copyTextToClipboard } from "./clipboard";
import { decode, encode } from './codec';
export default Vue.extend({
data() {
return {
display: 'hello',
secret: '你好',
encoded: '',
decoded: '',
};
},
methods: {
async encode() {
try {
await copyTextToClipboard(encode(this.display, this.secret));
alert('copied to clipboard');
} catch (e) {
alert(e.message);
}
},
decode() {
try {
this.decoded = decode(this.encoded);
} catch (e) {
alert(e.message);
}
}
}
})
</script>