From dfac7f7611933dde1f8c9d27ed5bc4dffee45c3e Mon Sep 17 00:00:00 2001 From: ice breaker <1324318532@qq.com> Date: Mon, 15 Jul 2024 00:41:20 +0800 Subject: [PATCH] feat: commit codes --- apps/vue-app/src/App.vue | 11 +++++-- apps/vue-app/src/main.ts | 4 +++ apps/vue-app/src/pages/bar.vue | 1 + apps/vue-app/src/pages/foo.vue | 1 + apps/vue-app/src/pages/index.vue | 1 + apps/vue-app/src/style.css | 2 +- apps/vue2-app/src/App.vue | 32 +++++++++++++++++---- apps/vue2-app/src/assets/tailwindcss.svg | 1 - apps/vue2-app/src/assets/vue.svg | 1 - apps/vue2-app/src/components/HelloWorld.vue | 32 --------------------- apps/vue2-app/src/main.ts | 24 ++++++++++------ apps/vue2-app/src/pages/bar.vue | 14 +++++++++ apps/vue2-app/src/pages/foo.vue | 14 +++++++++ apps/vue2-app/src/pages/index.vue | 12 ++++++++ apps/vue2-app/src/router.ts | 17 +++++------ apps/vue2-app/src/style.css | 10 ++++++- 16 files changed, 115 insertions(+), 62 deletions(-) delete mode 100644 apps/vue2-app/src/assets/tailwindcss.svg delete mode 100644 apps/vue2-app/src/assets/vue.svg delete mode 100644 apps/vue2-app/src/components/HelloWorld.vue create mode 100644 apps/vue2-app/src/pages/bar.vue create mode 100644 apps/vue2-app/src/pages/foo.vue create mode 100644 apps/vue2-app/src/pages/index.vue diff --git a/apps/vue-app/src/App.vue b/apps/vue-app/src/App.vue index fbff083..afe9715 100644 --- a/apps/vue-app/src/App.vue +++ b/apps/vue-app/src/App.vue @@ -1,13 +1,18 @@ + Vue3 - + + + + + + + diff --git a/apps/vue-app/src/main.ts b/apps/vue-app/src/main.ts index 90b8a8d..823de6b 100644 --- a/apps/vue-app/src/main.ts +++ b/apps/vue-app/src/main.ts @@ -11,9 +11,13 @@ if (window.__POWERED_BY_WUJIE__) { instance = createApp(App) instance.use(router) instance.mount('#app') + window.$router = router + window.$instance = instance } window.__WUJIE_UNMOUNT = () => { instance.unmount() + delete window.$router + delete window.$instance } } else { diff --git a/apps/vue-app/src/pages/bar.vue b/apps/vue-app/src/pages/bar.vue index 2754825..7dabfce 100644 --- a/apps/vue-app/src/pages/bar.vue +++ b/apps/vue-app/src/pages/bar.vue @@ -5,6 +5,7 @@ bar + diff --git a/apps/vue-app/src/pages/foo.vue b/apps/vue-app/src/pages/foo.vue index 1ace98f..d79ee19 100644 --- a/apps/vue-app/src/pages/foo.vue +++ b/apps/vue-app/src/pages/foo.vue @@ -5,6 +5,7 @@ foo + diff --git a/apps/vue-app/src/pages/index.vue b/apps/vue-app/src/pages/index.vue index 5105537..2844e9b 100644 --- a/apps/vue-app/src/pages/index.vue +++ b/apps/vue-app/src/pages/index.vue @@ -5,6 +5,7 @@ index + diff --git a/apps/vue-app/src/style.css b/apps/vue-app/src/style.css index ab8d279..a9c177b 100644 --- a/apps/vue-app/src/style.css +++ b/apps/vue-app/src/style.css @@ -5,7 +5,7 @@ a { @apply block text-slate-400 border-current font-semibold underline; - &.router-link-active { + &.router-link-exact-active { @apply text-sky-500; } } diff --git a/apps/vue2-app/src/App.vue b/apps/vue2-app/src/App.vue index c204a48..4d666b6 100644 --- a/apps/vue2-app/src/App.vue +++ b/apps/vue2-app/src/App.vue @@ -1,7 +1,29 @@ + + - - - - - + + Vue2 + + + + + + + + + + Index + + + Foo + + + Bar + + + + + diff --git a/apps/vue2-app/src/assets/tailwindcss.svg b/apps/vue2-app/src/assets/tailwindcss.svg deleted file mode 100644 index 6a9ab49..0000000 --- a/apps/vue2-app/src/assets/tailwindcss.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/apps/vue2-app/src/assets/vue.svg b/apps/vue2-app/src/assets/vue.svg deleted file mode 100644 index 770e9d3..0000000 --- a/apps/vue2-app/src/assets/vue.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/apps/vue2-app/src/components/HelloWorld.vue b/apps/vue2-app/src/components/HelloWorld.vue deleted file mode 100644 index a9e3eb0..0000000 --- a/apps/vue2-app/src/components/HelloWorld.vue +++ /dev/null @@ -1,32 +0,0 @@ - - - - - {{ msg }} - - - - count is {{ store.count }} - - - Double count {{ store.double }} - - - - - - diff --git a/apps/vue2-app/src/main.ts b/apps/vue2-app/src/main.ts index e856eba..0eb3eb3 100644 --- a/apps/vue2-app/src/main.ts +++ b/apps/vue2-app/src/main.ts @@ -1,17 +1,25 @@ import Vue from 'vue' import './style.css' import { PiniaVuePlugin, createPinia } from 'pinia' +import VueRouter from 'vue-router' import App from './App.vue' -import router from './router' +import { routes } from './router' Vue.use(PiniaVuePlugin) Vue.config.productionTip = false const pinia = createPinia() -/* eslint-disable no-new */ -new Vue({ - el: '#app', - router, - render: h => h(App), - pinia, -}) + +if (window.__POWERED_BY_WUJIE__) { + let instance + window.__WUJIE_MOUNT = () => { + const router = new VueRouter({ routes }) + instance = new Vue({ router, render: h => h(App), pinia }).$mount('#app') + } + window.__WUJIE_UNMOUNT = () => { + instance.$destroy() + } +} +else { + new Vue({ router: new VueRouter({ routes }), render: h => h(App), pinia }).$mount('#app') +} diff --git a/apps/vue2-app/src/pages/bar.vue b/apps/vue2-app/src/pages/bar.vue new file mode 100644 index 0000000..7dabfce --- /dev/null +++ b/apps/vue2-app/src/pages/bar.vue @@ -0,0 +1,14 @@ + + + + + bar + + + + + diff --git a/apps/vue2-app/src/pages/foo.vue b/apps/vue2-app/src/pages/foo.vue new file mode 100644 index 0000000..d79ee19 --- /dev/null +++ b/apps/vue2-app/src/pages/foo.vue @@ -0,0 +1,14 @@ + + + + + foo + + + + + diff --git a/apps/vue2-app/src/pages/index.vue b/apps/vue2-app/src/pages/index.vue new file mode 100644 index 0000000..2844e9b --- /dev/null +++ b/apps/vue2-app/src/pages/index.vue @@ -0,0 +1,12 @@ + + + + + index + + + + + diff --git a/apps/vue2-app/src/router.ts b/apps/vue2-app/src/router.ts index 865d2c6..a0f836f 100644 --- a/apps/vue2-app/src/router.ts +++ b/apps/vue2-app/src/router.ts @@ -1,18 +1,15 @@ import Vue from 'vue' import type { RouteConfig } from 'vue-router' import VueRouter from 'vue-router' -import HelloWorld from './components/HelloWorld.vue' -Vue.use(VueRouter) +import Index from './pages/index.vue' +import Bar from './pages/bar.vue' +import Foo from './pages/foo.vue' export const routes: RouteConfig[] = [ - { path: '/', component: HelloWorld, props: { msg: 'Home' } }, - { path: '/bar', component: HelloWorld, props: { msg: 'Bar' } }, + { path: '/', component: Index }, + { path: '/foo', component: Foo }, + { path: '/Bar', component: Bar }, ] -const router = new VueRouter({ - mode: 'history', - routes, -}) - -export default router +Vue.use(VueRouter) diff --git a/apps/vue2-app/src/style.css b/apps/vue2-app/src/style.css index bd6213e..a9c177b 100644 --- a/apps/vue2-app/src/style.css +++ b/apps/vue2-app/src/style.css @@ -1,3 +1,11 @@ @tailwind base; @tailwind components; -@tailwind utilities; \ No newline at end of file +@tailwind utilities; + +a { + @apply block text-slate-400 border-current font-semibold underline; + + &.router-link-exact-active { + @apply text-sky-500; + } +}
- Double count {{ store.double }} -