mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 01:04:25 +08:00
migrate information / password input / passcode input sheet to composition API and typescript
This commit is contained in:
@@ -17,74 +17,71 @@
|
|||||||
</p>
|
</p>
|
||||||
<textarea class="information-content full-line" readonly="readonly" :rows="rowCount" :value="information"></textarea>
|
<textarea class="information-content full-line" readonly="readonly" :rows="rowCount" :value="information"></textarea>
|
||||||
<div class="margin-top text-align-center">
|
<div class="margin-top text-align-center">
|
||||||
<f7-link @click="cancel" :text="$t('Close')"></f7-link>
|
<f7-link @click="close" :text="$t('Close')"></f7-link>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</f7-page-content>
|
</f7-page-content>
|
||||||
</f7-sheet>
|
</f7-sheet>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup lang="ts">
|
||||||
|
import { useTemplateRef, watch, onMounted, onUpdated } from 'vue';
|
||||||
|
|
||||||
import { ClipboardHolder } from '@/lib/clipboard.ts';
|
import { ClipboardHolder } from '@/lib/clipboard.ts';
|
||||||
|
|
||||||
export default {
|
const props = defineProps<{
|
||||||
props: [
|
title?: string
|
||||||
'title',
|
hint?: string
|
||||||
'hint',
|
information: string
|
||||||
'information',
|
rowCount: number
|
||||||
'rowCount',
|
enableCopy?: boolean
|
||||||
'enableCopy',
|
show: boolean
|
||||||
'show'
|
}>();
|
||||||
],
|
|
||||||
emits: [
|
|
||||||
'update:show',
|
|
||||||
'info:copied'
|
|
||||||
],
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
clipboardHolder: null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.makeCopyToClipboardClickable();
|
|
||||||
},
|
|
||||||
updated() {
|
|
||||||
this.makeCopyToClipboardClickable();
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
'information': function (newValue) {
|
|
||||||
if (this.clipboardHolder) {
|
|
||||||
this.clipboardHolder.setClipboardText(newValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
onSheetClosed() {
|
|
||||||
this.close();
|
|
||||||
},
|
|
||||||
cancel() {
|
|
||||||
this.close();
|
|
||||||
},
|
|
||||||
makeCopyToClipboardClickable() {
|
|
||||||
const self = this;
|
|
||||||
|
|
||||||
if (self.clipboardHolder) {
|
const emit = defineEmits<{
|
||||||
return;
|
(e: 'update:show', value: boolean): void
|
||||||
}
|
(e: 'info:copied'): void
|
||||||
|
}>();
|
||||||
|
|
||||||
if (self.$refs.copyToClipboardIcon) {
|
const iconCopyToClipboard = useTemplateRef('copyToClipboardIcon');
|
||||||
self.clipboardHolder = ClipboardHolder.create({
|
|
||||||
el: '#copy-to-clipboard-icon',
|
let clipboardHolder: ClipboardHolder = null;
|
||||||
text: self.information,
|
|
||||||
successCallback: function () {
|
function makeCopyToClipboardClickable() {
|
||||||
self.$emit('info:copied');
|
if (clipboardHolder) {
|
||||||
}
|
return;
|
||||||
});
|
}
|
||||||
|
|
||||||
|
if (iconCopyToClipboard.value) {
|
||||||
|
clipboardHolder = ClipboardHolder.create({
|
||||||
|
el: '#copy-to-clipboard-icon',
|
||||||
|
text: props.information,
|
||||||
|
successCallback: function () {
|
||||||
|
emit('info:copied');
|
||||||
}
|
}
|
||||||
},
|
});
|
||||||
close() {
|
|
||||||
this.$emit('update:show', false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function close() {
|
||||||
|
emit('update:show', false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSheetClosed() {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
makeCopyToClipboardClickable();
|
||||||
|
});
|
||||||
|
|
||||||
|
onUpdated(() => {
|
||||||
|
makeCopyToClipboardClickable();
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(() => props.information, (newValue) => {
|
||||||
|
if (clipboardHolder) {
|
||||||
|
clipboardHolder.setClipboardText(newValue);
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -36,47 +36,48 @@
|
|||||||
</f7-sheet>
|
</f7-sheet>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup lang="ts">
|
||||||
export default {
|
import { type Ref, ref } from 'vue';
|
||||||
props: [
|
|
||||||
'modelValue',
|
|
||||||
'title',
|
|
||||||
'hint',
|
|
||||||
'confirmDisabled',
|
|
||||||
'cancelDisabled',
|
|
||||||
'show'
|
|
||||||
],
|
|
||||||
emits: [
|
|
||||||
'update:modelValue',
|
|
||||||
'update:show',
|
|
||||||
'passcode:confirm'
|
|
||||||
],
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
currentPasscode: ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
onSheetOpen() {
|
|
||||||
this.currentPasscode = '';
|
|
||||||
},
|
|
||||||
onSheetClosed() {
|
|
||||||
this.close();
|
|
||||||
},
|
|
||||||
confirm() {
|
|
||||||
if (!this.currentPasscode || this.confirmDisabled) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.$emit('update:modelValue', this.currentPasscode);
|
const props = defineProps<{
|
||||||
this.$emit('passcode:confirm', this.currentPasscode);
|
modelValue: string
|
||||||
},
|
title?: string
|
||||||
cancel() {
|
hint?: string
|
||||||
this.close();
|
confirmDisabled?: boolean
|
||||||
},
|
cancelDisabled?: boolean
|
||||||
close() {
|
show: boolean
|
||||||
this.$emit('update:show', false);
|
}>();
|
||||||
}
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'update:modelValue', value: string): void
|
||||||
|
(e: 'update:show', value: boolean): void
|
||||||
|
(e: 'passcode:confirm', value: string): void
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const currentPasscode: Ref<string> = ref('');
|
||||||
|
|
||||||
|
function confirm() {
|
||||||
|
if (!currentPasscode.value || props.confirmDisabled) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit('update:modelValue', currentPasscode.value);
|
||||||
|
emit('passcode:confirm', currentPasscode.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
function cancel() {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
|
function close() {
|
||||||
|
emit('update:show', false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSheetOpen() {
|
||||||
|
currentPasscode.value = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSheetClosed() {
|
||||||
|
close();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -37,48 +37,49 @@
|
|||||||
</f7-sheet>
|
</f7-sheet>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup lang="ts">
|
||||||
export default {
|
import { type Ref, ref } from 'vue';
|
||||||
props: [
|
|
||||||
'modelValue',
|
|
||||||
'title',
|
|
||||||
'hint',
|
|
||||||
'color',
|
|
||||||
'confirmDisabled',
|
|
||||||
'cancelDisabled',
|
|
||||||
'show'
|
|
||||||
],
|
|
||||||
emits: [
|
|
||||||
'update:modelValue',
|
|
||||||
'update:show',
|
|
||||||
'password:confirm'
|
|
||||||
],
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
currentPassword: ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
onSheetOpen() {
|
|
||||||
this.currentPassword = '';
|
|
||||||
},
|
|
||||||
onSheetClosed() {
|
|
||||||
this.close();
|
|
||||||
},
|
|
||||||
confirm() {
|
|
||||||
if (!this.currentPassword || this.confirmDisabled) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.$emit('update:modelValue', this.currentPassword);
|
const props = defineProps<{
|
||||||
this.$emit('password:confirm', this.currentPassword);
|
modelValue: string
|
||||||
},
|
title?: string
|
||||||
cancel() {
|
hint?: string
|
||||||
this.close();
|
color?: string
|
||||||
},
|
confirmDisabled?: boolean
|
||||||
close() {
|
cancelDisabled?: boolean
|
||||||
this.$emit('update:show', false);
|
show: boolean
|
||||||
}
|
}>();
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'update:modelValue', value: string): void
|
||||||
|
(e: 'update:show', value: boolean): void
|
||||||
|
(e: 'password:confirm', value: string): void
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const currentPassword: Ref<string> = ref('');
|
||||||
|
|
||||||
|
function confirm() {
|
||||||
|
if (!currentPassword.value || props.confirmDisabled) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit('update:modelValue', currentPassword.value);
|
||||||
|
emit('password:confirm', currentPassword.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
function cancel() {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
|
function close() {
|
||||||
|
emit('update:show', false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSheetOpen() {
|
||||||
|
currentPassword.value = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSheetClosed() {
|
||||||
|
close();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user