-
-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(client): add vue SFC custom tab (#775)
- Loading branch information
1 parent
ebec9f2
commit 59996b9
Showing
14 changed files
with
405 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<script setup lang="ts"> | ||
import * as Vue from 'vue' | ||
import { loadModule } from 'vue3-sfc-loader' | ||
const props = defineProps<{ | ||
sfc: string | ||
name: string | ||
}>() | ||
const options = { | ||
moduleCache: { | ||
vue: Vue, | ||
}, | ||
getFile() { | ||
return props?.sfc ?? '' | ||
}, | ||
addStyle(textContent: string) { | ||
const style = Object.assign(document.createElement('style'), { textContent }) | ||
const ref = document.head.getElementsByTagName('style')[0] || null | ||
document.head.insertBefore(style, ref) | ||
}, | ||
} | ||
const RemoteSFC = defineAsyncComponent(() => loadModule(`${props.name}.vue`, options)) | ||
</script> | ||
|
||
<template> | ||
<RemoteSFC /> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>Vue DevTools Plugin-SFC Playground</title> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script type="module" src="/src/main.ts"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "playground-plugin-sfc", | ||
"type": "module", | ||
"version": "7.3.2", | ||
"private": true, | ||
"scripts": { | ||
"dev": "vite" | ||
}, | ||
"dependencies": { | ||
"vue": "^3.5.13" | ||
}, | ||
"devDependencies": { | ||
"@vitejs/plugin-vue": "^5.2.1", | ||
"@vue/devtools": "workspace:^", | ||
"typescript": "^5.7.2", | ||
"vite": "^6.0.1", | ||
"vite-plugin-inspect": "0.8.9", | ||
"vite-plugin-vue-devtools": "workspace:*" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<script setup lang="ts"> | ||
</script> | ||
|
||
<template> | ||
<div class="flex flex-col justify-center" /> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<script setup lang="ts"> | ||
import { ref } from 'vue' | ||
const count = ref(0) | ||
</script> | ||
|
||
<template> | ||
<div class="h-full w-full flex flex-col items-center justify-center"> | ||
<div> | ||
count is {{ count }} | ||
</div> | ||
<button class="btn" @click="count++"> | ||
increment | ||
</button> | ||
</div> | ||
</template> | ||
|
||
<style scoped> | ||
.btn { | ||
background-color: #4c51bf; | ||
color: #fff; | ||
padding: 0.5rem 1rem; | ||
border-radius: 0.25rem; | ||
border: none; | ||
cursor: pointer; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { addCustomTab } from '@vue/devtools-kit' | ||
import { createApp } from 'vue' | ||
import App from './App.vue' | ||
import countSFC from './count.vue?raw' | ||
|
||
const app = createApp(App) | ||
app.mount('#app') | ||
|
||
setTimeout(() => { | ||
addCustomTab({ | ||
name: 'plugin_count', | ||
title: 'Plugin Count', | ||
icon: 'baseline-exposure-plus-1', | ||
view: { | ||
type: 'sfc', | ||
sfc: countSFC, | ||
}, | ||
category: 'app', | ||
}) | ||
}, 2000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import vue from '@vitejs/plugin-vue' | ||
import { defineConfig } from 'vite' | ||
import inspect from 'vite-plugin-inspect' | ||
import VueDevTools from 'vite-plugin-vue-devtools' | ||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [ | ||
vue(), | ||
VueDevTools(), | ||
inspect(), | ||
], | ||
server: { | ||
port: 3000, | ||
}, | ||
}) |
Oops, something went wrong.