NetworkPane 网络面板
HAR / Hex / PCAP / Cert / Cookie 5 个 tab 的网络抓包面板。
基础用法
预定义 5 个 tab(id:har、hex、pcap、cert、cookie),每个 tab 内容由消费方通过 named slot
#panel-{tabId}(Vue)/ slots["panel-{tabId}"](React)填入。也可通过 tabs prop 覆盖默认列表。
来源:network.html。
背景
HAR 请求瀑布图(基于 CfTimingBar + CfChartCrosshair)。
<script setup lang="ts">
import { CfNetworkPane } from '@chufix-design/vue';
</script>
<template>
<div style="height: 280px;">
<CfNetworkPane>
<template #panel-har><p style="color: var(--fg-2);">HAR 请求瀑布图(基于 CfTimingBar + CfChartCrosshair)。</p></template>
<template #panel-hex><p style="color: var(--fg-2);">16 进制 + ASCII 双栏视图。</p></template>
<template #panel-pcap><p style="color: var(--fg-2);">抓包行项列表。</p></template>
<template #panel-cert><p style="color: var(--fg-2);">X.509 证书字段树。</p></template>
<template #panel-cookie><p style="color: var(--fg-2);">域级 cookie 管理。</p></template>
</CfNetworkPane>
</div>
</template> <script setup>
import { CfNetworkPane } from '@chufix-design/vue';
</script>
<template>
<div style="height: 280px;">
<CfNetworkPane>
<template #panel-har><p style="color: var(--fg-2);">HAR 请求瀑布图(基于 CfTimingBar + CfChartCrosshair)。</p></template>
<template #panel-hex><p style="color: var(--fg-2);">16 进制 + ASCII 双栏视图。</p></template>
<template #panel-pcap><p style="color: var(--fg-2);">抓包行项列表。</p></template>
<template #panel-cert><p style="color: var(--fg-2);">X.509 证书字段树。</p></template>
<template #panel-cookie><p style="color: var(--fg-2);">域级 cookie 管理。</p></template>
</CfNetworkPane>
</div>
</template> <CfNetworkPane slots={{
'panel-har': <PanelA />,
'panel-hex': <PanelB />,
}} /> <CfNetworkPane slots={{
'panel-har': <PanelA />,
'panel-hex': <PanelB />,
}} /> 真实内容拼装
5 个 tab 各放对应原子:HAR Timeline 用 CfTimingBar;Hex Viewer 用 pre + 等宽字体;Cert 字段用 CfDescriptionList。
背景
200OK/v1/orders · 312ms
<script setup lang="ts">
import { CfNetworkPane, CfTimingBar, CfStatusCodeBadge, CfDescriptionList } from '@chufix-design/vue';
const r1 = [
{ label: 'DNS', start: 0, end: 8, colorIndex: 6 },
{ label: 'TLS', start: 8, end: 92, colorIndex: 2 },
{ label: 'Wait', start: 92, end: 245, colorIndex: 1 },
{ label: 'Receive', start: 245, end: 312, colorIndex: 3 },
];
const certInfo = [
{ label: 'Common Name', value: 'api.protoforge.io' },
{ label: 'Issuer', value: "Let's Encrypt R3" },
{ label: 'Valid From', value: '2026-04-12' },
{ label: 'Valid To', value: '2026-07-11' },
{ label: 'SHA-256', value: '6a:bf:34:8d:21:99…' },
];
</script>
<template>
<div style="height: 320px;">
<CfNetworkPane>
<template #panel-har>
<div style="display: flex; flex-direction: column; gap: 8px;">
<div style="display: flex; align-items: center; gap: 8px;">
<CfStatusCodeBadge :code="200" reason="OK" />
<span style="font-family: var(--font-mono); font-size: 12px;">/v1/orders · 312ms</span>
</div>
<CfTimingBar :phases="r1" />
</div>
</template>
<template #panel-hex>
<pre style="margin: 0; padding: 8px; font-family: var(--font-mono); font-size: 11px; line-height: 16px; color: var(--fg-1); background: var(--bg-2); border-radius: var(--r-3);">00000000 47 45 54 20 2f 76 31 2f 6f 72 64 65 72 73 20 48 GET /v1/orders H
00000010 54 54 50 2f 31 2e 31 0d 0a 48 6f 73 74 3a 20 61 TTP/1.1..Host: a
00000020 70 69 2e 70 72 6f 74 6f 66 6f 72 67 65 2e 69 6f pi.protoforge.io</pre>
</template>
<template #panel-pcap>
<p style="color: var(--fg-2); font-size: 13px;">Wireshark 风格的抓包行,由 PCAPRow 子组件渲染(待实现)。</p>
</template>
<template #panel-cert>
<CfDescriptionList :items="certInfo" />
</template>
<template #panel-cookie>
<p style="color: var(--fg-2); font-size: 13px;">域级 cookie 管理(基于 CfDataGrid)。</p>
</template>
</CfNetworkPane>
</div>
</template> <script setup>
import { CfNetworkPane, CfTimingBar, CfStatusCodeBadge, CfDescriptionList } from '@chufix-design/vue';
const r1 = [
{ label: 'DNS', start: 0, end: 8, colorIndex: 6 },
{ label: 'TLS', start: 8, end: 92, colorIndex: 2 },
{ label: 'Wait', start: 92, end: 245, colorIndex: 1 },
{ label: 'Receive', start: 245, end: 312, colorIndex: 3 },
];
const certInfo = [
{ label: 'Common Name', value: 'api.protoforge.io' },
{ label: 'Issuer', value: "Let's Encrypt R3" },
{ label: 'Valid From', value: '2026-04-12' },
{ label: 'Valid To', value: '2026-07-11' },
{ label: 'SHA-256', value: '6a:bf:34:8d:21:99…' },
];
</script>
<template>
<div style="height: 320px;">
<CfNetworkPane>
<template #panel-har>
<div style="display: flex; flex-direction: column; gap: 8px;">
<div style="display: flex; align-items: center; gap: 8px;">
<CfStatusCodeBadge :code="200" reason="OK" />
<span style="font-family: var(--font-mono); font-size: 12px;">/v1/orders · 312ms</span>
</div>
<CfTimingBar :phases="r1" />
</div>
</template>
<template #panel-hex>
<pre style="margin: 0; padding: 8px; font-family: var(--font-mono); font-size: 11px; line-height: 16px; color: var(--fg-1); background: var(--bg-2); border-radius: var(--r-3);">00000000 47 45 54 20 2f 76 31 2f 6f 72 64 65 72 73 20 48 GET /v1/orders H
00000010 54 54 50 2f 31 2e 31 0d 0a 48 6f 73 74 3a 20 61 TTP/1.1..Host: a
00000020 70 69 2e 70 72 6f 74 6f 66 6f 72 67 65 2e 69 6f pi.protoforge.io</pre>
</template>
<template #panel-pcap>
<p style="color: var(--fg-2); font-size: 13px;">Wireshark 风格的抓包行,由 PCAPRow 子组件渲染(待实现)。</p>
</template>
<template #panel-cert>
<CfDescriptionList :items="certInfo" />
</template>
<template #panel-cookie>
<p style="color: var(--fg-2); font-size: 13px;">域级 cookie 管理(基于 CfDataGrid)。</p>
</template>
</CfNetworkPane>
</div>
</template> <CfNetworkPane slots={{...}} /> <CfNetworkPane slots={{...}} /> API
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
modelValue / value | string | 第一个 tab id | 活动 tab |
tabs | TemplatePaneTab[] | 预设 | 自定义 tab 列表 |
size | 'sm' | 'md' | 'lg' | 'md' |
预设的 tab id 列表导出为 PROTOCOL_TABS / NETWORK_TABS / SQL_TABS 等常量,可在自定义 tabs 时直接拿来用。
模版组件本质是
CfTabs的语义薄壳。如果你不需要一组预定义 tab,直接用 CfTabs 即可。
反馈与讨论
NetworkPane 网络面板 的讨论