diff --git a/app/components/floatingBubble/floating.js b/app/components/floatingBubble/floating.js new file mode 100644 index 0000000..d28f994 --- /dev/null +++ b/app/components/floatingBubble/floating.js @@ -0,0 +1,34 @@ +import { createApp } from 'vue' +import MinWindow from '@/components/floatingBubble/index.vue' + +let minWindowInstance = null +let minWindowApp = null // 新增:保存应用实例 + +// 创建悬浮窗 +export const showMinWindow1 = ( props = {}) => { + if (process.client){ + const container = document.createElement('div') + container.className = 'floating-bubble-container' // 添加类名 + document.body.appendChild(container) + const app = createApp(MinWindow, { + ...props + }) + + minWindowApp = app // 保存应用实例 + minWindowInstance = app.mount(container) + return minWindowInstance + } +} + +export const hideMinWindow1 = () => { + if (!minWindowApp) return + const cleanup = () => { + minWindowApp.unmount() // 使用应用实例的unmount方法 + const container = document.querySelector('.floating-bubble-container') // 假设您的容器有这个类名 + container && document.body.removeChild(container) + minWindowApp = null + minWindowInstance = null + } + + cleanup() +} \ No newline at end of file diff --git a/app/components/floatingBubble/index.vue b/app/components/floatingBubble/index.vue new file mode 100644 index 0000000..0fc4b58 --- /dev/null +++ b/app/components/floatingBubble/index.vue @@ -0,0 +1,26 @@ + + + + + \ No newline at end of file diff --git a/app/components/itemDetail/index.vue b/app/components/itemDetail/index.vue index f2ca9d6..c67833c 100644 --- a/app/components/itemDetail/index.vue +++ b/app/components/itemDetail/index.vue @@ -8,7 +8,7 @@ const props = defineProps({ default: null } }) - +console.log(props.detailInfo)