From 5ab1ad4a8a7925d9df6252774e6261b274d964e6 Mon Sep 17 00:00:00 2001 From: ice breaker <1324318532@qq.com> Date: Wed, 3 Jul 2024 23:10:22 +0800 Subject: [PATCH] feat: commit base vue3 shell --- apps/react-app/package.json | 4 +- apps/react-app/src/App.tsx | 52 ++++++------ apps/react-app/src/lifecycle.ts | 12 +++ apps/react-app/src/main.tsx | 22 ++++++ apps/shell-vue-app/.gitignore | 24 ++++++ apps/shell-vue-app/.vscode/extensions.json | 3 + apps/shell-vue-app/README.md | 5 ++ apps/shell-vue-app/index.html | 13 +++ apps/shell-vue-app/package.json | 21 +++++ apps/shell-vue-app/public/vite.svg | 1 + apps/shell-vue-app/src/App.vue | 13 +++ apps/shell-vue-app/src/assets/vue.svg | 1 + .../src/components/HelloWorld.vue | 41 ++++++++++ apps/shell-vue-app/src/main.ts | 8 ++ apps/shell-vue-app/src/style.css | 79 +++++++++++++++++++ apps/shell-vue-app/src/vite-env.d.ts | 1 + apps/shell-vue-app/tsconfig.app.json | 27 +++++++ apps/shell-vue-app/tsconfig.json | 11 +++ apps/shell-vue-app/tsconfig.node.json | 13 +++ apps/shell-vue-app/vite.config.ts | 10 +++ apps/vue2-app/src/App.vue | 2 - apps/vue2-app/src/components/HelloWorld.vue | 11 ++- pnpm-lock.yaml | 70 ++++++++++++++++ 23 files changed, 416 insertions(+), 28 deletions(-) create mode 100644 apps/react-app/src/lifecycle.ts create mode 100644 apps/shell-vue-app/.gitignore create mode 100644 apps/shell-vue-app/.vscode/extensions.json create mode 100644 apps/shell-vue-app/README.md create mode 100644 apps/shell-vue-app/index.html create mode 100644 apps/shell-vue-app/package.json create mode 100644 apps/shell-vue-app/public/vite.svg create mode 100644 apps/shell-vue-app/src/App.vue create mode 100644 apps/shell-vue-app/src/assets/vue.svg create mode 100644 apps/shell-vue-app/src/components/HelloWorld.vue create mode 100644 apps/shell-vue-app/src/main.ts create mode 100644 apps/shell-vue-app/src/style.css create mode 100644 apps/shell-vue-app/src/vite-env.d.ts create mode 100644 apps/shell-vue-app/tsconfig.app.json create mode 100644 apps/shell-vue-app/tsconfig.json create mode 100644 apps/shell-vue-app/tsconfig.node.json create mode 100644 apps/shell-vue-app/vite.config.ts diff --git a/apps/react-app/package.json b/apps/react-app/package.json index 64c1cbd..bf4a08a 100644 --- a/apps/react-app/package.json +++ b/apps/react-app/package.json @@ -11,7 +11,9 @@ }, "dependencies": { "react": "^18.3.1", - "react-dom": "^18.3.1" + "react-dom": "^18.3.1", + "wujie": "^1.0.22", + "wujie-react": "^1.0.22" }, "devDependencies": { "@types/react": "^18.3.3", diff --git a/apps/react-app/src/App.tsx b/apps/react-app/src/App.tsx index afe48ac..9850242 100644 --- a/apps/react-app/src/App.tsx +++ b/apps/react-app/src/App.tsx @@ -1,33 +1,37 @@ import { useState } from 'react' -import reactLogo from './assets/react.svg' -import viteLogo from '/vite.svg' import './App.css' +import WujieReact from 'wujie-react' function App() { - const [count, setCount] = useState(0) - return ( <> -
- - Vite logo - - - React logo - -
-

Vite + React

-
- -

- Edit src/App.tsx and save to test HMR -

-
-

- Click on the Vite and React logos to learn more -

+ + + + + + ) } diff --git a/apps/react-app/src/lifecycle.ts b/apps/react-app/src/lifecycle.ts new file mode 100644 index 0000000..d661582 --- /dev/null +++ b/apps/react-app/src/lifecycle.ts @@ -0,0 +1,12 @@ +const lifecycles = { + beforeLoad: appWindow => console.log(`${appWindow.__WUJIE.id} beforeLoad 生命周期`), + beforeMount: appWindow => console.log(`${appWindow.__WUJIE.id} beforeMount 生命周期`), + afterMount: appWindow => console.log(`${appWindow.__WUJIE.id} afterMount 生命周期`), + beforeUnmount: appWindow => console.log(`${appWindow.__WUJIE.id} beforeUnmount 生命周期`), + afterUnmount: appWindow => console.log(`${appWindow.__WUJIE.id} afterUnmount 生命周期`), + activated: appWindow => console.log(`${appWindow.__WUJIE.id} activated 生命周期`), + deactivated: appWindow => console.log(`${appWindow.__WUJIE.id} deactivated 生命周期`), + loadError: (url, e) => console.log(`${url} 加载失败`, e), +} + +export default lifecycles diff --git a/apps/react-app/src/main.tsx b/apps/react-app/src/main.tsx index 3d7150d..f6496b3 100644 --- a/apps/react-app/src/main.tsx +++ b/apps/react-app/src/main.tsx @@ -2,6 +2,28 @@ import React from 'react' import ReactDOM from 'react-dom/client' import App from './App.tsx' import './index.css' +import WujieReact from 'wujie-react' + +const { setupApp, preloadApp, bus } = WujieReact +bus.$on('click', msg => window.alert(msg)) + +setupApp({ + name: 'svelte', + url: '//localhost:8082/', + exec: true, +}) + +setupApp({ + name: 'vue3', + url: '//localhost:8083/', + exec: true, +}) + +setupApp({ + name: 'vue2', + url: '//localhost:8084/', + exec: true, +}) ReactDOM.createRoot(document.getElementById('root')!).render( diff --git a/apps/shell-vue-app/.gitignore b/apps/shell-vue-app/.gitignore new file mode 100644 index 0000000..a547bf3 --- /dev/null +++ b/apps/shell-vue-app/.gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/apps/shell-vue-app/.vscode/extensions.json b/apps/shell-vue-app/.vscode/extensions.json new file mode 100644 index 0000000..a7cea0b --- /dev/null +++ b/apps/shell-vue-app/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": ["Vue.volar"] +} diff --git a/apps/shell-vue-app/README.md b/apps/shell-vue-app/README.md new file mode 100644 index 0000000..33895ab --- /dev/null +++ b/apps/shell-vue-app/README.md @@ -0,0 +1,5 @@ +# Vue 3 + TypeScript + Vite + +This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 ` + + diff --git a/apps/shell-vue-app/package.json b/apps/shell-vue-app/package.json new file mode 100644 index 0000000..4e118cc --- /dev/null +++ b/apps/shell-vue-app/package.json @@ -0,0 +1,21 @@ +{ + "name": "shell-vue-app", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "vue-tsc -b && vite build", + "preview": "vite preview" + }, + "dependencies": { + "vue": "^3.4.29", + "wujie-vue3": "^1.0.22" + }, + "devDependencies": { + "@vitejs/plugin-vue": "^5.0.5", + "typescript": "^5.2.2", + "vite": "^5.3.1", + "vue-tsc": "^2.0.21" + } +} diff --git a/apps/shell-vue-app/public/vite.svg b/apps/shell-vue-app/public/vite.svg new file mode 100644 index 0000000..e7b8dfb --- /dev/null +++ b/apps/shell-vue-app/public/vite.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/shell-vue-app/src/App.vue b/apps/shell-vue-app/src/App.vue new file mode 100644 index 0000000..07456ee --- /dev/null +++ b/apps/shell-vue-app/src/App.vue @@ -0,0 +1,13 @@ + + + + + diff --git a/apps/shell-vue-app/src/assets/vue.svg b/apps/shell-vue-app/src/assets/vue.svg new file mode 100644 index 0000000..770e9d3 --- /dev/null +++ b/apps/shell-vue-app/src/assets/vue.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/shell-vue-app/src/components/HelloWorld.vue b/apps/shell-vue-app/src/components/HelloWorld.vue new file mode 100644 index 0000000..b58e52b --- /dev/null +++ b/apps/shell-vue-app/src/components/HelloWorld.vue @@ -0,0 +1,41 @@ + + + + + diff --git a/apps/shell-vue-app/src/main.ts b/apps/shell-vue-app/src/main.ts new file mode 100644 index 0000000..10dcab6 --- /dev/null +++ b/apps/shell-vue-app/src/main.ts @@ -0,0 +1,8 @@ +import { createApp } from 'vue' +import './style.css' +import WujieVue from 'wujie-vue3' +import App from './App.vue' + +const { bus, setupApp, preloadApp, destroyApp } = WujieVue + +createApp(App).use(WujieVue).mount('#app') diff --git a/apps/shell-vue-app/src/style.css b/apps/shell-vue-app/src/style.css new file mode 100644 index 0000000..bb131d6 --- /dev/null +++ b/apps/shell-vue-app/src/style.css @@ -0,0 +1,79 @@ +:root { + font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; + line-height: 1.5; + font-weight: 400; + + color-scheme: light dark; + color: rgba(255, 255, 255, 0.87); + background-color: #242424; + + font-synthesis: none; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +a { + font-weight: 500; + color: #646cff; + text-decoration: inherit; +} +a:hover { + color: #535bf2; +} + +body { + margin: 0; + display: flex; + place-items: center; + min-width: 320px; + min-height: 100vh; +} + +h1 { + font-size: 3.2em; + line-height: 1.1; +} + +button { + border-radius: 8px; + border: 1px solid transparent; + padding: 0.6em 1.2em; + font-size: 1em; + font-weight: 500; + font-family: inherit; + background-color: #1a1a1a; + cursor: pointer; + transition: border-color 0.25s; +} +button:hover { + border-color: #646cff; +} +button:focus, +button:focus-visible { + outline: 4px auto -webkit-focus-ring-color; +} + +.card { + padding: 2em; +} + +#app { + max-width: 1280px; + margin: 0 auto; + padding: 2rem; + text-align: center; +} + +@media (prefers-color-scheme: light) { + :root { + color: #213547; + background-color: #ffffff; + } + a:hover { + color: #747bff; + } + button { + background-color: #f9f9f9; + } +} diff --git a/apps/shell-vue-app/src/vite-env.d.ts b/apps/shell-vue-app/src/vite-env.d.ts new file mode 100644 index 0000000..11f02fe --- /dev/null +++ b/apps/shell-vue-app/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/apps/shell-vue-app/tsconfig.app.json b/apps/shell-vue-app/tsconfig.app.json new file mode 100644 index 0000000..b8e9723 --- /dev/null +++ b/apps/shell-vue-app/tsconfig.app.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "composite": true, + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", + "target": "ES2020", + "useDefineForClassFields": true, + "module": "ESNext", + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "moduleDetection": "force", + "noEmit": true, + "jsx": "preserve", + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"] +} diff --git a/apps/shell-vue-app/tsconfig.json b/apps/shell-vue-app/tsconfig.json new file mode 100644 index 0000000..ea9d0cd --- /dev/null +++ b/apps/shell-vue-app/tsconfig.json @@ -0,0 +1,11 @@ +{ + "files": [], + "references": [ + { + "path": "./tsconfig.app.json" + }, + { + "path": "./tsconfig.node.json" + } + ] +} diff --git a/apps/shell-vue-app/tsconfig.node.json b/apps/shell-vue-app/tsconfig.node.json new file mode 100644 index 0000000..3afdd6e --- /dev/null +++ b/apps/shell-vue-app/tsconfig.node.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "composite": true, + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", + "skipLibCheck": true, + "module": "ESNext", + "moduleResolution": "bundler", + "allowSyntheticDefaultImports": true, + "strict": true, + "noEmit": true + }, + "include": ["vite.config.ts"] +} diff --git a/apps/shell-vue-app/vite.config.ts b/apps/shell-vue-app/vite.config.ts new file mode 100644 index 0000000..416602b --- /dev/null +++ b/apps/shell-vue-app/vite.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from 'vite' +import vue from '@vitejs/plugin-vue' + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [vue()], + server: { + port: 8000, + }, +}) diff --git a/apps/vue2-app/src/App.vue b/apps/vue2-app/src/App.vue index 1f09cf2..c204a48 100644 --- a/apps/vue2-app/src/App.vue +++ b/apps/vue2-app/src/App.vue @@ -5,5 +5,3 @@ - - diff --git a/apps/vue2-app/src/components/HelloWorld.vue b/apps/vue2-app/src/components/HelloWorld.vue index 2fbf250..a9e3eb0 100644 --- a/apps/vue2-app/src/components/HelloWorld.vue +++ b/apps/vue2-app/src/components/HelloWorld.vue @@ -1,8 +1,17 @@