index.jsx 754 B

12345678910111213141516171819202122232425
  1. import { ref, markRaw, onMounted } from 'vue'
  2. import { start, initGlobalState } from 'qiankun'
  3. import { useMain } from '@cip/hooks/use-main'
  4. export default {
  5. setup () {
  6. const { setCurrentTitle } = useMain()
  7. console.log('subapp start')
  8. const actions = ref()
  9. onMounted(() => {
  10. if (!window.qiankunStarted) {
  11. window.qiankunStarted = true
  12. const state = { setCurrentTitle }
  13. actions.value = markRaw(initGlobalState(state))
  14. actions.value.onGlobalStateChange((state, prevState) => {
  15. console.log(state, prevState)
  16. })
  17. actions.value.setGlobalState(state)
  18. start({ excludeAssetFilter: () => true })
  19. }
  20. })
  21. return () => <div id={'subapp-viewport'}>
  22. </div>
  23. }
  24. }