mirror of
https://github.com/purocean/yn.git
synced 2026-09-24 15:46:02 +08:00
feat: luckysheet 增加重载按钮
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user