Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 7x 7x 7x | <template>
<div :class="$style.root">
<div @click="copy" vusion-slot-name="default">
<slot>
<s-empty v-if="(!$slots.default) && $env.VUE_APP_DESIGNER && !!$attrs['vusion-node-path']"></s-empty>
<u-link v-else :disabled="disabled" vusion-slot-name-edit="text">{{ text }}</u-link>
</slot>
</div>
<u-tooltip v-if="feedback === 'tooltip'" :placement="placement" trigger="manual" :opened.sync="success">
{{ successText }}
</u-tooltip>
<u-tooltip :placement="placement" trigger="manual" :opened.sync="failed">
无复制对象
</u-tooltip>
</div>
</template>
<script>
import { copy } from '../../utils/edit/clipboard';
// import i18n from '@/utils/i18n';
import SEmpty from '../../components/s-empty.vue';
export default {
name: 'u-copy',
components: { SEmpty },
props: {
value: String,
text: { type: String, default: '复制' },
placement: { type: String, default: 'top' },
successText: { type: String, default: '已复制' },
disabled: { type: Boolean, default: false },
hideDelay: { type: Number, default: 3000 },
feedback: { type: String, default: 'tooltip' },
},
data() {
return { success: false, timeoutId: undefined, failed: false };
},
destroyed() {
clearTimeout(this.timeoutId);
},
methods: {
copy() {
if (this.disabled)
return;
this.success = copy(this.value);
if (this.success) {
if (this.feedback === 'toast')
this.$toast.show(this.successText, this.hideDelay);
this.$emit('copy', { value: this.value }, this);
clearTimeout(this.timeoutId);
this.timeoutId = setTimeout(() => {
this.success = false;
}, this.hideDelay);
}
this.failed = !this.success;
},
},
};
</script>
<style module>
.root {
display: inline-block;
position: relative;
}
</style>
|