feat: luckysheet 增加重载按钮

This commit is contained in:
purocean
2021-07-12 23:38:22 +08:00
parent 21d6754410
commit dd1acce4e1
2 changed files with 15 additions and 2 deletions
+7 -1
View File
@@ -21,7 +21,7 @@ export const IFrame = defineComponent({
iframeProps: Object as PropType<IframeHTMLAttributes>,
onLoad: Function as PropType<(iframe: HTMLIFrameElement) => void>
},
setup (props) {
setup (props, { expose }) {
const url = ref('')
const iframe = ref<HTMLIFrameElement>()
@@ -62,6 +62,12 @@ export const IFrame = defineComponent({
props.onLoad?.(frame)
}
expose({
reload: () => {
iframe.value?.contentWindow?.location.reload()
}
})
return () => url.value ? h('iframe', {
ref: iframe,
src: url.value || undefined,
+8 -1
View File
@@ -1,4 +1,4 @@
import { defineComponent, h, ref, watch } from 'vue'
import { computed, defineComponent, h, ref, watch } from 'vue'
import Markdown from 'markdown-it'
import { Plugin } from '@fe/context/plugin'
@@ -200,11 +200,16 @@ const LuckyComponent = defineComponent({
setup (props) {
logger.debug('setup', props)
const srcdoc = ref('')
const refIFrame = ref<any>()
const update = () => {
srcdoc.value = buildSrcdoc(props.repo!, props.path!, false)
}
const reload = () => {
refIFrame.value.reload()
}
watch(props, update, { immediate: true })
const button = (text: string, onClick: any) => h('button', {
@@ -221,6 +226,7 @@ const LuckyComponent = defineComponent({
},
[
// button('全屏查看', () => 0),
button('重载', reload),
button('新窗口编辑', () => {
const html = buildSrcdoc(props.repo!, props.path!, true)
env.openWindow(buildSrc(html, '编辑表格', false, false), '_blank', { alwaysOnTop: false })
@@ -228,6 +234,7 @@ const LuckyComponent = defineComponent({
]
),
h(IFrame, {
ref: refIFrame,
html: srcdoc.value,
debounce: 1000,
iframeProps: {