优化代码,并删除长按10秒退出的功能,因为浏览器不支持了

master
叶志超 2021-12-22 15:01:33 +08:00
parent c95ae24140
commit 93a12decbf
1 changed files with 11 additions and 29 deletions

View File

@ -1,37 +1,19 @@
<template> <template>
<div v-show="!!src"> <div v-show="!!src">
<img @mouseup="onMouseUp" @mousedown="onMouseDown" :src="src"> <img :src="src">
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts" setup>
import { defineComponent, ref } from 'vue' import { ref } from 'vue'
export default defineComponent({
setup: () => {
const src = ref('/image/flag/Beidou.png')
const show_flag = (flag_name) => {
if (!flag_name) return
src.value = './image/flag/' + flag_name + '.png' const src = ref('')
} const show_flag = (flag_name: string) => {
if (!flag_name) return
let exit_timeout = null src.value = './image/flag/' + flag_name + '.png'
const exit = () => { }
window.opener = window; defineExpose({ show_flag })
window.open('', '_self', '');
window.close();
}
const onMouseUp = () => {
if (exit_timeout) clearTimeout(exit_timeout)
}
const onMouseDown = () => {
exit_timeout = setTimeout(exit, 10000)
}
return { src, show_flag, onMouseUp, onMouseDown }
}
})
</script> </script>
<style scoped> <style scoped>