ScrmApp.vue 1.61 KB
<!--
 * @Author: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
 * @Date: 2025-11-11 11:52:02
 * @LastEditors: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
 * @LastEditTime: 2025-11-11 19:30:18
 * @FilePath: \venus\apps\frontend\micro-vue\scrm-base\src\pages\ScrmApp.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<script setup lang="ts">
import { ref, onMounted } from 'vue'

const hostMsg = ref('')
const global = ref<any>(null)

onMounted(() => {
  const actions = (window as any).__QIANKUN_ACTIONS__
  actions?.onGlobalStateChange?.((s: any) => {
    global.value = s
  }, true)
})

function broadcast() {
  const actions = (window as any).__QIANKUN_ACTIONS__
  actions?.setGlobalState?.({ ...(global.value || {}), msg: hostMsg.value })
}
</script>

<template>
  <div>
    <div style="margin-bottom:12px; display:flex; gap:8px; align-items:center;">
      <input
        v-model="hostMsg"
        placeholder="向子应用广播消息"
        style="padding:6px; border:1px solid #ccc; border-radius:4px;"
      />
      <button @click="broadcast" style="padding:6px 10px;">广播</button>
      <span>当前全局消息:{{ global?.msg }}</span>
    </div>
    <div id="mfe-scrm-app"></div>
  </div>
</template>

<style scoped></style>