Browse Source

chore: 新增不能单独运行功能

huangziyang 1 month ago
parent
commit
2b277f149e

BIN
form/favicon.ico


+ 44 - 0
form/index.html

@@ -0,0 +1,44 @@
+<!DOCTYPE html><html lang=""><head>
+    <meta charset="UTF-8">
+    <link rel="icon" href="/saas/form/favicon.ico">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Vite App</title>
+    <script crossorigin="">import('/saas/form/static/index.DYYWzmnX.js').finally(() => {
+            
+    const qiankunLifeCycle = window.moudleQiankunAppLifeCycles && window.moudleQiankunAppLifeCycles['curstom-form'];
+    if (qiankunLifeCycle) {
+      window.proxy.vitemount((props) => qiankunLifeCycle.mount(props));
+      window.proxy.viteunmount((props) => qiankunLifeCycle.unmount(props));
+      window.proxy.vitebootstrap(() => qiankunLifeCycle.bootstrap());
+      window.proxy.viteupdate((props) => qiankunLifeCycle.update(props));
+    }
+  
+          })</script>
+    <link rel="stylesheet" crossorigin="" href="/saas/form/static/index.BePiSQRJ.css">
+  </head>
+  <body>
+    <div id="app"></div>
+  
+
+<script>
+  const createDeffer = (hookName) => {
+    const d = new Promise((resolve, reject) => {
+      window.proxy && (window.proxy[`vite${hookName}`] = resolve)
+    })
+    return props => d.then(fn => fn(props));
+  }
+  const bootstrap = createDeffer('bootstrap');
+  const mount = createDeffer('mount');
+  const unmount = createDeffer('unmount');
+  const update = createDeffer('update');
+
+  ;(global => {
+    global.qiankunName = 'curstom-form';
+    global['curstom-form'] = {
+      bootstrap,
+      mount,
+      unmount,
+      update
+    };
+  })(window);
+</script></body></html>

File diff suppressed because it is too large
+ 0 - 0
form/static/index.BePiSQRJ.css


File diff suppressed because it is too large
+ 0 - 0
form/static/index.DYYWzmnX.js


+ 3 - 0
src/components/404/no_found.vue

@@ -0,0 +1,3 @@
+<template>
+  <el-result title="404" icon="error" sub-title="抱歉,您访问的页面不存在">1 </el-result>
+</template>

+ 7 - 6
src/main.ts

@@ -1,6 +1,6 @@
 /* eslint-disable @typescript-eslint/ban-ts-comment */
 
-import { createApp, type App as AppType } from 'vue'
+import { createApp, type App as AppType, type Component } from 'vue'
 
 import './main.css'
 import App from './App.vue'
@@ -13,23 +13,24 @@ import * as ElementPlusIconsVue from '@element-plus/icons-vue'
 
 //封装弹窗方法
 import setupComponent from './components'
+import No_found from './components/404/no_found.vue'
 
 let app: AppType | null = null
 //导入方法
 
 //导入方法
-async function bootstrapVue3(container: HTMLElement) {
+async function bootstrapVue3(component: Component) {
   if (qiankunWindow.__POWERED_BY_QIANKUN__) {
     console.log('处于独立运行模式...')
   }
-  app = createApp(App)
+  app = createApp(component)
   await setupComponent(app)
   for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
     app.component(key, component)
   }
   app.use(ELEMENT)
   app.use(FcDesigner.formCreate)
-  app.mount(container)
+  app.mount(document.getElementById('app') as HTMLElement)
 }
 
 // bootstrapVue3()
@@ -39,7 +40,7 @@ const initQianKun = () => {
     // 当前应用在主应用中的生命周期
     // 文档 https://qiankun.umijs.org/zh/guide/getting-started#
     mount(props) {
-      bootstrapVue3(props.container?.querySelector('#app') as HTMLElement)
+      bootstrapVue3(App)
       //  可以通过props读取主应用的参数:msg
       // 监听主应用传值以及我本身的一些业务逻辑
       props.setLoading(false)
@@ -66,5 +67,5 @@ if (qiankunWindow.__POWERED_BY_QIANKUN__) {
   initQianKun()
 } else {
   // 独立运行时,直接挂载应用
-  bootstrapVue3(document.getElementById('app') as HTMLElement)
+  bootstrapVue3(No_found)
 }

+ 1 - 0
vite.config.ts

@@ -34,6 +34,7 @@ export default defineConfig({
         drop_debugger: true,
       },
     },
+
     rollupOptions: {
       output: {
         assetFileNames: 'static/[name].[hash].[ext]', // 确保静态资源路径正确

Some files were not shown because too many files changed in this diff