Skip to content

Commit

Permalink
chore: commit vue3 app
Browse files Browse the repository at this point in the history
  • Loading branch information
sonofmagic committed Jul 14, 2024
1 parent cb8259b commit 92e7a42
Show file tree
Hide file tree
Showing 14 changed files with 164 additions and 149 deletions.
42 changes: 33 additions & 9 deletions apps/shell-vue-app/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@ const apps = reactive([
{
name: 'vue3',
url: '//localhost:8001/',
visible: true
visible: true,
},
{
name: 'vue2',
url: '//localhost:8002/',
visible: false
}
visible: false,
},
])
function createContext() {
const windowMap = new Map()
return {
Expand All @@ -29,19 +28,44 @@ function showApp(index: number) {
})
}
function beforeLoad() {
}
function beforeMount(win: Window) {
console.log(win)
}
function afterMount(win: Window) {
console.log(win)
}
function beforeUnmount() {
}
function afterUnmount() {
}
</script>

<template>
<div class="flex">
<div class="w-72 border-r flex flex-col min-h-screen">
<button @click="showApp(0)">切换到 Vue3 项目</button>
<button @click="showApp(1)">切换到 Vue2 项目</button>
<button @click="showApp(0)">
切换到 Vue3 项目
</button>
<button @click="showApp(1)">
切换到 Vue2 项目
</button>
</div>
<div class="grow">
<WujieVue v-show="app.visible" :key="app.name" v-for="app in apps" width="100%" height="100%" :name="app.name"
:url="app.url" :sync="true"></WujieVue>
<WujieVue
v-for="app in apps" v-show="app.visible" :key="app.name" width="100%" height="100%" :name="app.name"
:url="app.url" :sync="true" :beforeLoad="beforeLoad" :beforeMount="beforeMount" :afterMount="afterMount"
:beforeUnmount="beforeUnmount" :afterUnmount="afterUnmount"
/>
</div>

</div>
</template>

Expand Down
6 changes: 5 additions & 1 deletion apps/vue-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@
"preview": "vite preview"
},
"dependencies": {
"vue": "^3.4.29"
"vue": "^3.4.29",
"vue-router": "^4.4.0"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.0.5",
"autoprefixer": "^10.4.19",
"postcss": "^8.4.39",
"tailwindcss": "^3.4.4",
"typescript": "^5.2.2",
"vite": "^5.3.1",
"vue-tsc": "^2.0.26"
Expand Down
6 changes: 6 additions & 0 deletions apps/vue-app/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
40 changes: 18 additions & 22 deletions apps/vue-app/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
<script setup lang="ts">
import HelloWorld from './components/HelloWorld.vue'
import { useRoute } from 'vue-router'
const route = useRoute()
</script>

<template>
<div>
<a href="https://vitejs.dev" target="_blank">
<img src="/vite.svg" class="logo" alt="Vite logo" />
</a>
<a href="https://vuejs.org/" target="_blank">
<img src="./assets/vue.svg" class="logo vue" alt="Vue logo" />
</a>
<div>
<RouterView />
</div>
<div class="border-t">
<RouterLink to="/">
Index
</RouterLink>
<RouterLink to="/foo">
Foo
</RouterLink>
<RouterLink to="/bar">
Bar
</RouterLink>
</div>
</div>
<HelloWorld msg="Vite + Vue" />
</template>

<style scoped>
.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.vue:hover {
filter: drop-shadow(0 0 2em #42b883aa);
}
</style>
<style scoped></style>
1 change: 0 additions & 1 deletion apps/vue-app/src/assets/vue.svg

This file was deleted.

41 changes: 0 additions & 41 deletions apps/vue-app/src/components/HelloWorld.vue

This file was deleted.

18 changes: 17 additions & 1 deletion apps/vue-app/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
import { createRouter, createWebHistory } from 'vue-router'
import { createApp } from 'vue'
import './style.css'
import App from './App.vue'
import { routes } from './router'

createApp(App).mount('#app')
if (window.__POWERED_BY_WUJIE__) {
let instance: App<Element>
window.__WUJIE_MOUNT = () => {
const router = createRouter({ history: createWebHistory(), routes })
instance = createApp(App)
instance.use(router)
instance.mount('#app')
}
window.__WUJIE_UNMOUNT = () => {
instance.unmount()
}
}
else {
createApp(App).use(createRouter({ history: createWebHistory(), routes })).mount('#app')
}
13 changes: 13 additions & 0 deletions apps/vue-app/src/pages/bar.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<script setup lang="ts">
</script>

<template>
<div>
bar
</div>
</template>

<style scoped>
</style>
13 changes: 13 additions & 0 deletions apps/vue-app/src/pages/foo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<script setup lang="ts">
</script>

<template>
<div>
foo
</div>
</template>

<style scoped>
</style>
11 changes: 11 additions & 0 deletions apps/vue-app/src/pages/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script setup lang="ts">
</script>

<template>
<div>
index
</div>
</template>

<style scoped></style>
9 changes: 9 additions & 0 deletions apps/vue-app/src/router.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Index from './pages/index.vue'
import Bar from './pages/bar.vue'
import Foo from './pages/foo.vue'

export const routes = [
{ path: '/', component: Index },
{ path: '/foo', component: Foo },
{ path: '/Bar', component: Bar },
]
80 changes: 6 additions & 74 deletions apps/vue-app/src/style.css
Original file line number Diff line number Diff line change
@@ -1,79 +1,11 @@
: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;
}
@tailwind base;
@tailwind components;
@tailwind utilities;

a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}
@apply block text-slate-400 border-current font-semibold underline;

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;
&.router-link-active {
@apply text-sky-500;
}
}
11 changes: 11 additions & 0 deletions apps/vue-app/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** @type {import('tailwindcss').Config} */
export default {
content: [
'./index.html',
'./src/**/*.{vue,js,ts,jsx,tsx}',
],
theme: {
extend: {},
},
plugins: [],
}
Loading

0 comments on commit 92e7a42

Please sign in to comment.