@lovrabet/rabetbase-cli 2.2.4 → 2.2.5-beta.2
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.
- package/README.md +1 -1
- package/lib/api/api-doc.js +1 -1
- package/lib/api/fetch-model-list.js +1 -1
- package/lib/api/generate-api-file.js +1 -1
- package/lib/auth/auth-server-ui.js +1 -1
- package/lib/auth/auth-server.js +1 -1
- package/lib/auth/constant.js +1 -1
- package/lib/auth/get-cookie.js +1 -1
- package/lib/auth/get-session-user.js +1 -1
- package/lib/auth/is-session-valid.js +1 -1
- package/lib/auth/login-success-html.js +1 -1
- package/lib/auth/logout.js +1 -1
- package/lib/cli-flags.js +1 -1
- package/lib/cli.js +1 -1
- package/lib/commands/api/generate.js +1 -1
- package/lib/commands/api/index.js +1 -1
- package/lib/commands/api/list.js +1 -1
- package/lib/commands/api/pull.js +1 -1
- package/lib/commands/api/shared.js +1 -1
- package/lib/commands/app/add.js +1 -1
- package/lib/commands/app/discover.js +1 -1
- package/lib/commands/app/index.js +1 -1
- package/lib/commands/app/list.js +1 -1
- package/lib/commands/app/remove.js +1 -1
- package/lib/commands/app/shared.js +1 -1
- package/lib/commands/app/use.js +1 -1
- package/lib/commands/app-config/delete.js +1 -0
- package/lib/commands/app-config/get.js +1 -0
- package/lib/commands/app-config/index.js +1 -0
- package/lib/commands/app-config/list.js +1 -0
- package/lib/commands/app-config/set.js +1 -0
- package/lib/commands/app-config/shared.js +1 -0
- package/lib/commands/auth/index.js +1 -1
- package/lib/commands/bff/create.js +1 -1
- package/lib/commands/bff/delete.js +1 -1
- package/lib/commands/bff/detail.js +1 -1
- package/lib/commands/bff/index.js +1 -1
- package/lib/commands/bff/list.js +1 -1
- package/lib/commands/bff/pull.js +1 -1
- package/lib/commands/bff/push.js +1 -1
- package/lib/commands/bff/status.js +1 -1
- package/lib/commands/cli-update.js +1 -1
- package/lib/commands/codegen/index.js +1 -1
- package/lib/commands/codegen/sdk.js +1 -1
- package/lib/commands/codegen/sql.js +1 -1
- package/lib/commands/common/app-selector.js +1 -1
- package/lib/commands/common/flags.js +1 -1
- package/lib/commands/common/validate.js +1 -1
- package/lib/commands/config/get.js +1 -1
- package/lib/commands/config/index.js +1 -1
- package/lib/commands/config/list.js +1 -1
- package/lib/commands/config/set.js +1 -1
- package/lib/commands/config/shared.js +1 -1
- package/lib/commands/data/filter.js +1 -1
- package/lib/commands/data/getOne.js +1 -1
- package/lib/commands/data/index.js +1 -1
- package/lib/commands/data/shared.js +1 -1
- package/lib/commands/dataset/business-group-update.js +1 -0
- package/lib/commands/dataset/capability.js +1 -1
- package/lib/commands/dataset/delete.js +1 -1
- package/lib/commands/dataset/detail.js +1 -1
- package/lib/commands/dataset/extend-update.js +1 -1
- package/lib/commands/dataset/field-update.js +1 -1
- package/lib/commands/dataset/index.js +1 -1
- package/lib/commands/dataset/list.js +1 -1
- package/lib/commands/dataset/operations.js +1 -1
- package/lib/commands/dataset/relation-create.js +1 -1
- package/lib/commands/dataset/relation-delete.js +1 -1
- package/lib/commands/dataset/relation-shared.js +1 -1
- package/lib/commands/dataset/relation-update.js +1 -1
- package/lib/commands/dataset/relations.js +1 -1
- package/lib/commands/dataset/rename.js +1 -1
- package/lib/commands/dataset/restore.js +1 -0
- package/lib/commands/db/analyze-cancel.js +1 -1
- package/lib/commands/db/analyze-start.js +1 -1
- package/lib/commands/db/analyze-status.js +1 -1
- package/lib/commands/db/create.js +1 -1
- package/lib/commands/db/delete.js +1 -1
- package/lib/commands/db/detail.js +1 -1
- package/lib/commands/db/diff.js +1 -1
- package/lib/commands/db/index.js +1 -1
- package/lib/commands/db/list.js +1 -1
- package/lib/commands/db/shared.js +1 -1
- package/lib/commands/db/tables.js +1 -1
- package/lib/commands/db/test.js +1 -1
- package/lib/commands/db/update.js +1 -1
- package/lib/commands/doctor.js +1 -1
- package/lib/commands/init/index.js +1 -1
- package/lib/commands/issue/index.js +1 -1
- package/lib/commands/issue/nudge.js +1 -1
- package/lib/commands/issue/report.js +1 -1
- package/lib/commands/issue/shared.js +1 -1
- package/lib/commands/logs/index.js +1 -1
- package/lib/commands/menu/index.js +1 -1
- package/lib/commands/menu/list.js +1 -1
- package/lib/commands/menu/shared/compare-table.js +1 -1
- package/lib/commands/menu/shared/index.js +1 -1
- package/lib/commands/menu/shared/inquirer.js +1 -1
- package/lib/commands/menu/shared/local-pages.js +1 -1
- package/lib/commands/menu/shared/logic.js +1 -1
- package/lib/commands/menu/shared/service.js +1 -1
- package/lib/commands/menu/shared/sync-core.js +1 -1
- package/lib/commands/menu/shared/update-core.js +1 -1
- package/lib/commands/menu/shared/valid-url.js +1 -1
- package/lib/commands/menu/sync.js +1 -1
- package/lib/commands/menu/update.js +1 -1
- package/lib/commands/page/generate-start.js +1 -1
- package/lib/commands/page/generate-status.js +1 -1
- package/lib/commands/page/index.js +1 -1
- package/lib/commands/page/pull.js +1 -1
- package/lib/commands/page/push.js +1 -1
- package/lib/commands/page/relation-audit.js +1 -1
- package/lib/commands/page/shared.js +1 -1
- package/lib/commands/page/standard-page-status.js +1 -1
- package/lib/commands/page/sync.js +1 -1
- package/lib/commands/project/create/enhanced-guided-create.js +1 -1
- package/lib/commands/project/create/format-elapsed.js +1 -1
- package/lib/commands/project/create/main.js +1 -1
- package/lib/commands/project/create/non-interactive.js +1 -1
- package/lib/commands/project/create/project-template-path.js +1 -1
- package/lib/commands/project/create/use-copy-project-template.js +1 -1
- package/lib/commands/project/create/use-format-code.js +1 -1
- package/lib/commands/project/create/use-install-dependencies.js +1 -1
- package/lib/commands/project/index.js +1 -1
- package/lib/commands/project/init.js +1 -1
- package/lib/commands/project/upgrade.js +1 -1
- package/lib/commands/registry.js +1 -1
- package/lib/commands/run/index.js +1 -1
- package/lib/commands/schema.js +1 -1
- package/lib/commands/skill/index.js +1 -1
- package/lib/commands/sql/create.js +1 -1
- package/lib/commands/sql/delete.js +1 -1
- package/lib/commands/sql/detail.js +1 -1
- package/lib/commands/sql/exec.js +1 -1
- package/lib/commands/sql/index.js +1 -1
- package/lib/commands/sql/list.js +1 -1
- package/lib/commands/sql/pull.js +1 -1
- package/lib/commands/sql/push.js +1 -1
- package/lib/commands/sql/save.js +1 -1
- package/lib/commands/sql/shared.js +1 -1
- package/lib/commands/sql/status.js +1 -1
- package/lib/commands/sql/validate.js +1 -1
- package/lib/commands/workspace/index.js +1 -1
- package/lib/config/schema.js +1 -1
- package/lib/constant/cdn.js +1 -1
- package/lib/constant/cli.js +1 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/domain.js +1 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/paths.js +1 -1
- package/lib/constant/risk.js +1 -1
- package/lib/context/app-resolver.js +1 -1
- package/lib/context/auth-resolver.js +1 -1
- package/lib/context/config-loader.js +1 -1
- package/lib/context.js +1 -1
- package/lib/core/alias-resolver.js +1 -1
- package/lib/core/api-client.js +1 -1
- package/lib/core/bff/config.js +1 -1
- package/lib/core/bff/file-system.js +1 -1
- package/lib/core/bff/hash.js +1 -1
- package/lib/core/bff/lock.js +1 -1
- package/lib/core/bff/utils.js +1 -1
- package/lib/core/db-resolver.js +1 -1
- package/lib/core/page/file-system.js +1 -1
- package/lib/core/page/hash.js +1 -1
- package/lib/core/page/lock.js +1 -1
- package/lib/core/sql-sync/config.js +1 -1
- package/lib/core/sql-sync/file-system.js +1 -1
- package/lib/core/sql-sync/hash.js +1 -1
- package/lib/core/sql-sync/lock.js +1 -1
- package/lib/core/sql-sync/utils.js +1 -1
- package/lib/core/sql-validator.js +1 -1
- package/lib/errors.js +1 -1
- package/lib/framework/build-all-flags.js +1 -1
- package/lib/framework/flags.js +1 -1
- package/lib/framework/help.js +1 -1
- package/lib/framework/index.js +1 -1
- package/lib/framework/output.js +1 -1
- package/lib/framework/response.js +1 -1
- package/lib/framework/runner-alias.js +1 -1
- package/lib/framework/runner.js +1 -1
- package/lib/framework/schema-export.js +1 -1
- package/lib/framework/types.js +1 -1
- package/lib/generated/build-info.js +1 -1
- package/lib/help.js +1 -1
- package/lib/skills/main.js +1 -1
- package/lib/skills/npx-skills-add.js +1 -1
- package/lib/telemetry/cli-command-trace.js +1 -1
- package/lib/telemetry/cli-help-trace.js +1 -1
- package/lib/telemetry/ensure-cli-otel-config.js +1 -1
- package/lib/telemetry/register-otel-exit-shutdown.js +1 -1
- package/lib/telemetry/send-cli-trace-log.js +1 -1
- package/lib/telemetry/send-platform-issue-collect-log.js +1 -1
- package/lib/utils/ai_config.js +1 -1
- package/lib/utils/apply-jq-filter.js +1 -1
- package/lib/utils/cdn-config.js +1 -1
- package/lib/utils/check-sdk-version.js +1 -1
- package/lib/utils/cli-version-check.js +1 -1
- package/lib/utils/cli-version-policy.js +1 -1
- package/lib/utils/config.js +1 -1
- package/lib/utils/copy-directory.js +1 -1
- package/lib/utils/entity-with-id.js +1 -1
- package/lib/utils/file-utils.js +1 -1
- package/lib/utils/guides-cdn.js +1 -1
- package/lib/utils/http-client.js +1 -1
- package/lib/utils/is-non-interactive.js +1 -1
- package/lib/utils/logger.js +1 -1
- package/lib/utils/params.js +1 -1
- package/lib/utils/platform.js +1 -1
- package/lib/utils/rules-cdn.js +1 -1
- package/lib/utils/sleep.js +1 -1
- package/lib/utils/template-replacer.js +1 -1
- package/lib/utils/update-notice.js +1 -1
- package/lib/utils/version.js +1 -1
- package/lib/utils/with-active-cookie.js +1 -1
- package/lib/utils/write-cli-side-channel.js +1 -1
- package/package.json +1 -1
- package/templates/README.md +15 -25
- package/templates/generate-api/api.ts.tpl +2 -2
- package/templates/generate-api/client.ts.tpl +2 -2
- package/templates/projects/sub-app-react-demo/CHANGELOG.md +15 -1
- package/templates/projects/sub-app-react-demo/README.md +159 -231
- package/templates/projects/sub-app-react-demo/docs/quick-start.md +145 -426
- package/templates/projects/sub-app-react-demo/src/api/api.ts +8 -65
- package/templates/projects/sub-app-react-demo/src/api/client.ts +10 -42
- package/templates/projects/sub-app-react-demo/src/components/demo-page-container/DemoPageContainer.module.css +28 -0
- package/templates/projects/sub-app-react-demo/src/components/demo-page-container/DemoPageContainer.tsx +55 -0
- package/templates/projects/sub-app-react-demo/src/layouts/MainLayout.tsx +6 -9
- package/templates/projects/sub-app-react-demo/src/main.tsx +10 -6
- package/templates/projects/sub-app-react-demo/src/pages/dashboard/index.tsx +3 -5
- package/templates/projects/sub-app-react-demo/src/pages/data-screen/index.tsx +153 -148
- package/templates/projects/sub-app-react-demo/src/pages/index.module.css +500 -0
- package/templates/projects/sub-app-react-demo/src/pages/index.tsx +517 -343
- package/templates/projects/sub-app-react-demo/src/pages/sdk-demo/index.tsx +325 -242
- package/templates/projects/sub-app-react-demo/src/pages/workbench/index.module.css +8 -6
- package/templates/projects/sub-app-react-demo/src/pages/workbench/index.tsx +174 -87
- package/templates/projects/sub-app-react-demo/src/style.css +19 -3
- package/templates/projects/sub-app-react-demo/src/vite-env.d.ts +1 -1
- package/templates/projects/sub-app-react-demo/docs/API_RULE_CHANGE.md +0 -212
|
@@ -10,11 +10,107 @@ import {
|
|
|
10
10
|
Input,
|
|
11
11
|
Tag,
|
|
12
12
|
} from "antd";
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
ApiOutlined,
|
|
15
|
+
CheckOutlined,
|
|
16
|
+
CopyOutlined,
|
|
17
|
+
DownOutlined,
|
|
18
|
+
UpOutlined,
|
|
19
|
+
} from "@ant-design/icons";
|
|
14
20
|
import { lovrabetClient } from "@/api/client";
|
|
21
|
+
import DemoPageContainer from "@/components/demo-page-container/DemoPageContainer";
|
|
15
22
|
|
|
16
23
|
const { Title, Paragraph, Text } = Typography;
|
|
17
24
|
|
|
25
|
+
interface CollapsibleCodeBlockProps {
|
|
26
|
+
title: string;
|
|
27
|
+
code: string;
|
|
28
|
+
accent?: boolean;
|
|
29
|
+
defaultExpanded?: boolean;
|
|
30
|
+
maxHeight?: number;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function CollapsibleCodeBlock({
|
|
34
|
+
title,
|
|
35
|
+
code,
|
|
36
|
+
accent = false,
|
|
37
|
+
defaultExpanded = false,
|
|
38
|
+
maxHeight,
|
|
39
|
+
}: CollapsibleCodeBlockProps) {
|
|
40
|
+
const [expanded, setExpanded] = useState(defaultExpanded);
|
|
41
|
+
const [copied, setCopied] = useState(false);
|
|
42
|
+
|
|
43
|
+
const handleCopy = async () => {
|
|
44
|
+
try {
|
|
45
|
+
if (navigator.clipboard?.writeText) {
|
|
46
|
+
await navigator.clipboard.writeText(code);
|
|
47
|
+
}
|
|
48
|
+
setCopied(true);
|
|
49
|
+
window.setTimeout(() => setCopied(false), 2000);
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.error("复制代码失败:", error);
|
|
52
|
+
message.error("复制代码失败");
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<div
|
|
58
|
+
style={{
|
|
59
|
+
border: `1px solid ${accent ? "#1890ff" : "#d9d9d9"}`,
|
|
60
|
+
borderRadius: 6,
|
|
61
|
+
overflow: "hidden",
|
|
62
|
+
background: "#fff",
|
|
63
|
+
}}
|
|
64
|
+
>
|
|
65
|
+
<div
|
|
66
|
+
style={{
|
|
67
|
+
display: "flex",
|
|
68
|
+
justifyContent: "space-between",
|
|
69
|
+
alignItems: "center",
|
|
70
|
+
gap: 12,
|
|
71
|
+
padding: "10px 12px",
|
|
72
|
+
background: accent ? "#f0f8ff" : "#fafafa",
|
|
73
|
+
borderBottom: expanded
|
|
74
|
+
? `1px solid ${accent ? "#1890ff" : "#d9d9d9"}`
|
|
75
|
+
: "none",
|
|
76
|
+
}}
|
|
77
|
+
>
|
|
78
|
+
<Text strong>{title}</Text>
|
|
79
|
+
<Space size={8}>
|
|
80
|
+
<Button
|
|
81
|
+
size="small"
|
|
82
|
+
icon={copied ? <CheckOutlined /> : <CopyOutlined />}
|
|
83
|
+
onClick={handleCopy}
|
|
84
|
+
>
|
|
85
|
+
{copied ? "已复制" : "复制"}
|
|
86
|
+
</Button>
|
|
87
|
+
<Button
|
|
88
|
+
size="small"
|
|
89
|
+
icon={expanded ? <UpOutlined /> : <DownOutlined />}
|
|
90
|
+
onClick={() => setExpanded((current) => !current)}
|
|
91
|
+
>
|
|
92
|
+
{expanded ? "收起" : "展开"}
|
|
93
|
+
</Button>
|
|
94
|
+
</Space>
|
|
95
|
+
</div>
|
|
96
|
+
{expanded && (
|
|
97
|
+
<pre
|
|
98
|
+
style={{
|
|
99
|
+
background: accent ? "#f0f8ff" : "#f5f5f5",
|
|
100
|
+
padding: "16px",
|
|
101
|
+
margin: 0,
|
|
102
|
+
fontSize: "13px",
|
|
103
|
+
maxHeight,
|
|
104
|
+
overflow: "auto",
|
|
105
|
+
}}
|
|
106
|
+
>
|
|
107
|
+
{code}
|
|
108
|
+
</pre>
|
|
109
|
+
)}
|
|
110
|
+
</div>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
18
114
|
export default function SdkDemo() {
|
|
19
115
|
const [loading, setLoading] = useState(false);
|
|
20
116
|
const [data, setData] = useState<any[]>([]);
|
|
@@ -36,6 +132,70 @@ export default function SdkDemo() {
|
|
|
36
132
|
// 获取选中模型的信息(用于代码示例展示 alias)
|
|
37
133
|
const selectedModelInfo = modelList.find((m) => m.value === selectedModel);
|
|
38
134
|
|
|
135
|
+
const filterCodeExample = `// ========== 方式一:标准 dataset_code 模式(推荐 AI/LLM 使用)==========
|
|
136
|
+
const response = await lovrabetClient
|
|
137
|
+
.models['${selectedModel || "dataset_xxx"}'].filter({
|
|
138
|
+
currentPage: 1,
|
|
139
|
+
pageSize: 10
|
|
140
|
+
});
|
|
141
|
+
${
|
|
142
|
+
selectedModelInfo?.alias
|
|
143
|
+
? `
|
|
144
|
+
// ========== 方式二:人类友好的 alias 模式 ==========
|
|
145
|
+
const response = await lovrabetClient
|
|
146
|
+
.models.${selectedModelInfo.alias}.filter({
|
|
147
|
+
currentPage: 1,
|
|
148
|
+
pageSize: 10
|
|
149
|
+
});
|
|
150
|
+
`
|
|
151
|
+
: ""
|
|
152
|
+
}
|
|
153
|
+
// ========== 完整查询示例(所有参数均为可选)==========
|
|
154
|
+
const response = await lovrabetClient
|
|
155
|
+
.models['${selectedModel || "dataset_xxx"}'].filter({
|
|
156
|
+
// where: 条件查询(可选)
|
|
157
|
+
// where: {
|
|
158
|
+
// age: { $gte: 18 },
|
|
159
|
+
// status: { $eq: 'active' }
|
|
160
|
+
// },
|
|
161
|
+
|
|
162
|
+
// select: 字段选择(可选)
|
|
163
|
+
// select: ['id', 'name', 'age'],
|
|
164
|
+
|
|
165
|
+
// orderBy: 排序(可选)
|
|
166
|
+
// orderBy: [{ createTime: 'desc' }],
|
|
167
|
+
|
|
168
|
+
// 分页参数(必需)
|
|
169
|
+
currentPage: 1,
|
|
170
|
+
pageSize: 10
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
// 其他可用参数(仅示例,以实际字段为准):
|
|
174
|
+
// - where: 支持 $eq, $ne, $gte, $lte, $in, $contain, $startWith, $endWith 等操作符
|
|
175
|
+
// - where: 支持 $and, $or 逻辑组合
|
|
176
|
+
// - select: 数组形式,指定返回的字段
|
|
177
|
+
// - orderBy: 数组形式,支持多字段排序 [{ field1: 'desc' }, { field2: 'asc' }]`;
|
|
178
|
+
|
|
179
|
+
const selectOptionsCodeExample = `// ========== 方式一:标准 dataset_code 模式(推荐 AI/LLM 使用)==========
|
|
180
|
+
const options = await lovrabetClient
|
|
181
|
+
.models['${selectedModel || "dataset_xxx"}'].getSelectOptions({
|
|
182
|
+
code: "${codeField || "id"}",
|
|
183
|
+
label: "${labelField || "name"}"
|
|
184
|
+
});
|
|
185
|
+
${
|
|
186
|
+
selectedModelInfo?.alias
|
|
187
|
+
? `
|
|
188
|
+
// ========== 方式二:人类友好的 alias 模式 ==========
|
|
189
|
+
const options = await lovrabetClient
|
|
190
|
+
.models.${selectedModelInfo.alias}.getSelectOptions({
|
|
191
|
+
code: "${codeField || "id"}",
|
|
192
|
+
label: "${labelField || "name"}"
|
|
193
|
+
});
|
|
194
|
+
`
|
|
195
|
+
: ""
|
|
196
|
+
}
|
|
197
|
+
// 返回格式:[{ label: "显示文本", value: "选项值" }]`;
|
|
198
|
+
|
|
39
199
|
/**
|
|
40
200
|
* 加载可用的数据模型列表
|
|
41
201
|
*/
|
|
@@ -195,259 +355,182 @@ export default function SdkDemo() {
|
|
|
195
355
|
};
|
|
196
356
|
|
|
197
357
|
return (
|
|
198
|
-
<
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
<
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
{/* 数据模型选择 */}
|
|
213
|
-
<Card title="选择数据模型" size="small" style={{ marginBottom: 16 }}>
|
|
214
|
-
<Space>
|
|
215
|
-
<Select
|
|
216
|
-
placeholder="选择要查询的数据模型"
|
|
217
|
-
style={{ width: 350 }}
|
|
218
|
-
value={selectedModel}
|
|
219
|
-
onChange={setSelectedModel}
|
|
220
|
-
showSearch
|
|
221
|
-
optionFilterProp="label"
|
|
222
|
-
options={modelList}
|
|
223
|
-
/>
|
|
224
|
-
<Button
|
|
225
|
-
type="primary"
|
|
226
|
-
loading={loading}
|
|
227
|
-
onClick={loadData}
|
|
228
|
-
icon={<ApiOutlined />}
|
|
229
|
-
disabled={!selectedModel}
|
|
230
|
-
>
|
|
231
|
-
查询数据
|
|
232
|
-
</Button>
|
|
233
|
-
</Space>
|
|
234
|
-
</Card>
|
|
235
|
-
|
|
236
|
-
{/* 代码示例 */}
|
|
237
|
-
<Card title="代码示例" size="small" style={{ marginBottom: 16 }}>
|
|
238
|
-
<pre
|
|
239
|
-
style={{
|
|
240
|
-
background: "#f0f8ff",
|
|
241
|
-
padding: "16px",
|
|
242
|
-
borderRadius: "4px",
|
|
243
|
-
margin: 0,
|
|
244
|
-
fontSize: "13px",
|
|
245
|
-
border: "1px solid #1890ff",
|
|
246
|
-
overflow: "auto",
|
|
247
|
-
}}
|
|
248
|
-
>
|
|
249
|
-
{`// ========== 方式一:标准 dataset_code 模式(推荐 AI/LLM 使用)==========
|
|
250
|
-
const response = await lovrabetClient
|
|
251
|
-
.models['${selectedModel || "dataset_xxx"}'].filter({
|
|
252
|
-
currentPage: 1,
|
|
253
|
-
pageSize: 10
|
|
254
|
-
});
|
|
255
|
-
${
|
|
256
|
-
selectedModelInfo?.alias
|
|
257
|
-
? `
|
|
258
|
-
// ========== 方式二:人类友好的 alias 模式 ==========
|
|
259
|
-
const response = await lovrabetClient
|
|
260
|
-
.models.${selectedModelInfo.alias}.filter({
|
|
261
|
-
currentPage: 1,
|
|
262
|
-
pageSize: 10
|
|
263
|
-
});
|
|
264
|
-
`
|
|
265
|
-
: ""
|
|
266
|
-
}
|
|
267
|
-
// ========== 完整查询示例(所有参数均为可选)==========
|
|
268
|
-
const response = await lovrabetClient
|
|
269
|
-
.models['${selectedModel || "dataset_xxx"}'].filter({
|
|
270
|
-
// where: 条件查询(可选)
|
|
271
|
-
// where: {
|
|
272
|
-
// age: { $gte: 18 },
|
|
273
|
-
// status: { $eq: 'active' }
|
|
274
|
-
// },
|
|
275
|
-
|
|
276
|
-
// select: 字段选择(可选)
|
|
277
|
-
// select: ['id', 'name', 'age'],
|
|
278
|
-
|
|
279
|
-
// orderBy: 排序(可选)
|
|
280
|
-
// orderBy: [{ createTime: 'desc' }],
|
|
281
|
-
|
|
282
|
-
// 分页参数(必需)
|
|
283
|
-
currentPage: 1,
|
|
284
|
-
pageSize: 10
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
// 其他可用参数(仅示例,以实际字段为准):
|
|
288
|
-
// - where: 支持 $eq, $ne, $gte, $lte, $in, $contain, $startWith, $endWith 等操作符
|
|
289
|
-
// - where: 支持 $and, $or 逻辑组合
|
|
290
|
-
// - select: 数组形式,指定返回的字段
|
|
291
|
-
// - orderBy: 数组形式,支持多字段排序 [{ field1: 'desc' }, { field2: 'asc' }]`}
|
|
292
|
-
</pre>
|
|
293
|
-
</Card>
|
|
294
|
-
|
|
295
|
-
{/* 数据表格 */}
|
|
296
|
-
{data.length > 0 && (
|
|
297
|
-
<Card title="数据结果" size="small" style={{ marginBottom: 16 }}>
|
|
298
|
-
<Table
|
|
299
|
-
columns={columns}
|
|
300
|
-
dataSource={data}
|
|
301
|
-
rowKey={(_, index) => index?.toString() || "0"}
|
|
302
|
-
pagination={false}
|
|
303
|
-
size="small"
|
|
304
|
-
scroll={{ x: true }}
|
|
305
|
-
/>
|
|
306
|
-
</Card>
|
|
307
|
-
)}
|
|
358
|
+
<DemoPageContainer>
|
|
359
|
+
<div>
|
|
360
|
+
{/* 标题 */}
|
|
361
|
+
<Title level={2}>
|
|
362
|
+
<ApiOutlined /> Lovrabet SDK 简单演示
|
|
363
|
+
</Title>
|
|
364
|
+
|
|
365
|
+
<Paragraph style={{ color: "#666", marginBottom: 24 }}>
|
|
366
|
+
演示 Lovrabet SDK 的 <Text strong>filter</Text> 接口使用方法。filter
|
|
367
|
+
接口支持复杂条件查询、字段选择、多字段排序等功能。
|
|
368
|
+
<br />
|
|
369
|
+
<strong>注意:</strong>代码示例中的 "Requirements"
|
|
370
|
+
是假设已经存在的数据模型名称,实际使用时请根据下拉框中的可用模型进行选择。
|
|
371
|
+
</Paragraph>
|
|
308
372
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
<span style={{ color: "#666", marginRight: 8 }}>
|
|
321
|
-
可用字段(点击快速填入):
|
|
322
|
-
</span>
|
|
323
|
-
<Space wrap size={[4, 4]}>
|
|
324
|
-
{columns.map((column: any) => (
|
|
325
|
-
<Tag
|
|
326
|
-
key={column.dataIndex}
|
|
327
|
-
color="blue"
|
|
328
|
-
style={{ cursor: "pointer" }}
|
|
329
|
-
onClick={() => {
|
|
330
|
-
if (!codeField) {
|
|
331
|
-
setCodeField(column.dataIndex);
|
|
332
|
-
message.success(
|
|
333
|
-
`已填入 Code 字段: ${column.dataIndex}`,
|
|
334
|
-
);
|
|
335
|
-
} else if (!labelField) {
|
|
336
|
-
setLabelField(column.dataIndex);
|
|
337
|
-
message.success(
|
|
338
|
-
`已填入 Label 字段: ${column.dataIndex}`,
|
|
339
|
-
);
|
|
340
|
-
} else {
|
|
341
|
-
message.info("Code 和 Label 已填写,如需更换请先清空");
|
|
342
|
-
}
|
|
343
|
-
}}
|
|
344
|
-
>
|
|
345
|
-
{column.dataIndex}
|
|
346
|
-
</Tag>
|
|
347
|
-
))}
|
|
348
|
-
</Space>
|
|
349
|
-
</div>
|
|
350
|
-
)}
|
|
351
|
-
|
|
352
|
-
<Space wrap>
|
|
353
|
-
<span>Code 字段:</span>
|
|
354
|
-
<Input
|
|
355
|
-
placeholder="用作选项值的字段名"
|
|
356
|
-
value={codeField}
|
|
357
|
-
onChange={(e) => setCodeField(e.target.value)}
|
|
358
|
-
style={{ width: 200 }}
|
|
359
|
-
allowClear
|
|
360
|
-
/>
|
|
361
|
-
<span>Label 字段:</span>
|
|
362
|
-
<Input
|
|
363
|
-
placeholder="用作显示文本的字段名"
|
|
364
|
-
value={labelField}
|
|
365
|
-
onChange={(e) => setLabelField(e.target.value)}
|
|
366
|
-
style={{ width: 200 }}
|
|
367
|
-
allowClear
|
|
373
|
+
{/* 数据模型选择 */}
|
|
374
|
+
<Card title="选择数据模型" size="small" style={{ marginBottom: 16 }}>
|
|
375
|
+
<Space>
|
|
376
|
+
<Select
|
|
377
|
+
placeholder="选择要查询的数据模型"
|
|
378
|
+
style={{ width: 350 }}
|
|
379
|
+
value={selectedModel}
|
|
380
|
+
onChange={setSelectedModel}
|
|
381
|
+
showSearch
|
|
382
|
+
optionFilterProp="label"
|
|
383
|
+
options={modelList}
|
|
368
384
|
/>
|
|
369
385
|
<Button
|
|
370
386
|
type="primary"
|
|
371
387
|
loading={loading}
|
|
372
|
-
onClick={
|
|
388
|
+
onClick={loadData}
|
|
373
389
|
icon={<ApiOutlined />}
|
|
374
|
-
disabled={!selectedModel
|
|
390
|
+
disabled={!selectedModel}
|
|
375
391
|
>
|
|
376
|
-
|
|
392
|
+
查询数据
|
|
377
393
|
</Button>
|
|
378
394
|
</Space>
|
|
395
|
+
</Card>
|
|
379
396
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
label: "${labelField || "name"}"
|
|
404
|
-
});
|
|
405
|
-
`
|
|
406
|
-
: ""
|
|
407
|
-
}
|
|
408
|
-
// 返回格式:[{ label: "显示文本", value: "选项值" }]`}
|
|
409
|
-
</pre>
|
|
410
|
-
</Space>
|
|
411
|
-
</Card>
|
|
397
|
+
{/* 数据表格 */}
|
|
398
|
+
{data.length > 0 && (
|
|
399
|
+
<Card title="数据结果" size="small" style={{ marginBottom: 16 }}>
|
|
400
|
+
<Table
|
|
401
|
+
columns={columns}
|
|
402
|
+
dataSource={data}
|
|
403
|
+
rowKey={(_, index) => index?.toString() || "0"}
|
|
404
|
+
pagination={false}
|
|
405
|
+
size="small"
|
|
406
|
+
scroll={{ x: true }}
|
|
407
|
+
/>
|
|
408
|
+
</Card>
|
|
409
|
+
)}
|
|
410
|
+
|
|
411
|
+
{/* 代码示例 */}
|
|
412
|
+
<Card title="代码示例" size="small" style={{ marginBottom: 16 }}>
|
|
413
|
+
<CollapsibleCodeBlock
|
|
414
|
+
title="filter 查询代码"
|
|
415
|
+
code={filterCodeExample}
|
|
416
|
+
accent
|
|
417
|
+
defaultExpanded
|
|
418
|
+
/>
|
|
419
|
+
</Card>
|
|
412
420
|
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
421
|
+
{/* 获取下拉选项 */}
|
|
422
|
+
<Card title="📋 获取下拉选项" size="small" style={{ marginBottom: 16 }}>
|
|
423
|
+
<Space direction="vertical" style={{ width: "100%" }}>
|
|
424
|
+
<div style={{ color: "#666" }}>
|
|
425
|
+
用于获取数据表的下拉选项数据,适用于 Select、Radio、Checkbox
|
|
426
|
+
等表单组件(仅 WebAPI 模式支持)
|
|
427
|
+
</div>
|
|
428
|
+
|
|
429
|
+
{/* 显示可用字段 */}
|
|
430
|
+
{columns.length > 0 && (
|
|
431
|
+
<div style={{ marginBottom: 8 }}>
|
|
432
|
+
<span style={{ color: "#666", marginRight: 8 }}>
|
|
433
|
+
可用字段(点击快速填入):
|
|
434
|
+
</span>
|
|
435
|
+
<Space wrap size={[4, 4]}>
|
|
436
|
+
{columns.map((column: any) => (
|
|
437
|
+
<Tag
|
|
438
|
+
key={column.dataIndex}
|
|
439
|
+
color="blue"
|
|
440
|
+
style={{ cursor: "pointer" }}
|
|
441
|
+
onClick={() => {
|
|
442
|
+
if (!codeField) {
|
|
443
|
+
setCodeField(column.dataIndex);
|
|
444
|
+
message.success(
|
|
445
|
+
`已填入 Code 字段: ${column.dataIndex}`,
|
|
446
|
+
);
|
|
447
|
+
} else if (!labelField) {
|
|
448
|
+
setLabelField(column.dataIndex);
|
|
449
|
+
message.success(
|
|
450
|
+
`已填入 Label 字段: ${column.dataIndex}`,
|
|
451
|
+
);
|
|
452
|
+
} else {
|
|
453
|
+
message.info(
|
|
454
|
+
"Code 和 Label 已填写,如需更换请先清空",
|
|
455
|
+
);
|
|
456
|
+
}
|
|
457
|
+
}}
|
|
458
|
+
>
|
|
459
|
+
{column.dataIndex}
|
|
460
|
+
</Tag>
|
|
461
|
+
))}
|
|
462
|
+
</Space>
|
|
463
|
+
</div>
|
|
464
|
+
)}
|
|
465
|
+
|
|
466
|
+
<Space wrap>
|
|
467
|
+
<span>Code 字段:</span>
|
|
468
|
+
<Input
|
|
469
|
+
placeholder="用作选项值的字段名"
|
|
470
|
+
value={codeField}
|
|
471
|
+
onChange={(e) => setCodeField(e.target.value)}
|
|
472
|
+
style={{ width: 200 }}
|
|
473
|
+
allowClear
|
|
474
|
+
/>
|
|
475
|
+
<span>Label 字段:</span>
|
|
476
|
+
<Input
|
|
477
|
+
placeholder="用作显示文本的字段名"
|
|
478
|
+
value={labelField}
|
|
479
|
+
onChange={(e) => setLabelField(e.target.value)}
|
|
480
|
+
style={{ width: 200 }}
|
|
481
|
+
allowClear
|
|
482
|
+
/>
|
|
483
|
+
<Button
|
|
484
|
+
type="primary"
|
|
485
|
+
loading={loading}
|
|
486
|
+
onClick={loadSelectOptions}
|
|
487
|
+
icon={<ApiOutlined />}
|
|
488
|
+
disabled={!selectedModel || !codeField || !labelField}
|
|
489
|
+
>
|
|
490
|
+
获取选项
|
|
491
|
+
</Button>
|
|
492
|
+
</Space>
|
|
493
|
+
|
|
494
|
+
<CollapsibleCodeBlock
|
|
495
|
+
title="getSelectOptions 代码"
|
|
496
|
+
code={selectOptionsCodeExample}
|
|
497
|
+
defaultExpanded
|
|
498
|
+
/>
|
|
499
|
+
</Space>
|
|
432
500
|
</Card>
|
|
433
|
-
)}
|
|
434
501
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
502
|
+
{/* 下拉选项结果 */}
|
|
503
|
+
{selectOptions.length > 0 && (
|
|
504
|
+
<Card
|
|
505
|
+
title={`下拉选项结果(共 ${selectOptions.length} 个)`}
|
|
506
|
+
size="small"
|
|
507
|
+
>
|
|
508
|
+
<CollapsibleCodeBlock
|
|
509
|
+
title="下拉选项 JSON"
|
|
510
|
+
code={JSON.stringify(selectOptions, null, 2)}
|
|
511
|
+
defaultExpanded
|
|
512
|
+
maxHeight={400}
|
|
513
|
+
/>
|
|
514
|
+
</Card>
|
|
515
|
+
)}
|
|
516
|
+
|
|
517
|
+
{/* API 参考文档 */}
|
|
518
|
+
<Card size="small" style={{ marginTop: 24, background: "#f5f5f5" }}>
|
|
519
|
+
<Paragraph style={{ margin: 0, textAlign: "center" }}>
|
|
520
|
+
<Text type="secondary">
|
|
521
|
+
技术开发文档指引:{" "}
|
|
522
|
+
<a
|
|
523
|
+
href="https://qizhiyuntu.feishu.cn/wiki/CMfxw6l2li01EVkBTcBcshD3nSe"
|
|
524
|
+
target="_blank"
|
|
525
|
+
rel="noopener noreferrer"
|
|
526
|
+
style={{ color: "#1890ff" }}
|
|
527
|
+
>
|
|
528
|
+
https://qizhiyuntu.feishu.cn/wiki/CMfxw6l2li01EVkBTcBcshD3nSe
|
|
529
|
+
</a>
|
|
530
|
+
</Text>
|
|
531
|
+
</Paragraph>
|
|
532
|
+
</Card>
|
|
533
|
+
</div>
|
|
534
|
+
</DemoPageContainer>
|
|
452
535
|
);
|
|
453
536
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
@import url(
|
|
1
|
+
@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;600;700&display=swap");
|
|
2
2
|
|
|
3
|
+
/* workbench 的页面级外层 gutter 由 DemoPageContainer 负责。
|
|
4
|
+
这里不要再加根节点 padding,否则会和共享容器叠出双层间距。 */
|
|
3
5
|
.page {
|
|
4
|
-
font-family:
|
|
6
|
+
font-family: "Noto Sans SC", system-ui, sans-serif;
|
|
5
7
|
background: #f5f5f7;
|
|
6
|
-
padding: 20px;
|
|
7
|
-
min-height: 100vh;
|
|
8
|
-
margin: -16px;
|
|
9
8
|
color: #1d1d1f;
|
|
9
|
+
border-radius: 16px;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
/* 欢迎区域 - 简洁直接 */
|
|
@@ -45,7 +45,9 @@
|
|
|
45
45
|
border-radius: 12px;
|
|
46
46
|
padding: 20px;
|
|
47
47
|
border: 1px solid #e5e5e7;
|
|
48
|
-
transition:
|
|
48
|
+
transition:
|
|
49
|
+
transform 0.2s ease,
|
|
50
|
+
box-shadow 0.2s ease;
|
|
49
51
|
cursor: default;
|
|
50
52
|
}
|
|
51
53
|
|