@yuku123/z-cognition-component 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,17 +4,17 @@ import { useNavigate as x } from "react-router-dom";
4
4
  import { Input as i, Form as a, Space as f, Button as d, Table as E, Tag as S, Modal as z, Select as O, message as m } from "antd";
5
5
  import { ReloadOutlined as P, PlusOutlined as $ } from "@ant-design/icons";
6
6
  import { cognitionApi as g } from "./api.js";
7
- import { K as q, C as F, a as N } from "./EvidenceFormList-097ICr7D.js";
8
- const { TextArea: j } = i;
7
+ import { K as k, C as q, a as F } from "./EvidenceFormList-097ICr7D.js";
8
+ const { TextArea: N } = i;
9
9
  function H() {
10
- const w = x(), [I, C] = r([]), [b, u] = r(!1), [p, h] = r(""), [K, s] = r(!1), [v, y] = r(!1), [c] = a.useForm(), l = async (t = p) => {
11
- u(!0);
10
+ const w = x(), [I, C] = r([]), [b, p] = r(!1), [u, h] = r(""), [K, s] = r(!1), [v, y] = r(!1), [c] = a.useForm(), l = async (t = u) => {
11
+ p(!0);
12
12
  try {
13
13
  C(await g.listConcepts({ domain: t }));
14
14
  } catch (n) {
15
15
  m.error(n.message);
16
16
  } finally {
17
- u(!1);
17
+ p(!1);
18
18
  }
19
19
  };
20
20
  return T(() => {
@@ -27,7 +27,7 @@ function H() {
27
27
  placeholder: "域(如 trade)",
28
28
  allowClear: !0,
29
29
  style: { width: 180 },
30
- value: p,
30
+ value: u,
31
31
  onChange: (t) => h(t.target.value),
32
32
  onPressEnter: () => l()
33
33
  }
@@ -59,6 +59,7 @@ function H() {
59
59
  render: (t, n) => /* @__PURE__ */ e(
60
60
  d,
61
61
  {
62
+ type: "link",
62
63
  size: "small",
63
64
  onClick: () => w(`/cognition/impact?subjectType=concept&subjectKey=${encodeURIComponent(n.conceptKey)}`),
64
65
  children: "影响面"
@@ -101,18 +102,18 @@ function H() {
101
102
  label: "conceptKey",
102
103
  rules: [
103
104
  { required: !0, message: "必填" },
104
- { pattern: q, message: "^[a-z][a-z0-9_.-]{1,127}$" }
105
+ { pattern: k, message: "^[a-z][a-z0-9_.-]{1,127}$" }
105
106
  ],
106
107
  children: /* @__PURE__ */ e(i, { style: { width: 240 }, placeholder: "order" })
107
108
  }
108
109
  ),
109
110
  /* @__PURE__ */ e(a.Item, { name: "name", label: "名称", rules: [{ required: !0, message: "必填" }], children: /* @__PURE__ */ e(i, { style: { width: 200 }, placeholder: "订单" }) }),
110
- /* @__PURE__ */ e(a.Item, { name: "conceptType", label: "类型", rules: [{ required: !0, message: "必填" }], initialValue: "ENTITY", children: /* @__PURE__ */ e(O, { style: { width: 140 }, options: F.map((t) => ({ value: t, label: t })) }) }),
111
+ /* @__PURE__ */ e(a.Item, { name: "conceptType", label: "类型", rules: [{ required: !0, message: "必填" }], initialValue: "ENTITY", children: /* @__PURE__ */ e(O, { style: { width: 140 }, options: q.map((t) => ({ value: t, label: t })) }) }),
111
112
  /* @__PURE__ */ e(a.Item, { name: "domain", label: "域", children: /* @__PURE__ */ e(i, { style: { width: 140 } }) }),
112
113
  /* @__PURE__ */ e(a.Item, { name: "parentKey", label: "父概念", children: /* @__PURE__ */ e(i, { style: { width: 180 } }) })
113
114
  ] }),
114
- /* @__PURE__ */ e(a.Item, { name: "definition", label: "定义", rules: [{ required: !0, message: "必填" }], children: /* @__PURE__ */ e(j, { rows: 3 }) }),
115
- /* @__PURE__ */ e(a.Item, { label: "证据(至少一条)", required: !0, children: /* @__PURE__ */ e(N, {}) })
115
+ /* @__PURE__ */ e(a.Item, { name: "definition", label: "定义", rules: [{ required: !0, message: "必填" }], children: /* @__PURE__ */ e(N, { rows: 3 }) }),
116
+ /* @__PURE__ */ e(a.Item, { label: "证据(至少一条)", required: !0, children: /* @__PURE__ */ e(F, {}) })
116
117
  ] })
117
118
  }
118
119
  )
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("react"),S=require("react-router-dom"),t=require("antd"),p=require("@ant-design/icons"),h=require("./api.cjs"),l=require("./EvidenceFormList-CQNgMNCG.cjs"),{TextArea:b}=t.Input;function v(){const x=S.useNavigate(),[y,g]=a.useState([]),[j,c]=a.useState(!1),[d,u]=a.useState(""),[w,r]=a.useState(!1),[I,m]=a.useState(!1),[o]=t.Form.useForm(),i=async(n=d)=>{c(!0);try{g(await h.cognitionApi.listConcepts({domain:n}))}catch(s){t.message.error(s.message)}finally{c(!1)}};a.useEffect(()=>{i()},[]);const f=async()=>{const n=await o.validateFields();m(!0);try{await h.cognitionApi.createConcept({...n,actor:n.actor||"console",note:n.note||"console create"}),t.message.success(`概念 ${n.conceptKey} 已登记`),r(!1),o.resetFields(),await i()}catch(s){t.message.error(s.field?`${s.field}: ${s.message}`:s.message)}finally{m(!1)}};return e.jsxs("div",{children:[e.jsxs(t.Space,{wrap:!0,style:{marginBottom:16},children:[e.jsx(t.Input,{placeholder:"域(如 trade)",allowClear:!0,style:{width:180},value:d,onChange:n=>u(n.target.value),onPressEnter:()=>i()}),e.jsx(t.Button,{icon:e.jsx(p.ReloadOutlined,{}),onClick:()=>{u(""),i("")},children:"重置"}),e.jsx(t.Button,{type:"primary",icon:e.jsx(p.PlusOutlined,{}),onClick:()=>r(!0),children:"新建概念"})]}),e.jsx(t.Table,{rowKey:"conceptKey",size:"middle",loading:j,dataSource:y,pagination:{pageSize:20,showSizeChanger:!1},columns:[{title:"conceptKey",dataIndex:"conceptKey",width:200},{title:"名称",dataIndex:"name",width:180},{title:"类型",dataIndex:"conceptType",width:120,render:n=>e.jsx(t.Tag,{children:n})},{title:"域",dataIndex:"domain",width:120},{title:"父概念",dataIndex:"parentKey",width:180,render:n=>n||"—"},{title:"版本",dataIndex:"revisionNo",width:70,render:n=>`r${n}`},{title:"定义",dataIndex:"definition",ellipsis:!0},{title:"操作",width:110,render:(n,s)=>e.jsx(t.Button,{size:"small",onClick:()=>x(`/cognition/impact?subjectType=concept&subjectKey=${encodeURIComponent(s.conceptKey)}`),children:"影响面"})}]}),e.jsx(t.Modal,{title:"新建概念(证据必填)",open:w,onCancel:()=>r(!1),onOk:f,confirmLoading:I,width:800,destroyOnHidden:!0,children:e.jsxs(t.Form,{form:o,layout:"vertical",children:[e.jsxs(t.Space,{size:"large",wrap:!0,children:[e.jsx(t.Form.Item,{name:"conceptKey",label:"conceptKey",rules:[{required:!0,message:"必填"},{pattern:l.KEY_PATTERN,message:"^[a-z][a-z0-9_.-]{1,127}$"}],children:e.jsx(t.Input,{style:{width:240},placeholder:"order"})}),e.jsx(t.Form.Item,{name:"name",label:"名称",rules:[{required:!0,message:"必填"}],children:e.jsx(t.Input,{style:{width:200},placeholder:"订单"})}),e.jsx(t.Form.Item,{name:"conceptType",label:"类型",rules:[{required:!0,message:"必填"}],initialValue:"ENTITY",children:e.jsx(t.Select,{style:{width:140},options:l.CONCEPT_TYPES.map(n=>({value:n,label:n}))})}),e.jsx(t.Form.Item,{name:"domain",label:"域",children:e.jsx(t.Input,{style:{width:140}})}),e.jsx(t.Form.Item,{name:"parentKey",label:"父概念",children:e.jsx(t.Input,{style:{width:180}})})]}),e.jsx(t.Form.Item,{name:"definition",label:"定义",rules:[{required:!0,message:"必填"}],children:e.jsx(b,{rows:3})}),e.jsx(t.Form.Item,{label:"证据(至少一条)",required:!0,children:e.jsx(l.EvidenceFormList,{})})]})})]})}exports.default=v;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("react"),S=require("react-router-dom"),t=require("antd"),p=require("@ant-design/icons"),h=require("./api.cjs"),l=require("./EvidenceFormList-CQNgMNCG.cjs"),{TextArea:b}=t.Input;function v(){const x=S.useNavigate(),[y,g]=a.useState([]),[j,c]=a.useState(!1),[d,u]=a.useState(""),[w,r]=a.useState(!1),[I,m]=a.useState(!1),[o]=t.Form.useForm(),i=async(n=d)=>{c(!0);try{g(await h.cognitionApi.listConcepts({domain:n}))}catch(s){t.message.error(s.message)}finally{c(!1)}};a.useEffect(()=>{i()},[]);const f=async()=>{const n=await o.validateFields();m(!0);try{await h.cognitionApi.createConcept({...n,actor:n.actor||"console",note:n.note||"console create"}),t.message.success(`概念 ${n.conceptKey} 已登记`),r(!1),o.resetFields(),await i()}catch(s){t.message.error(s.field?`${s.field}: ${s.message}`:s.message)}finally{m(!1)}};return e.jsxs("div",{children:[e.jsxs(t.Space,{wrap:!0,style:{marginBottom:16},children:[e.jsx(t.Input,{placeholder:"域(如 trade)",allowClear:!0,style:{width:180},value:d,onChange:n=>u(n.target.value),onPressEnter:()=>i()}),e.jsx(t.Button,{icon:e.jsx(p.ReloadOutlined,{}),onClick:()=>{u(""),i("")},children:"重置"}),e.jsx(t.Button,{type:"primary",icon:e.jsx(p.PlusOutlined,{}),onClick:()=>r(!0),children:"新建概念"})]}),e.jsx(t.Table,{rowKey:"conceptKey",size:"middle",loading:j,dataSource:y,pagination:{pageSize:20,showSizeChanger:!1},columns:[{title:"conceptKey",dataIndex:"conceptKey",width:200},{title:"名称",dataIndex:"name",width:180},{title:"类型",dataIndex:"conceptType",width:120,render:n=>e.jsx(t.Tag,{children:n})},{title:"域",dataIndex:"domain",width:120},{title:"父概念",dataIndex:"parentKey",width:180,render:n=>n||"—"},{title:"版本",dataIndex:"revisionNo",width:70,render:n=>`r${n}`},{title:"定义",dataIndex:"definition",ellipsis:!0},{title:"操作",width:110,render:(n,s)=>e.jsx(t.Button,{type:"link",size:"small",onClick:()=>x(`/cognition/impact?subjectType=concept&subjectKey=${encodeURIComponent(s.conceptKey)}`),children:"影响面"})}]}),e.jsx(t.Modal,{title:"新建概念(证据必填)",open:w,onCancel:()=>r(!1),onOk:f,confirmLoading:I,width:800,destroyOnHidden:!0,children:e.jsxs(t.Form,{form:o,layout:"vertical",children:[e.jsxs(t.Space,{size:"large",wrap:!0,children:[e.jsx(t.Form.Item,{name:"conceptKey",label:"conceptKey",rules:[{required:!0,message:"必填"},{pattern:l.KEY_PATTERN,message:"^[a-z][a-z0-9_.-]{1,127}$"}],children:e.jsx(t.Input,{style:{width:240},placeholder:"order"})}),e.jsx(t.Form.Item,{name:"name",label:"名称",rules:[{required:!0,message:"必填"}],children:e.jsx(t.Input,{style:{width:200},placeholder:"订单"})}),e.jsx(t.Form.Item,{name:"conceptType",label:"类型",rules:[{required:!0,message:"必填"}],initialValue:"ENTITY",children:e.jsx(t.Select,{style:{width:140},options:l.CONCEPT_TYPES.map(n=>({value:n,label:n}))})}),e.jsx(t.Form.Item,{name:"domain",label:"域",children:e.jsx(t.Input,{style:{width:140}})}),e.jsx(t.Form.Item,{name:"parentKey",label:"父概念",children:e.jsx(t.Input,{style:{width:180}})})]}),e.jsx(t.Form.Item,{name:"definition",label:"定义",rules:[{required:!0,message:"必填"}],children:e.jsx(b,{rows:3})}),e.jsx(t.Form.Item,{label:"证据(至少一条)",required:!0,children:e.jsx(l.EvidenceFormList,{})})]})})]})}exports.default=v;
@@ -0,0 +1,192 @@
1
+ import { jsx as t, jsxs as r, Fragment as q } from "react/jsx-runtime";
2
+ import { useState as c, useRef as F, useEffect as U, useMemo as I } from "react";
3
+ import { useSearchParams as W, useNavigate as G } from "react-router-dom";
4
+ import { Empty as H, Tag as d, Input as N, Button as _, Spin as J, Tabs as Q, Table as k, Space as $, message as V } from "antd";
5
+ import { ApartmentOutlined as X, ReloadOutlined as Y, NodeIndexOutlined as Z } from "@ant-design/icons";
6
+ import { f as z, o as m } from "./api-BVrIcAFp.js";
7
+ import "@antv/g6";
8
+ import "d3-force";
9
+ function oe() {
10
+ const [O] = W(), n = O.get("id") || "", j = G(), [v, w] = c("default"), [l, T] = c(null), [h, L] = c([]), [y, A] = c([]), [x, K] = c([]), [R, C] = c(!1), [f, D] = c(""), o = F(0), g = async (e = v) => {
11
+ if (!n) return;
12
+ const a = ++o.current;
13
+ C(!0);
14
+ const i = (s, u) => V.error(`${s}取数失败:${u.message}`), b = [
15
+ ["统计", () => m.stats(n, e).then((s) => T(s))],
16
+ ["类列表", () => m.listClasses(n, e).then((s) => L(s || []))],
17
+ ["实例列表", () => m.listIndividuals(n, e).then((s) => A(s || []))]
18
+ ];
19
+ for (const [s, u] of b) {
20
+ if (a !== o.current) return;
21
+ try {
22
+ await u();
23
+ } catch (p) {
24
+ a === o.current && i(s, p);
25
+ }
26
+ }
27
+ try {
28
+ const u = ((h.length ? h : await m.listClasses(n, e)) || []).map((P) => P.key), p = await m.subgraph(n, u, 1, e);
29
+ a === o.current && K((p == null ? void 0 : p.edges) || []);
30
+ } catch (s) {
31
+ a === o.current && i("关系", s);
32
+ }
33
+ a === o.current && C(!1);
34
+ };
35
+ U(() => (n && (w("default"), g("default")), () => {
36
+ o.current += 1;
37
+ }), [n]);
38
+ const E = I(() => l ? [
39
+ { label: "类节点", value: l.class_nodes ?? l.classNodes ?? 0, sub: "classes" },
40
+ { label: "实例节点", value: l.individual_nodes ?? l.individualNodes ?? 0, sub: "individuals" },
41
+ { label: "总节点", value: l.node_count ?? l.nodeCount ?? 0, sub: "nodes" },
42
+ { label: "关系边", value: l.edge_count ?? l.edgeCount ?? 0, sub: "edges" },
43
+ { label: "显式陈述", value: l.explicit_statements ?? l.explicitStatements ?? 0, sub: "explicit" },
44
+ { label: "推理陈述", value: l.inferred_statements ?? l.inferredStatements ?? 0, sub: "inferred" }
45
+ ] : [], [l]), S = [
46
+ { title: "key", dataIndex: "key", key: "key", width: 240 },
47
+ {
48
+ title: "标签",
49
+ dataIndex: "labels",
50
+ key: "labels",
51
+ width: 220,
52
+ render: (e) => (e || []).map((a) => /* @__PURE__ */ t(d, { color: a === "OntologyClass" ? "purple" : a === "OntologyIndividual" ? "blue" : void 0, children: a }, a))
53
+ },
54
+ {
55
+ title: "属性",
56
+ dataIndex: "properties",
57
+ key: "properties",
58
+ render: (e) => /* @__PURE__ */ r($, { size: 4, wrap: !0, children: [
59
+ Object.entries(e || {}).slice(0, 8).map(([a, i]) => /* @__PURE__ */ r(d, { color: "default", children: [
60
+ a,
61
+ "=",
62
+ String(i)
63
+ ] }, a)),
64
+ Object.keys(e || {}).length > 8 ? /* @__PURE__ */ r(d, { children: [
65
+ "+",
66
+ Object.keys(e).length - 8
67
+ ] }) : null
68
+ ] })
69
+ }
70
+ ], M = [
71
+ { title: "from", dataIndex: "from_key", key: "from_key", width: 220 },
72
+ { title: "type", dataIndex: "type", key: "type", width: 160, render: (e) => /* @__PURE__ */ t(d, { color: "geekblue", children: e }) },
73
+ { title: "to", dataIndex: "to_key", key: "to_key", width: 220 },
74
+ {
75
+ title: "属性",
76
+ dataIndex: "properties",
77
+ key: "properties",
78
+ render: (e) => /* @__PURE__ */ t($, { size: 4, wrap: !0, children: Object.entries(e || {}).slice(0, 4).map(([a, i]) => /* @__PURE__ */ r(d, { color: "default", children: [
79
+ a,
80
+ "=",
81
+ String(i)
82
+ ] }, a)) })
83
+ }
84
+ ], B = I(() => {
85
+ const e = f.trim().toLowerCase();
86
+ return e ? (y || []).filter(
87
+ (a) => a.key.toLowerCase().includes(e) || (a.labels || []).some((i) => i.toLowerCase().includes(e)) || Object.entries(a.properties || {}).some(([i, b]) => `${i}=${b}`.toLowerCase().includes(e))
88
+ ) : y;
89
+ }, [y, f]);
90
+ return n ? /* @__PURE__ */ r("div", { className: "view", children: [
91
+ /* @__PURE__ */ r("div", { className: "view-bar", children: [
92
+ /* @__PURE__ */ r(d, { icon: /* @__PURE__ */ t(X, {}), color: "purple", children: [
93
+ "本体 ",
94
+ n
95
+ ] }),
96
+ /* @__PURE__ */ t(
97
+ N.Search,
98
+ {
99
+ style: { width: 200 },
100
+ placeholder: "工作空间(默认 default)",
101
+ value: v,
102
+ onChange: (e) => w(e.target.value),
103
+ onSearch: () => g()
104
+ }
105
+ ),
106
+ /* @__PURE__ */ t(_, { icon: /* @__PURE__ */ t(Y, {}), onClick: () => g(), children: "刷新" }),
107
+ /* @__PURE__ */ t(
108
+ _,
109
+ {
110
+ type: "primary",
111
+ icon: /* @__PURE__ */ t(Z, {}),
112
+ onClick: () => j(`/ontology/nodes?id=${encodeURIComponent(n)}`),
113
+ children: "图谱"
114
+ }
115
+ ),
116
+ /* @__PURE__ */ t("span", { className: "hint spacer" }),
117
+ /* @__PURE__ */ t("span", { className: "hint", children: z(l, "lastMaterializedAt", "last_materialized_at") ? `物化于 ${new Date(z(l, "lastMaterializedAt", "last_materialized_at")).toLocaleString()}` : "" })
118
+ ] }),
119
+ l ? /* @__PURE__ */ t("div", { className: "stat-cards", children: E.map((e) => /* @__PURE__ */ r("div", { className: "stat-card", children: [
120
+ /* @__PURE__ */ t("span", { className: "label", children: e.label }),
121
+ /* @__PURE__ */ t("span", { className: "value", children: e.value }),
122
+ /* @__PURE__ */ t("span", { className: "sub", children: e.sub })
123
+ ] }, e.label)) }) : null,
124
+ /* @__PURE__ */ t(J, { spinning: R, children: /* @__PURE__ */ t(
125
+ Q,
126
+ {
127
+ items: [
128
+ {
129
+ key: "classes",
130
+ label: `类定义(${h.length})`,
131
+ children: /* @__PURE__ */ t(
132
+ k,
133
+ {
134
+ rowKey: "key",
135
+ size: "small",
136
+ columns: S,
137
+ dataSource: h,
138
+ pagination: !1,
139
+ locale: { emptyText: /* @__PURE__ */ t("span", { className: "empty-note", children: "暂无类定义(可先登记 schema 或物化)" }) }
140
+ }
141
+ )
142
+ },
143
+ {
144
+ key: "edges",
145
+ label: `关系(${x.length})`,
146
+ children: /* @__PURE__ */ t(
147
+ k,
148
+ {
149
+ rowKey: (e) => e.key || `${e.from_key}|${e.type}|${e.to_key}`,
150
+ size: "small",
151
+ columns: M,
152
+ dataSource: x,
153
+ pagination: !1,
154
+ locale: { emptyText: /* @__PURE__ */ t("span", { className: "empty-note", children: "暂无关系边" }) }
155
+ }
156
+ )
157
+ },
158
+ {
159
+ key: "individuals",
160
+ label: `实例(${y.length})`,
161
+ children: /* @__PURE__ */ r(q, { children: [
162
+ /* @__PURE__ */ t("div", { style: { marginBottom: 8 }, children: /* @__PURE__ */ t(
163
+ N.Search,
164
+ {
165
+ allowClear: !0,
166
+ style: { width: 320 },
167
+ placeholder: "按 key / 标签 / 属性搜索实例",
168
+ value: f,
169
+ onChange: (e) => D(e.target.value)
170
+ }
171
+ ) }),
172
+ /* @__PURE__ */ t(
173
+ k,
174
+ {
175
+ rowKey: "key",
176
+ size: "small",
177
+ columns: S,
178
+ dataSource: B,
179
+ pagination: { pageSize: 20, showSizeChanger: !0, showTotal: (e) => `共 ${e} 条` },
180
+ locale: { emptyText: /* @__PURE__ */ t("span", { className: "empty-note", children: "暂无实例" }) }
181
+ }
182
+ )
183
+ ] })
184
+ }
185
+ ]
186
+ }
187
+ ) })
188
+ ] }) : /* @__PURE__ */ t(H, { description: "缺少本体 ID(?id=xxx)", style: { padding: 48 } });
189
+ }
190
+ export {
191
+ oe as default
192
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),r=require("react"),w=require("react-router-dom"),a=require("antd"),f=require("@ant-design/icons"),d=require("./api-D5Hgcud4.cjs");require("@antv/g6");require("d3-force");function M(){const[C]=w.useSearchParams(),i=C.get("id")||"",I=w.useNavigate(),[j,b]=r.useState("default"),[l,N]=r.useState(null),[m,_]=r.useState([]),[y,T]=r.useState([]),[k,$]=r.useState([]),[O,v]=r.useState(!1),[h,z]=r.useState(""),c=r.useRef(0),g=async(e=j)=>{if(!i)return;const s=++c.current;v(!0);const o=(n,u)=>a.message.error(`${n}取数失败:${u.message}`),x=[["统计",()=>d.ontologyApi.stats(i,e).then(n=>N(n))],["类列表",()=>d.ontologyApi.listClasses(i,e).then(n=>_(n||[]))],["实例列表",()=>d.ontologyApi.listIndividuals(i,e).then(n=>T(n||[]))]];for(const[n,u]of x){if(s!==c.current)return;try{await u()}catch(p){s===c.current&&o(n,p)}}try{const u=((m.length?m:await d.ontologyApi.listClasses(i,e))||[]).map(L=>L.key),p=await d.ontologyApi.subgraph(i,u,1,e);s===c.current&&$((p==null?void 0:p.edges)||[])}catch(n){s===c.current&&o("关系",n)}s===c.current&&v(!1)};r.useEffect(()=>(i&&(b("default"),g("default")),()=>{c.current+=1}),[i]);const q=r.useMemo(()=>l?[{label:"类节点",value:l.class_nodes??l.classNodes??0,sub:"classes"},{label:"实例节点",value:l.individual_nodes??l.individualNodes??0,sub:"individuals"},{label:"总节点",value:l.node_count??l.nodeCount??0,sub:"nodes"},{label:"关系边",value:l.edge_count??l.edgeCount??0,sub:"edges"},{label:"显式陈述",value:l.explicit_statements??l.explicitStatements??0,sub:"explicit"},{label:"推理陈述",value:l.inferred_statements??l.inferredStatements??0,sub:"inferred"}]:[],[l]),S=[{title:"key",dataIndex:"key",key:"key",width:240},{title:"标签",dataIndex:"labels",key:"labels",width:220,render:e=>(e||[]).map(s=>t.jsx(a.Tag,{color:s==="OntologyClass"?"purple":s==="OntologyIndividual"?"blue":void 0,children:s},s))},{title:"属性",dataIndex:"properties",key:"properties",render:e=>t.jsxs(a.Space,{size:4,wrap:!0,children:[Object.entries(e||{}).slice(0,8).map(([s,o])=>t.jsxs(a.Tag,{color:"default",children:[s,"=",String(o)]},s)),Object.keys(e||{}).length>8?t.jsxs(a.Tag,{children:["+",Object.keys(e).length-8]}):null]})}],A=[{title:"from",dataIndex:"from_key",key:"from_key",width:220},{title:"type",dataIndex:"type",key:"type",width:160,render:e=>t.jsx(a.Tag,{color:"geekblue",children:e})},{title:"to",dataIndex:"to_key",key:"to_key",width:220},{title:"属性",dataIndex:"properties",key:"properties",render:e=>t.jsx(a.Space,{size:4,wrap:!0,children:Object.entries(e||{}).slice(0,4).map(([s,o])=>t.jsxs(a.Tag,{color:"default",children:[s,"=",String(o)]},s))})}],R=r.useMemo(()=>{const e=h.trim().toLowerCase();return e?(y||[]).filter(s=>s.key.toLowerCase().includes(e)||(s.labels||[]).some(o=>o.toLowerCase().includes(e))||Object.entries(s.properties||{}).some(([o,x])=>`${o}=${x}`.toLowerCase().includes(e))):y},[y,h]);return i?t.jsxs("div",{className:"view",children:[t.jsxs("div",{className:"view-bar",children:[t.jsxs(a.Tag,{icon:t.jsx(f.ApartmentOutlined,{}),color:"purple",children:["本体 ",i]}),t.jsx(a.Input.Search,{style:{width:200},placeholder:"工作空间(默认 default)",value:j,onChange:e=>b(e.target.value),onSearch:()=>g()}),t.jsx(a.Button,{icon:t.jsx(f.ReloadOutlined,{}),onClick:()=>g(),children:"刷新"}),t.jsx(a.Button,{type:"primary",icon:t.jsx(f.NodeIndexOutlined,{}),onClick:()=>I(`/ontology/nodes?id=${encodeURIComponent(i)}`),children:"图谱"}),t.jsx("span",{className:"hint spacer"}),t.jsx("span",{className:"hint",children:d.field(l,"lastMaterializedAt","last_materialized_at")?`物化于 ${new Date(d.field(l,"lastMaterializedAt","last_materialized_at")).toLocaleString()}`:""})]}),l?t.jsx("div",{className:"stat-cards",children:q.map(e=>t.jsxs("div",{className:"stat-card",children:[t.jsx("span",{className:"label",children:e.label}),t.jsx("span",{className:"value",children:e.value}),t.jsx("span",{className:"sub",children:e.sub})]},e.label))}):null,t.jsx(a.Spin,{spinning:O,children:t.jsx(a.Tabs,{items:[{key:"classes",label:`类定义(${m.length})`,children:t.jsx(a.Table,{rowKey:"key",size:"small",columns:S,dataSource:m,pagination:!1,locale:{emptyText:t.jsx("span",{className:"empty-note",children:"暂无类定义(可先登记 schema 或物化)"})}})},{key:"edges",label:`关系(${k.length})`,children:t.jsx(a.Table,{rowKey:e=>e.key||`${e.from_key}|${e.type}|${e.to_key}`,size:"small",columns:A,dataSource:k,pagination:!1,locale:{emptyText:t.jsx("span",{className:"empty-note",children:"暂无关系边"})}})},{key:"individuals",label:`实例(${y.length})`,children:t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{marginBottom:8},children:t.jsx(a.Input.Search,{allowClear:!0,style:{width:320},placeholder:"按 key / 标签 / 属性搜索实例",value:h,onChange:e=>z(e.target.value)})}),t.jsx(a.Table,{rowKey:"key",size:"small",columns:S,dataSource:R,pagination:{pageSize:20,showSizeChanger:!0,showTotal:e=>`共 ${e} 条`},locale:{emptyText:t.jsx("span",{className:"empty-note",children:"暂无实例"})}})]})}]})})]}):t.jsx(a.Empty,{description:"缺少本体 ID(?id=xxx)",style:{padding:48}})}exports.default=M;
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),g=require("react-router-dom"),t=require("antd"),f=require("@ant-design/icons"),a=require("./api-D5Hgcud4.cjs"),b=require("./OntologyValidatePage-40ZvGGH4.cjs"),{TextArea:S}=t.Input;function T(){const[h]=g.useSearchParams(),r=h.get("id")||"",[d,x]=l.useState(`{
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),g=require("react-router-dom"),t=require("antd"),f=require("@ant-design/icons"),a=require("./api-D5Hgcud4.cjs"),b=require("./OntologyValidatePage-Dqzp4hWg.cjs"),{TextArea:S}=t.Input;function T(){const[h]=g.useSearchParams(),r=h.get("id")||"",[d,x]=l.useState(`{
2
2
  "individuals": [],
3
3
  "statements": []
4
4
  }`),[n,o]=l.useState(null),[p,c]=l.useState(!1),y=async()=>{c(!0),o(null);try{o(await a.ontologyApi.infer(r,b.parseSnapshot(d)))}catch(s){t.message.error(s.message)}finally{c(!1)}};if(!r)return e.jsx(t.Alert,{type:"warning",message:"缺少本体 ID(?id=xxx)"});const m=[{title:"主体",dataIndex:"subject",key:"subject",width:180},{title:"谓词",dataIndex:"predicate",key:"predicate",width:160},{title:"客体",dataIndex:"object",key:"object",width:180},{title:"性质",key:"nature",width:140,render:(s,i)=>e.jsxs(t.Space,{size:4,children:[i.inferred?e.jsx(t.Tag,{color:"blue",children:"推理"}):e.jsx(t.Tag,{children:"显式"}),i.literal?e.jsx(t.Tag,{color:"orange",children:"字面量"}):null]})}],j=[{title:"key",dataIndex:"key",key:"key",width:200},{title:"名称",dataIndex:"name",key:"name",width:160},{title:"显式类型",dataIndex:"types",key:"types",width:200,render:s=>(s||[]).map(i=>e.jsx(t.Tag,{children:i},i))},{title:"推理类型",dataIndex:"inferredTypes",key:"inferredTypes",render:(s,i)=>(a.field(i,"inferredTypes")||[]).map(u=>e.jsx(t.Tag,{color:"blue",children:u},u))}];return e.jsxs(t.Spin,{spinning:p,children:[e.jsx(t.Card,{size:"small",title:"推理输入(OntologySnapshot)",style:{marginBottom:16},children:e.jsxs(t.Space,{direction:"vertical",style:{width:"100%"},children:[e.jsx(S,{rows:10,value:d,onChange:s=>x(s.target.value),placeholder:'{"individuals": [], "statements": []}'}),e.jsx(t.Button,{type:"primary",icon:e.jsx(f.ThunderboltOutlined,{}),onClick:y,children:"开始推理"})]})}),n?e.jsxs(e.Fragment,{children:[e.jsx(t.Card,{size:"small",title:"推理概览",style:{marginBottom:16},children:e.jsxs(t.Space,{size:"large",wrap:!0,children:[e.jsxs("span",{children:["显式陈述 ",e.jsx("b",{children:a.field(n,"explicitStatements")})]}),e.jsxs("span",{children:["推理陈述 ",e.jsx("b",{children:a.field(n,"inferredStatements")})]}),e.jsxs("span",{children:["显式类型 ",e.jsx("b",{children:a.field(n,"explicitTypes")})]}),e.jsxs("span",{children:["推理类型 ",e.jsx("b",{children:a.field(n,"inferredTypes")})]})]})}),e.jsx(t.Card,{size:"small",title:`个体(${(n.individuals||[]).length})`,style:{marginBottom:16},children:e.jsx(t.Table,{rowKey:"key",size:"small",columns:j,dataSource:n.individuals||[],pagination:!1})}),e.jsx(t.Card,{size:"small",title:`陈述(${(n.statements||[]).length})`,children:e.jsx(t.Table,{rowKey:(s,i)=>`${s.subject}-${s.predicate}-${s.object}-${i}`,size:"small",columns:m,dataSource:n.statements||[],pagination:!1})})]}):null]})}exports.default=T;
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("react"),D=require("react-router-dom"),s=require("antd"),z=require("@ant-design/icons"),l=require("./api-D5Hgcud4.cjs"),C=require("./OntologyValidatePage-40ZvGGH4.cjs"),{TextArea:q}=s.Input;function A(){var x;const[j]=D.useSearchParams(),r=j.get("id")||"",[a,f]=n.useState("source"),[c,y]=n.useState("default"),[o,u]=n.useState(""),[p,S]=n.useState(`{
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("react"),D=require("react-router-dom"),s=require("antd"),z=require("@ant-design/icons"),l=require("./api-D5Hgcud4.cjs"),C=require("./OntologyValidatePage-Dqzp4hWg.cjs"),{TextArea:q}=s.Input;function R(){var x;const[j]=D.useSearchParams(),r=j.get("id")||"",[a,f]=n.useState("source"),[c,y]=n.useState("default"),[o,u]=n.useState(""),[p,S]=n.useState(`{
2
2
  "individuals": [],
3
3
  "statements": []
4
- }`),[v,h]=n.useState([]),[i,d]=n.useState(null),[b,m]=n.useState(!1);n.useEffect(()=>{r&&l.ontologyApi.listSources().then(h).catch(()=>h([]))},[r]);const I=async()=>{m(!0),d(null);try{if(a==="source"){if(!o.trim()){s.message.warning("按来源物化需要指定 source");return}d(await l.ontologyApi.materialize(r,o.trim(),c))}else d(await l.ontologyApi.materializeInline(r,C.parseSnapshot(p),c))}catch(t){s.message.error(t.message)}finally{m(!1)}};if(!r)return e.jsx(s.Alert,{type:"warning",message:"缺少本体 ID(?id=xxx)"});const g=((x=i==null?void 0:i.validation)==null?void 0:x.issues)||[];return e.jsxs(s.Spin,{spinning:b,children:[e.jsx(s.Card,{size:"small",title:"物化输入",style:{marginBottom:16},children:e.jsxs(s.Space,{direction:"vertical",style:{width:"100%"},size:12,children:[e.jsxs(s.Space,{wrap:!0,children:[e.jsx(s.Select,{style:{width:200},value:a,onChange:f,options:[{value:"source",label:"按来源物化"},{value:"inline",label:"内联快照物化"}]}),e.jsx(s.Input,{style:{width:220},placeholder:"工作空间",value:c,onChange:t=>y(t.target.value)}),a==="source"?e.jsx(s.Select,{style:{width:280},placeholder:"选择数据源",value:o||void 0,onChange:u,showSearch:!0,options:v.map(t=>({value:t.id,label:t.description?`${t.id} — ${t.description}`:t.id})),notFoundContent:null}):null,e.jsx(s.Button,{type:"primary",icon:e.jsx(z.DatabaseOutlined,{}),onClick:I,children:"执行物化"})]}),a==="source"?e.jsx(s.Input,{style:{width:420},placeholder:"source ID(可直接输入)",value:o,onChange:t=>u(t.target.value)}):e.jsx(q,{rows:10,value:p,onChange:t=>S(t.target.value),placeholder:'{"individuals": [], "statements": []}'})]})}),i?e.jsxs(s.Card,{size:"small",title:"物化报告",children:[e.jsxs(s.Descriptions,{bordered:!0,size:"small",column:2,style:{marginBottom:12},children:[e.jsx(s.Descriptions.Item,{label:"本体",children:l.field(i,"ontologyId")}),e.jsx(s.Descriptions.Item,{label:"工作空间",children:l.field(i,"workspace")}),e.jsx(s.Descriptions.Item,{label:"来源",children:l.field(i,"sourceId")||"(内联)"}),e.jsxs(s.Descriptions.Item,{label:"耗时",children:[l.field(i,"durationMs")," ms"]}),e.jsx(s.Descriptions.Item,{label:"类节点",children:l.field(i,"classNodes")}),e.jsx(s.Descriptions.Item,{label:"实例节点",children:l.field(i,"individualNodes")}),e.jsx(s.Descriptions.Item,{label:"边",children:l.field(i,"edges")}),e.jsx(s.Descriptions.Item,{label:"物化时间",children:l.field(i,"materializedAt")||"—"})]}),e.jsxs(s.Space,{size:"large",wrap:!0,style:{marginBottom:8},children:[e.jsxs("span",{children:["显式陈述 ",e.jsx("b",{children:l.field(i,"explicitStatements")})]}),e.jsxs("span",{children:["推理陈述 ",e.jsx("b",{children:l.field(i,"inferredStatements")})]})]}),g.length?e.jsx("div",{children:g.map((t,w)=>e.jsxs(s.Tag,{color:t.severity==="ERROR"?"red":"orange",children:[t.code," ",t.message]},w))}):e.jsx(s.Tag,{color:"green",children:"物化通过,无校验问题"})]}):null]})}exports.default=A;
4
+ }`),[v,h]=n.useState([]),[i,d]=n.useState(null),[b,m]=n.useState(!1);n.useEffect(()=>{r&&l.ontologyApi.listSources().then(h).catch(()=>h([]))},[r]);const I=async()=>{m(!0),d(null);try{if(a==="source"){if(!o.trim()){s.message.warning("按来源物化需要指定 source");return}d(await l.ontologyApi.materialize(r,o.trim(),c))}else d(await l.ontologyApi.materializeInline(r,C.parseSnapshot(p),c))}catch(t){s.message.error(t.message)}finally{m(!1)}};if(!r)return e.jsx(s.Alert,{type:"warning",message:"缺少本体 ID(?id=xxx)"});const g=((x=i==null?void 0:i.validation)==null?void 0:x.issues)||[];return e.jsxs(s.Spin,{spinning:b,children:[e.jsx(s.Card,{size:"small",title:"物化输入",style:{marginBottom:16},children:e.jsxs(s.Space,{direction:"vertical",style:{width:"100%"},size:12,children:[e.jsxs(s.Space,{wrap:!0,children:[e.jsx(s.Select,{style:{width:200},value:a,onChange:f,options:[{value:"source",label:"按来源物化"},{value:"inline",label:"内联快照物化"}]}),e.jsx(s.Input,{style:{width:220},placeholder:"工作空间",value:c,onChange:t=>y(t.target.value)}),a==="source"?e.jsx(s.Select,{style:{width:280},placeholder:"选择数据源",value:o||void 0,onChange:u,showSearch:!0,options:v.map(t=>({value:t.id,label:t.description?`${t.id} — ${t.description}`:t.id})),notFoundContent:null}):null,e.jsx(s.Button,{type:"primary",icon:e.jsx(z.DatabaseOutlined,{}),onClick:I,children:"执行物化"})]}),a==="source"?e.jsx(s.Input,{style:{width:420},placeholder:"source ID(可直接输入)",value:o,onChange:t=>u(t.target.value)}):e.jsx(q,{rows:10,value:p,onChange:t=>S(t.target.value),placeholder:'{"individuals": [], "statements": []}'})]})}),i?e.jsxs(s.Card,{size:"small",title:"物化报告",children:[e.jsxs(s.Descriptions,{bordered:!0,size:"small",column:2,style:{marginBottom:12},children:[e.jsx(s.Descriptions.Item,{label:"本体",children:l.field(i,"ontologyId")}),e.jsx(s.Descriptions.Item,{label:"工作空间",children:l.field(i,"workspace")}),e.jsx(s.Descriptions.Item,{label:"来源",children:l.field(i,"sourceId")||"(内联)"}),e.jsxs(s.Descriptions.Item,{label:"耗时",children:[l.field(i,"durationMs")," ms"]}),e.jsx(s.Descriptions.Item,{label:"类节点",children:l.field(i,"classNodes")}),e.jsx(s.Descriptions.Item,{label:"实例节点",children:l.field(i,"individualNodes")}),e.jsx(s.Descriptions.Item,{label:"边",children:l.field(i,"edges")}),e.jsx(s.Descriptions.Item,{label:"物化时间",children:l.field(i,"materializedAt")||"—"})]}),e.jsxs(s.Space,{size:"large",wrap:!0,style:{marginBottom:8},children:[e.jsxs("span",{children:["显式陈述 ",e.jsx("b",{children:l.field(i,"explicitStatements")})]}),e.jsxs("span",{children:["推理陈述 ",e.jsx("b",{children:l.field(i,"inferredStatements")})]})]}),g.length?e.jsx("div",{children:g.map((t,w)=>e.jsxs(s.Tag,{color:t.severity==="ERROR"?"red":"orange",children:[t.code," ",t.message]},w))}):e.jsx(s.Tag,{color:"green",children:"物化通过,无校验问题"})]}):null]})}exports.default=R;
@@ -0,0 +1,270 @@
1
+ import { jsx as o, jsxs as c, Fragment as J } from "react/jsx-runtime";
2
+ import { useState as f, useMemo as Q, useRef as de, useCallback as m, useEffect as ue } from "react";
3
+ import { useSearchParams as pe } from "react-router-dom";
4
+ import { message as G, Empty as U, Tag as T, Input as ye, Button as b, Spin as fe, Drawer as he, Descriptions as C } from "antd";
5
+ import { ApartmentOutlined as X, ReloadOutlined as me, RollbackOutlined as ge, ExpandOutlined as Y, ArrowsAltOutlined as Z } from "@ant-design/icons";
6
+ import { o as A } from "./api-BVrIcAFp.js";
7
+ import { b as ke, t as ve, u as be } from "./use-g6-graph-2-Pr4oTs.js";
8
+ import "d3-force";
9
+ import "@antv/g6";
10
+ const se = "class", te = "instance";
11
+ function Ce() {
12
+ return ke([
13
+ { categoryCode: se },
14
+ { categoryCode: te }
15
+ ]);
16
+ }
17
+ function E(a) {
18
+ return (a.labels || []).includes("OntologyClass");
19
+ }
20
+ function ee(a) {
21
+ return (a.labels || []).includes("OntologyIndividual");
22
+ }
23
+ function _(a) {
24
+ const r = a.properties && a.properties.name;
25
+ return r != null && String(r).trim() ? String(r) : a.key;
26
+ }
27
+ function Ne(a, r) {
28
+ const d = (a.nodes || []).map((t) => ({
29
+ id: t.key,
30
+ code: t.key,
31
+ name: _(t),
32
+ fullName: t.key,
33
+ categoryCode: E(t) ? se : te,
34
+ objectCode: t.key,
35
+ objectName: _(t),
36
+ labels: t.labels || [],
37
+ props: t.properties || {}
38
+ })), g = (a.edges || []).map((t) => ({
39
+ source: t.from_key,
40
+ target: t.to_key,
41
+ code: t.type,
42
+ value: t.type,
43
+ displayName: t.type,
44
+ edgeKey: t.key,
45
+ isSelfAssoc: t.from_key === t.to_key
46
+ }));
47
+ return ve({ data: d, links: g }, void 0, void 0, r);
48
+ }
49
+ function Se(a, r) {
50
+ const d = new Map((a.nodes || []).map((t) => [t.key, t])), g = new Map((a.edges || []).map((t) => [t.key || `${t.from_key}|${t.type}|${t.to_key}`, t]));
51
+ return (r.nodes || []).forEach((t) => d.set(t.key, t)), (r.edges || []).forEach((t) => g.set(t.key || `${t.from_key}|${t.type}|${t.to_key}`, t)), { nodes: [...d.values()], edges: [...g.values()] };
52
+ }
53
+ function ze() {
54
+ const [a] = pe(), r = a.get("id") || "", [d, g] = f("default"), [t, M] = f("structure"), [ne, P] = f(""), [N, R] = f([]), [y, I] = f({ nodes: [], edges: [] }), [F, $] = f(!1), [i, S] = f(null), [w, k] = f([]), [B, L] = f(!1), H = Q(() => Ce(), []), p = de(0), K = m(
55
+ (e) => (y.nodes || []).find((s) => s.key === e) || null,
56
+ [y.nodes]
57
+ ), j = m(() => (y.nodes || []).map((e) => e.key), [y.nodes]), { containerRef: oe, setData: W, setViewState: O, ready: re } = be({
58
+ onNodeClick: (e) => {
59
+ var l, u;
60
+ const s = ((l = e.data) == null ? void 0 : l.code) || ((u = e.data) == null ? void 0 : u.id);
61
+ if (!s) return;
62
+ const n = K(s);
63
+ S(n || { key: s, labels: [], properties: {} }), k([s]), O([s], [], j().filter((h) => h !== s));
64
+ },
65
+ onNodeDoubleClick: (e) => {
66
+ var l, u;
67
+ const s = ((l = e.data) == null ? void 0 : l.code) || ((u = e.data) == null ? void 0 : u.id), n = K(s);
68
+ n && E(n) && z(n.key);
69
+ },
70
+ onCanvasClick: () => {
71
+ S(null), k([]), O([], [], []);
72
+ },
73
+ tooltipFormatter: (e, s) => {
74
+ if (s !== "node") return "";
75
+ const n = Array.isArray(e.labels) ? e.labels.join(" / ") : "";
76
+ return `<div><b>${D(e.name || e.code || "")}</b>${n ? `<div style="color:#888;font-size:12px">${D(n)}</div>` : ""}<div style="color:#999;font-size:12px">${D(e.code || "")}</div></div>`;
77
+ }
78
+ }), v = m(
79
+ (e, s = {}) => {
80
+ const n = Ne(e, H);
81
+ W(n, { fit: s.fit !== !1, keepPositions: !!s.keepPositions });
82
+ },
83
+ [W, H]
84
+ ), x = m(
85
+ async (e = d) => {
86
+ if (!r) return;
87
+ const s = ++p.current;
88
+ $(!0);
89
+ try {
90
+ const n = await A.listClasses(r, e);
91
+ if (s !== p.current) return;
92
+ R(n || []);
93
+ const l = (n || []).map((h) => h.key), u = await A.subgraph(r, l, 1, e);
94
+ if (s !== p.current) return;
95
+ I(u || { nodes: [], edges: [] }), M("structure"), P(""), S(null), k([]), v(u || { nodes: [], edges: [] });
96
+ } catch (n) {
97
+ s === p.current && (G.error(`图谱取数失败:${n.message}`), I({ nodes: [], edges: [] }), R([]));
98
+ } finally {
99
+ s === p.current && $(!1);
100
+ }
101
+ },
102
+ [r, d, v]
103
+ );
104
+ ue(() => (r && x("default"), () => {
105
+ p.current += 1;
106
+ }), [r]);
107
+ const z = m(
108
+ async (e) => {
109
+ if (!r) return;
110
+ const s = ++p.current;
111
+ $(!0);
112
+ try {
113
+ const n = await A.subgraph(r, [e], 1, d);
114
+ if (s !== p.current) return;
115
+ I(n || { nodes: [], edges: [] }), M("instance"), P(e), S(null), k([]), v(n || { nodes: [], edges: [] });
116
+ } catch (n) {
117
+ s === p.current && G.error(`实例图取数失败:${n.message}`);
118
+ } finally {
119
+ s === p.current && $(!1);
120
+ }
121
+ },
122
+ [r, d, v]
123
+ ), le = m(() => x(), [x]), q = m(
124
+ async (e) => {
125
+ const s = e || i;
126
+ if (!(!s || !r)) {
127
+ L(!0);
128
+ try {
129
+ const n = await A.listNeighbors(r, s.key, 1, d), l = { nodes: [], edges: [] };
130
+ (n || []).forEach((h) => {
131
+ h.node && l.nodes.push(h.node), h.edge && l.edges.push(h.edge);
132
+ });
133
+ const u = Se(y, l);
134
+ I(u), v(u, { keepPositions: !0 });
135
+ } catch (n) {
136
+ G.error(`邻居展开失败:${n.message}`);
137
+ } finally {
138
+ L(!1);
139
+ }
140
+ }
141
+ },
142
+ [i, r, d, y, v]
143
+ ), ie = m(
144
+ (e) => {
145
+ const s = w.includes(e) ? w.filter((n) => n !== e) : [...w, e];
146
+ k(s), O(s, [], s.length ? j().filter((n) => !s.includes(n)) : []);
147
+ },
148
+ [w, O, j]
149
+ ), ae = Q(() => {
150
+ const e = {}, s = new Set((N || []).map((n) => n.key));
151
+ return (y.nodes || []).forEach((n) => {
152
+ s.has(n.key) ? e[n.key] = e[n.key] || { instances: 0 } : ee(n) && (n.labels || []).filter((l) => s.has(l)).forEach((l) => {
153
+ e[l] = e[l] || { instances: 0 }, e[l].instances += 1;
154
+ });
155
+ }), e;
156
+ }, [N, y.nodes]);
157
+ if (!r)
158
+ return /* @__PURE__ */ o(U, { description: "缺少本体 ID(?id=xxx)", style: { padding: 48 } });
159
+ const V = t === "structure", ce = !!(y.nodes || []).length;
160
+ return /* @__PURE__ */ c("div", { className: "view", children: [
161
+ /* @__PURE__ */ c("div", { className: "view-bar", children: [
162
+ /* @__PURE__ */ c(T, { icon: /* @__PURE__ */ o(X, {}), color: "purple", children: [
163
+ "本体 ",
164
+ r
165
+ ] }),
166
+ /* @__PURE__ */ o(
167
+ ye.Search,
168
+ {
169
+ style: { width: 200 },
170
+ placeholder: "工作空间(默认 default)",
171
+ value: d,
172
+ onChange: (e) => g(e.target.value),
173
+ onSearch: () => x()
174
+ }
175
+ ),
176
+ V ? /* @__PURE__ */ o(b, { icon: /* @__PURE__ */ o(me, {}), onClick: () => x(), children: "刷新" }) : /* @__PURE__ */ c(J, { children: [
177
+ /* @__PURE__ */ o(b, { icon: /* @__PURE__ */ o(ge, {}), onClick: le, children: "返回结构层" }),
178
+ /* @__PURE__ */ c(T, { color: "blue", children: [
179
+ "实例层:",
180
+ ne
181
+ ] })
182
+ ] }),
183
+ i ? /* @__PURE__ */ o(b, { icon: /* @__PURE__ */ o(Y, {}), loading: B, onClick: () => q(i), children: "展开邻居" }) : null,
184
+ /* @__PURE__ */ o("span", { className: "spacer hint", children: "双击类节点进入实例层 · 点击节点查看详情 · 空白点击取消" })
185
+ ] }),
186
+ /* @__PURE__ */ c("div", { style: { display: "flex", gap: 12, alignItems: "stretch", height: "calc(100vh - 220px)" }, children: [
187
+ /* @__PURE__ */ c("div", { className: "side-rail", children: [
188
+ /* @__PURE__ */ c("div", { className: "rail-head", children: [
189
+ "类型(",
190
+ N.length,
191
+ ")"
192
+ ] }),
193
+ N.length ? /* @__PURE__ */ o("ul", { className: "rail-list", children: N.map((e) => {
194
+ const s = ae[e.key] || { instances: 0 }, n = w.includes(e.key);
195
+ return /* @__PURE__ */ c(
196
+ "li",
197
+ {
198
+ className: `rail-item${n ? " active" : ""}`,
199
+ onClick: () => ie(e.key),
200
+ title: "点击高亮该类型",
201
+ children: [
202
+ /* @__PURE__ */ o(X, { style: { color: "#722ed1" } }),
203
+ /* @__PURE__ */ o("span", { style: { flex: 1, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: _(e) }),
204
+ /* @__PURE__ */ c(T, { style: { fontSize: 11 }, children: [
205
+ s.instances,
206
+ " 实例"
207
+ ] }),
208
+ /* @__PURE__ */ o(
209
+ b,
210
+ {
211
+ type: "link",
212
+ size: "small",
213
+ style: { padding: 0 },
214
+ icon: /* @__PURE__ */ o(Z, {}),
215
+ title: "进入实例层",
216
+ onClick: (l) => {
217
+ l.stopPropagation(), z(e.key);
218
+ }
219
+ }
220
+ )
221
+ ]
222
+ },
223
+ e.key
224
+ );
225
+ }) }) : /* @__PURE__ */ o("div", { className: "empty-note", children: "暂无类定义(可先登记 schema 或物化)" })
226
+ ] }),
227
+ /* @__PURE__ */ c("div", { ref: oe, className: "graph-canvas", children: [
228
+ F ? /* @__PURE__ */ o("div", { className: "canvas-overlay", children: /* @__PURE__ */ o(fe, { tip: "图谱加载中", children: /* @__PURE__ */ o("div", { style: { width: 80, height: 80 } }) }) }) : null,
229
+ !F && re && !ce ? /* @__PURE__ */ o("div", { className: "canvas-overlay", children: /* @__PURE__ */ o(U, { description: V ? "本体内无物化图数据" : "该类型暂无实例" }) }) : null
230
+ ] })
231
+ ] }),
232
+ /* @__PURE__ */ o(
233
+ he,
234
+ {
235
+ open: !!i,
236
+ width: 380,
237
+ title: i ? _(i) : "",
238
+ onClose: () => {
239
+ S(null), k([]);
240
+ },
241
+ destroyOnHidden: !0,
242
+ children: i ? /* @__PURE__ */ c(J, { children: [
243
+ /* @__PURE__ */ c(C, { column: 1, size: "small", bordered: !0, children: [
244
+ /* @__PURE__ */ o(C.Item, { label: "key", children: i.key }),
245
+ /* @__PURE__ */ o(C.Item, { label: "类型", children: E(i) ? "类" : ee(i) ? "实例" : (i.labels || []).join(" / ") || "节点" }),
246
+ /* @__PURE__ */ o(C.Item, { label: "标签", children: (i.labels || []).join(" / ") || "-" })
247
+ ] }),
248
+ /* @__PURE__ */ o("div", { style: { marginTop: 16, fontWeight: 600, marginBottom: 8 }, children: "属性" }),
249
+ Object.keys(i.properties || {}).length ? /* @__PURE__ */ o(C, { column: 1, size: "small", children: Object.entries(i.properties).map(([e, s]) => /* @__PURE__ */ o(C.Item, { label: e, children: String(s) }, e)) }) : /* @__PURE__ */ o("div", { style: { color: "#999", fontSize: 12 }, children: "(无属性)" }),
250
+ /* @__PURE__ */ c("div", { style: { marginTop: 16, display: "flex", gap: 8 }, children: [
251
+ /* @__PURE__ */ o(b, { icon: /* @__PURE__ */ o(Y, {}), loading: B, onClick: () => q(i), children: "展开 1 跳邻居" }),
252
+ E(i) ? /* @__PURE__ */ o(b, { type: "primary", icon: /* @__PURE__ */ o(Z, {}), onClick: () => z(i.key), children: "查看实例" }) : null
253
+ ] })
254
+ ] }) : null
255
+ }
256
+ )
257
+ ] });
258
+ }
259
+ function D(a) {
260
+ return String(a).replace(/[&<>"']/g, (r) => ({
261
+ "&": "&amp;",
262
+ "<": "&lt;",
263
+ ">": "&gt;",
264
+ '"': "&quot;",
265
+ "'": "&#39;"
266
+ })[r]);
267
+ }
268
+ export {
269
+ ze as default
270
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),se=require("react-router-dom"),l=require("antd"),f=require("@ant-design/icons"),A=require("./api-D5Hgcud4.cjs"),q=require("./use-g6-graph-B9K6IPJe.cjs");require("d3-force");require("@antv/g6");const W="class",V="instance";function te(){return q.buildCategoryColorMap([{categoryCode:W},{categoryCode:V}])}function O(d){return(d.labels||[]).includes("OntologyClass")}function K(d){return(d.labels||[]).includes("OntologyIndividual")}function I(d){const r=d.properties&&d.properties.name;return r!=null&&String(r).trim()?String(r):d.key}function ne(d,r){const u=(d.nodes||[]).map(n=>({id:n.key,code:n.key,name:I(n),fullName:n.key,categoryCode:O(n)?W:V,objectCode:n.key,objectName:I(n),labels:n.labels||[],props:n.properties||{}})),m=(d.edges||[]).map(n=>({source:n.from_key,target:n.to_key,code:n.type,value:n.type,displayName:n.type,edgeKey:n.key,isSelfAssoc:n.from_key===n.to_key}));return q.toG6Data({data:u,links:m},void 0,void 0,r)}function oe(d,r){const u=new Map((d.nodes||[]).map(n=>[n.key,n])),m=new Map((d.edges||[]).map(n=>[n.key||`${n.from_key}|${n.type}|${n.to_key}`,n]));return(r.nodes||[]).forEach(n=>u.set(n.key,n)),(r.edges||[]).forEach(n=>m.set(n.key||`${n.from_key}|${n.type}|${n.to_key}`,n)),{nodes:[...u.values()],edges:[...m.values()]}}function re(){const[d]=se.useSearchParams(),r=d.get("id")||"",[u,m]=i.useState("default"),[n,T]=i.useState("structure"),[J,_]=i.useState(""),[j,G]=i.useState([]),[g,S]=i.useState({nodes:[],edges:[]}),[R,N]=i.useState(!1),[c,b]=i.useState(null),[v,x]=i.useState([]),[B,M]=i.useState(!1),z=i.useMemo(()=>te(),[]),y=i.useRef(0),P=i.useCallback(s=>(g.nodes||[]).find(t=>t.key===s)||null,[g.nodes]),$=i.useCallback(()=>(g.nodes||[]).map(s=>s.key),[g.nodes]),{containerRef:Q,setData:F,setViewState:w,ready:U}=q.useG6Graph({onNodeClick:s=>{var a,p;const t=((a=s.data)==null?void 0:a.code)||((p=s.data)==null?void 0:p.id);if(!t)return;const o=P(t);b(o||{key:t,labels:[],properties:{}}),x([t]),w([t],[],$().filter(h=>h!==t))},onNodeDoubleClick:s=>{var a,p;const t=((a=s.data)==null?void 0:a.code)||((p=s.data)==null?void 0:p.id),o=P(t);o&&O(o)&&D(o.key)},onCanvasClick:()=>{b(null),x([]),w([],[],[])},tooltipFormatter:(s,t)=>{if(t!=="node")return"";const o=Array.isArray(s.labels)?s.labels.join(" / "):"";return`<div><b>${E(s.name||s.code||"")}</b>${o?`<div style="color:#888;font-size:12px">${E(o)}</div>`:""}<div style="color:#999;font-size:12px">${E(s.code||"")}</div></div>`}}),k=i.useCallback((s,t={})=>{const o=ne(s,z);F(o,{fit:t.fit!==!1,keepPositions:!!t.keepPositions})},[F,z]),C=i.useCallback(async(s=u)=>{if(!r)return;const t=++y.current;N(!0);try{const o=await A.ontologyApi.listClasses(r,s);if(t!==y.current)return;G(o||[]);const a=(o||[]).map(h=>h.key),p=await A.ontologyApi.subgraph(r,a,1,s);if(t!==y.current)return;S(p||{nodes:[],edges:[]}),T("structure"),_(""),b(null),x([]),k(p||{nodes:[],edges:[]})}catch(o){t===y.current&&(l.message.error(`图谱取数失败:${o.message}`),S({nodes:[],edges:[]}),G([]))}finally{t===y.current&&N(!1)}},[r,u,k]);i.useEffect(()=>(r&&C("default"),()=>{y.current+=1}),[r]);const D=i.useCallback(async s=>{if(!r)return;const t=++y.current;N(!0);try{const o=await A.ontologyApi.subgraph(r,[s],1,u);if(t!==y.current)return;S(o||{nodes:[],edges:[]}),T("instance"),_(s),b(null),x([]),k(o||{nodes:[],edges:[]})}catch(o){t===y.current&&l.message.error(`实例图取数失败:${o.message}`)}finally{t===y.current&&N(!1)}},[r,u,k]),X=i.useCallback(()=>C(),[C]),L=i.useCallback(async s=>{const t=s||c;if(!(!t||!r)){M(!0);try{const o=await A.ontologyApi.listNeighbors(r,t.key,1,u),a={nodes:[],edges:[]};(o||[]).forEach(h=>{h.node&&a.nodes.push(h.node),h.edge&&a.edges.push(h.edge)});const p=oe(g,a);S(p),k(p,{keepPositions:!0})}catch(o){l.message.error(`邻居展开失败:${o.message}`)}finally{M(!1)}}},[c,r,u,g,k]),Y=i.useCallback(s=>{const t=v.includes(s)?v.filter(o=>o!==s):[...v,s];x(t),w(t,[],t.length?$().filter(o=>!t.includes(o)):[])},[v,w,$]),Z=i.useMemo(()=>{const s={},t=new Set((j||[]).map(o=>o.key));return(g.nodes||[]).forEach(o=>{t.has(o.key)?s[o.key]=s[o.key]||{instances:0}:K(o)&&(o.labels||[]).filter(a=>t.has(a)).forEach(a=>{s[a]=s[a]||{instances:0},s[a].instances+=1})}),s},[j,g.nodes]);if(!r)return e.jsx(l.Empty,{description:"缺少本体 ID(?id=xxx)",style:{padding:48}});const H=n==="structure",ee=!!(g.nodes||[]).length;return e.jsxs("div",{className:"view",children:[e.jsxs("div",{className:"view-bar",children:[e.jsxs(l.Tag,{icon:e.jsx(f.ApartmentOutlined,{}),color:"purple",children:["本体 ",r]}),e.jsx(l.Input.Search,{style:{width:200},placeholder:"工作空间(默认 default)",value:u,onChange:s=>m(s.target.value),onSearch:()=>C()}),H?e.jsx(l.Button,{icon:e.jsx(f.ReloadOutlined,{}),onClick:()=>C(),children:"刷新"}):e.jsxs(e.Fragment,{children:[e.jsx(l.Button,{icon:e.jsx(f.RollbackOutlined,{}),onClick:X,children:"返回结构层"}),e.jsxs(l.Tag,{color:"blue",children:["实例层:",J]})]}),c?e.jsx(l.Button,{icon:e.jsx(f.ExpandOutlined,{}),loading:B,onClick:()=>L(c),children:"展开邻居"}):null,e.jsx("span",{className:"spacer hint",children:"双击类节点进入实例层 · 点击节点查看详情 · 空白点击取消"})]}),e.jsxs("div",{style:{display:"flex",gap:12,alignItems:"stretch",height:"calc(100vh - 220px)"},children:[e.jsxs("div",{className:"side-rail",children:[e.jsxs("div",{className:"rail-head",children:["类型(",j.length,")"]}),j.length?e.jsx("ul",{className:"rail-list",children:j.map(s=>{const t=Z[s.key]||{instances:0},o=v.includes(s.key);return e.jsxs("li",{className:`rail-item${o?" active":""}`,onClick:()=>Y(s.key),title:"点击高亮该类型",children:[e.jsx(f.ApartmentOutlined,{style:{color:"#722ed1"}}),e.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:I(s)}),e.jsxs(l.Tag,{style:{fontSize:11},children:[t.instances," 实例"]}),e.jsx(l.Button,{type:"link",size:"small",style:{padding:0},icon:e.jsx(f.ArrowsAltOutlined,{}),title:"进入实例层",onClick:a=>{a.stopPropagation(),D(s.key)}})]},s.key)})}):e.jsx("div",{className:"empty-note",children:"暂无类定义(可先登记 schema 或物化)"})]}),e.jsxs("div",{ref:Q,className:"graph-canvas",children:[R?e.jsx("div",{className:"canvas-overlay",children:e.jsx(l.Spin,{tip:"图谱加载中",children:e.jsx("div",{style:{width:80,height:80}})})}):null,!R&&U&&!ee?e.jsx("div",{className:"canvas-overlay",children:e.jsx(l.Empty,{description:H?"本体内无物化图数据":"该类型暂无实例"})}):null]})]}),e.jsx(l.Drawer,{open:!!c,width:380,title:c?I(c):"",onClose:()=>{b(null),x([])},destroyOnHidden:!0,children:c?e.jsxs(e.Fragment,{children:[e.jsxs(l.Descriptions,{column:1,size:"small",bordered:!0,children:[e.jsx(l.Descriptions.Item,{label:"key",children:c.key}),e.jsx(l.Descriptions.Item,{label:"类型",children:O(c)?"类":K(c)?"实例":(c.labels||[]).join(" / ")||"节点"}),e.jsx(l.Descriptions.Item,{label:"标签",children:(c.labels||[]).join(" / ")||"-"})]}),e.jsx("div",{style:{marginTop:16,fontWeight:600,marginBottom:8},children:"属性"}),Object.keys(c.properties||{}).length?e.jsx(l.Descriptions,{column:1,size:"small",children:Object.entries(c.properties).map(([s,t])=>e.jsx(l.Descriptions.Item,{label:s,children:String(t)},s))}):e.jsx("div",{style:{color:"#999",fontSize:12},children:"(无属性)"}),e.jsxs("div",{style:{marginTop:16,display:"flex",gap:8},children:[e.jsx(l.Button,{icon:e.jsx(f.ExpandOutlined,{}),loading:B,onClick:()=>L(c),children:"展开 1 跳邻居"}),O(c)?e.jsx(l.Button,{type:"primary",icon:e.jsx(f.ArrowsAltOutlined,{}),onClick:()=>D(c.key),children:"查看实例"}):null]})]}):null})]})}function E(d){return String(d).replace(/[&<>"']/g,r=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[r])}exports.default=re;