Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
feat: @unplugin-vue-ce/ce-app support A more complete app instance ob…
Browse files Browse the repository at this point in the history
…ject
  • Loading branch information
baiwusanyu-c committed Jun 9, 2023
1 parent 65be50e commit eedd881
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 45 deletions.
8 changes: 3 additions & 5 deletions packages/ce-app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@ export function createCEApp(
}
}

const app: App | undefined = undefined
const app: App = createApp(rootComponent)
const rootCEComponent = () => defineCustomElement({
setup() {
const app = createApp(rootComponent)

plugins.forEach((value) => {
app.use(value.plugin, value.option)
app!.use(value.plugin, value.option)
})

const inst = getCurrentInstance()
Expand All @@ -41,9 +39,9 @@ export function createCEApp(

const mount = (ceName: string) => {
customElements.define(ceName, rootCEComponent())
return app
}
return {
...app,
mount,
use: usePlugin,
}
Expand Down
3 changes: 3 additions & 0 deletions play/ce-app/src/Entry.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<script setup>
import '@virtual:uno'
import { inject } from 'vue'
import { RouterLink, RouterView } from 'vue-router'
import HelloWorld from './components/HelloWorld.vue'
import { useCounterStore } from './stores/counter'
const { increment, getV } = useCounterStore()
const msg = inject('message')
</script>

<template>
Expand All @@ -19,6 +21,7 @@ const { increment, getV } = useCounterStore()

<div class="wrapper">
<HelloWorld :msg="`You did it! ${getV()}`" />
<h2> inject: {{ msg }} </h2>
<nav>
<RouterLink to="/">
Home
Expand Down
1 change: 1 addition & 0 deletions play/ce-app/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import router from './router'
const app = createCEApp(App)
app.use(createPinia())
app.use(router)
app.provide('message', 'hello')
app.mount('vue-app')

const ceEntry = defineCustomElement(Entry)
Expand Down
80 changes: 40 additions & 40 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit eedd881

Please sign in to comment.