Skip to content

Commit 2a3021c

Browse files
committed
feat: auth for standalone
1 parent 2d38d74 commit 2a3021c

File tree

1 file changed

+18
-3
lines changed
  • packages/core/src/client/standalone

1 file changed

+18
-3
lines changed

packages/core/src/client/standalone/App.vue

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<script setup lang="ts">
22
import type { DocksContext } from '@vitejs/devtools-kit/client'
33
import { getDevToolsRpcClient } from '@vitejs/devtools-kit/client'
4-
import { markRaw, useTemplateRef } from 'vue'
4+
import { markRaw, ref, useTemplateRef, watch } from 'vue'
55
import DockEntries from '../webcomponents/components/DockEntries.vue'
66
import VitePlus from '../webcomponents/components/icons/VitePlus.vue'
7+
import ViewBuiltinClientAuthNotice from '../webcomponents/components/ViewBuiltinClientAuthNotice.vue'
78
import ViewEntry from '../webcomponents/components/ViewEntry.vue'
89
import { createDocksContext } from '../webcomponents/state/context'
910
import { PersistedDomViewsManager } from '../webcomponents/utils/PersistedDomViewsManager'
@@ -21,11 +22,25 @@ const context: DocksContext = await createDocksContext(
2122
rpc,
2223
)
2324
24-
context.docks.selectedId ||= context.docks.entries[0]?.id ?? null
25+
const isRpcTrusted = ref(context.rpc.isTrusted)
26+
context.rpc.events.on('rpc:is-trusted:updated', (isTrusted) => {
27+
isRpcTrusted.value = isTrusted
28+
})
29+
30+
watch(
31+
() => context.docks.entries,
32+
() => {
33+
context.docks.selectedId ||= context.docks.entries[0]?.id ?? null
34+
},
35+
{ immediate: true },
36+
)
2537
</script>
2638

2739
<template>
28-
<div class="h-screen w-screen of-hidden grid cols-[max-content_1fr]">
40+
<div v-if="!isRpcTrusted" class="h-screen w-screen of-hidden">
41+
<ViewBuiltinClientAuthNotice :context="context" />
42+
</div>
43+
<div v-else class="h-screen w-screen of-hidden grid cols-[max-content_1fr]">
2944
<div class="border-r border-base flex flex-col">
3045
<div class="p2 border-b border-base flex">
3146
<VitePlus class="w-7 h-7 ma" />

0 commit comments

Comments
 (0)