qiankun.jsx 750 B

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