mirror of
https://github.com/XiaoDaiGua-Ray/ray-template.git
synced 2026-11-29 16:13:41 +08:00
Load sign-in assets in the initial graph and defer the workspace, demo features, and mock client until needed. Split feature dependencies and clear stale files from the default production output. Document feature entry points for runtime imports and record the browser and Harness results.
62 lines
1.9 KiB
TypeScript
62 lines
1.9 KiB
TypeScript
import './index.scss'
|
|
import { useI18n } from '@/hooks'
|
|
import { RIcon } from '@ray-template/ui/icon'
|
|
import { NButton, NCard } from 'naive-ui'
|
|
import { exampleFocusKey } from './example-focus'
|
|
|
|
export default defineComponent({
|
|
name: 'HookExample',
|
|
props: {
|
|
name: { type: String, required: true },
|
|
description: { type: String, required: true },
|
|
code: { type: String, required: true },
|
|
},
|
|
setup(props, { slots }) {
|
|
const { t } = useI18n('showcase')
|
|
const focus = inject(exampleFocusKey, void 0)
|
|
const route = focus && useRoute()
|
|
|
|
return () =>
|
|
focus &&
|
|
focus.path === route?.path &&
|
|
!focus.names.has(props.name) ? null : (
|
|
<NCard
|
|
tag="article"
|
|
class="r-hook-example"
|
|
contentStyle={{ padding: 0 }}
|
|
>
|
|
<header class="r-hook-example__header">
|
|
<span class="r-hook-example__symbol" aria-hidden="true">
|
|
ƒ
|
|
</span>
|
|
<h2>{props.name}</h2>
|
|
<span class="r-hook-example__type">Hook</span>
|
|
</header>
|
|
<p class="r-hook-example__description">{props.description}</p>
|
|
<div class="r-hook-preview">
|
|
<span class="r-hook-preview__label">{t('preview')}</span>
|
|
{slots.default?.()}
|
|
</div>
|
|
<details class="r-hook-code">
|
|
<summary>
|
|
<span>
|
|
<RIcon name="directional/expanded" size={12} />
|
|
{t('code')}
|
|
</span>
|
|
<span class="r-hook-code__format">TS / TSX</span>
|
|
</summary>
|
|
<div class="r-hook-code__toolbar">
|
|
<span>TypeScript</span>
|
|
<NButton text size="tiny" v-copy={props.code}>
|
|
{t('copyCode')}
|
|
</NButton>
|
|
</div>
|
|
<pre class="r-demo-code">
|
|
<code>{props.code}</code>
|
|
</pre>
|
|
</details>
|
|
</NCard>
|
|
)
|
|
},
|
|
})
|