-
-
Notifications
You must be signed in to change notification settings - Fork 262
Expand file tree
/
Copy pathBase64EncodeDecodeTool.vue
More file actions
72 lines (63 loc) · 1.67 KB
/
Copy pathBase64EncodeDecodeTool.vue
File metadata and controls
72 lines (63 loc) · 1.67 KB
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
<template>
<div class="base-encode-decode-tool">
<AppForm>
<AppFormItem :label="i18n.t('devtools:form.type')">
<AppSelect
v-model="type"
:options="options"
/>
</AppFormItem>
<AppFormItem :label="i18n.t('devtools:form.inputString')">
<AppInput
v-model="inputValue"
style="width: 100%"
type="textarea"
/>
</AppFormItem>
<AppFormItem :label="i18n.t('devtools:form.result')">
<AppInput
v-model="outputValue"
style="width: 100%"
readonly
type="textarea"
/>
<template #actions>
<AppButton @click="onClear">
{{ i18n.t('common:button.clear') }}
</AppButton>
<AppButton @click="useCopy(outputValue)">
{{ i18n.t('common:button.copy') }}
</AppButton>
</template>
</AppFormItem>
</AppForm>
</div>
</template>
<script setup lang="ts">
import { i18n } from '@/electron'
import { track } from '@/services/analytics'
import { ref, computed } from 'vue'
import type { Type } from './types'
import options from './encode-decode-options.json'
import { useCopy } from '../composables'
const inputValue = ref('')
const type = ref<Type>('encode')
const outputValue = computed(() => {
let result = ''
if (inputValue.value === '') {
return result
}
if (type.value === 'encode') {
result = btoa(inputValue.value)
}
if (type.value === 'decode') {
result = atob(inputValue.value)
}
return result
})
function onClear () {
inputValue.value = ''
}
track('devtools/base64-encoder-decoder')
</script>
<style lang="scss" scoped></style>