Skip to content

Commit

Permalink
feat: commit base vue3 shell
Browse files Browse the repository at this point in the history
  • Loading branch information
sonofmagic committed Jul 3, 2024
1 parent ecf036b commit 5ab1ad4
Show file tree
Hide file tree
Showing 23 changed files with 416 additions and 28 deletions.
4 changes: 3 additions & 1 deletion apps/react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
52 changes: 28 additions & 24 deletions apps/react-app/src/App.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<>
<div>
<a href="https://vitejs.dev" target="_blank">
<img src={viteLogo} className="logo" alt="Vite logo" />
</a>
<a href="https://react.dev" target="_blank">
<img src={reactLogo} className="logo react" alt="React logo" />
</a>
</div>
<h1>Vite + React</h1>
<div className="card">
<button onClick={() => setCount((count) => count + 1)}>
count is {count}
</button>
<p>
Edit <code>src/App.tsx</code> and save to test HMR
</p>
</div>
<p className="read-the-docs">
Click on the Vite and React logos to learn more
</p>
<WujieReact
width="100px"
height="100px"
name="svelte"
url="//localhost:8082/"
sync={true}
alive={true}
>
</WujieReact>
<WujieReact
width="100px"
height="100px"
name="vue3"
url="//localhost:8083/"
sync={true}
alive={true}
>
</WujieReact>
<WujieReact
width="100px"
height="100px"
name="vue2"
url="//localhost:8084/"
sync={true}
alive={true}
>
</WujieReact>
</>
)
}
Expand Down
12 changes: 12 additions & 0 deletions apps/react-app/src/lifecycle.ts
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions apps/react-app/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
<React.StrictMode>
Expand Down
24 changes: 24 additions & 0 deletions apps/shell-vue-app/.gitignore
Original file line number Diff line number Diff line change
@@ -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?
3 changes: 3 additions & 0 deletions apps/shell-vue-app/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["Vue.volar"]
}
5 changes: 5 additions & 0 deletions apps/shell-vue-app/README.md
Original file line number Diff line number Diff line change
@@ -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 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.

Learn more about the recommended Project Setup and IDE Support in the [Vue Docs TypeScript Guide](https://vuejs.org/guide/typescript/overview.html#project-setup).
13 changes: 13 additions & 0 deletions apps/shell-vue-app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Vue + TS</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
21 changes: 21 additions & 0 deletions apps/shell-vue-app/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
1 change: 1 addition & 0 deletions apps/shell-vue-app/public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions apps/shell-vue-app/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<script setup lang="ts">
</script>

<template>
<div>
<WujieVue width="100%" height="100%" name="xxx0" url="//localhost:8082/" :sync="true"></WujieVue>
<WujieVue width="100%" height="100%" name="xxx1" url="//localhost:8083/" :sync="true"></WujieVue>
<WujieVue width="100%" height="100%" name="xxx2" url="//localhost:8084/" :sync="true"></WujieVue>
</div>
</template>

<style scoped></style>
1 change: 1 addition & 0 deletions apps/shell-vue-app/src/assets/vue.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions apps/shell-vue-app/src/components/HelloWorld.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<script setup lang="ts">
import { ref } from 'vue'
defineProps<{ msg: string }>()
const count = ref(0)
</script>

<template>
<h1>{{ msg }}</h1>

<div class="card">
<button type="button" @click="count++">count is {{ count }}</button>
<p>
Edit
<code>components/HelloWorld.vue</code> to test HMR
</p>
</div>

<p>
Check out
<a href="https://vuejs.org/guide/quick-start.html#local" target="_blank"
>create-vue</a
>, the official Vue + Vite starter
</p>
<p>
Learn more about IDE Support for Vue in the
<a
href="https://vuejs.org/guide/scaling-up/tooling.html#ide-support"
target="_blank"
>Vue Docs Scaling up Guide</a
>.
</p>
<p class="read-the-docs">Click on the Vite and Vue logos to learn more</p>
</template>

<style scoped>
.read-the-docs {
color: #888;
}
</style>
8 changes: 8 additions & 0 deletions apps/shell-vue-app/src/main.ts
Original file line number Diff line number Diff line change
@@ -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')
79 changes: 79 additions & 0 deletions apps/shell-vue-app/src/style.css
Original file line number Diff line number Diff line change
@@ -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;
}
}
1 change: 1 addition & 0 deletions apps/shell-vue-app/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
27 changes: 27 additions & 0 deletions apps/shell-vue-app/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -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"]
}
11 changes: 11 additions & 0 deletions apps/shell-vue-app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"files": [],
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.node.json"
}
]
}
13 changes: 13 additions & 0 deletions apps/shell-vue-app/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -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"]
}
Loading

0 comments on commit 5ab1ad4

Please sign in to comment.