openyida 2026.11.2 → 2026.11.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.
- package/README.md +11 -9
- package/bin/yida.js +2 -1
- package/lib/app/application-entry-urls.js +35 -1
- package/lib/app/check-prd-completeness.js +27 -6
- package/lib/app/create-app.js +17 -9
- package/lib/app/fast-build.js +151 -0
- package/lib/app/fast-theme.js +83 -0
- package/lib/app/form-data-contract.js +162 -0
- package/lib/app/services/canvas-page-schema-builder.js +10 -0
- package/lib/asset/ai-image.js +8 -5
- package/lib/asset/asset-cmd.js +24 -4
- package/lib/asset/asset-execution.js +25 -4
- package/lib/asset/asset-plan.js +4 -2
- package/lib/asset/asset-resolve.js +21 -7
- package/lib/auth/oauth-loopback.js +1 -1
- package/lib/auth/org.js +2 -0
- package/lib/auth/token-auth.js +1 -0
- package/lib/core/agent-capabilities.js +30 -9
- package/lib/core/batch.js +71 -122
- package/lib/core/command-manifest.js +71 -38
- package/lib/core/locales/en.js +20 -4
- package/lib/core/locales/zh.js +19 -3
- package/lib/core/permission-guidance.js +10 -10
- package/lib/core/query-data.js +67 -10
- package/lib/core/sample.js +73 -0
- package/lib/core/task-concurrency.js +96 -0
- package/lib/corp-efficiency/corp-efficiency.js +15 -8
- package/lib/design/fast-document.js +118 -0
- package/lib/design-plan/design-plan.js +3 -3
- package/lib/design-plan/init.js +90 -5
- package/lib/design-plan/materialize.js +2 -2
- package/lib/design-plan/validate.js +64 -9
- package/lib/flash-note/build-flash-note-prompt.js +1 -1
- package/lib/samples/openyida-scaffold/canvas-data-source.jsx +135 -0
- package/lib/samples/openyida-scaffold/canvas-file-upload.jsx +106 -0
- package/lib/samples/openyida-scaffold/file-upload-client.jsx +160 -0
- package/lib/samples/yida-app/fast-app.json +64 -0
- package/lib/samples/yida-design/fast-design.json +38 -0
- package/package.json +3 -3
- package/scripts/postinstall.js +6 -6
- package/yida-skills/SKILL.md +10 -9
- package/yida-skills/references/official-example-schema-patterns.md +3 -3
- package/yida-skills/references/qwenwork-link-presentation.md +11 -16
- package/yida-skills/references/user-facing-summary.md +1 -1
- package/yida-skills/skills/yida-app/SKILL.md +23 -12
- package/yida-skills/skills/yida-app/references/fast-context.md +7 -0
- package/yida-skills/skills/yida-app/workflow/fast-build.md +65 -0
- package/yida-skills/skills/yida-app/workflow/parallel-work.md +15 -5
- package/yida-skills/skills/yida-app/workflow/plan/workflow.md +5 -1
- package/yida-skills/skills/yida-app/workflow/step-2-design.md +13 -6
- package/yida-skills/skills/yida-app/workflow/step-3-create-or-reuse-app.md +7 -2
- package/yida-skills/skills/yida-app/workflow/step-4-forms-processes.md +4 -1
- package/yida-skills/skills/yida-app/workflow/step-5-seed-records.md +4 -1
- package/yida-skills/skills/yida-app/workflow/step-6-main-page.md +3 -0
- package/yida-skills/skills/yida-app/workflow/step-7-page-code.md +5 -2
- package/yida-skills/skills/yida-app/workflow/step-8-publish-navigation.md +3 -0
- package/yida-skills/skills/yida-app/workflow/step-9-output-finish.md +7 -2
- package/yida-skills/skills/yida-canvas-custom-page/SKILL.md +14 -4
- package/yida-skills/skills/yida-canvas-custom-page/references/data-bridge-guide.md +2 -0
- package/yida-skills/skills/yida-canvas-custom-page/references/file-upload.md +75 -0
- package/yida-skills/skills/yida-canvas-custom-page/references/native-components-bridge.md +4 -3
- package/yida-skills/skills/yida-canvas-custom-page/references/page-generation-guide.md +1 -1
- package/yida-skills/skills/yida-canvas-data-binding/SKILL.md +23 -82
- package/yida-skills/skills/yida-corp-efficiency/SKILL.md +3 -3
- package/yida-skills/skills/yida-create-app/SKILL.md +9 -5
- package/yida-skills/skills/yida-create-form-page/SKILL.md +1 -1
- package/yida-skills/skills/yida-create-form-page/references/field-definition-guide.md +1 -1
- package/yida-skills/skills/yida-create-form-page/references/form-field-properties.md +13 -17
- package/yida-skills/skills/yida-custom-page/SKILL.md +2 -0
- package/yida-skills/skills/yida-custom-page/references/attachment-upload-guide.md +4 -0
- package/yida-skills/skills/yida-data-management/SKILL.md +2 -0
- package/yida-skills/skills/yida-data-management/references/data-format-guide.md +9 -0
- package/yida-skills/skills/yida-design/SKILL.md +7 -2
- package/yida-skills/skills/yida-design/references/application-theme-consistency.md +4 -4
- package/yida-skills/skills/yida-design/references/ask-human-interaction-contract.md +2 -2
- package/yida-skills/skills/yida-design/references/design-mode.md +4 -2
- package/yida-skills/skills/yida-design/references/fast-design-spec.md +32 -0
- package/yida-skills/skills/yida-design/references/native-form-styles.md +2 -2
- package/yida-skills/skills/yida-design/templates/design-themes/app-teal/design.md +4 -4
- package/yida-skills/skills/yida-design/templates/design-themes/app-terminal/design.md +4 -4
- package/yida-skills/skills/yida-design/workflow/output-design.md +1 -1
- package/yida-skills/skills/yida-design/workflow/step-4-wireframe-interaction.md +1 -1
- package/yida-skills/skills/yida-design/workflow/step-6-handoff.md +1 -1
- package/yida-skills/skills/yida-dingtalk-openapi/references/api-contract.md +1 -1
- package/yida-skills/skills/yida-flash-note-to-prd/references/flash-note-prompt.md +1 -1
- package/yida-skills/skills/yida-image-assets/SKILL.md +11 -5
- package/yida-skills/skills/yida-login/SKILL.md +6 -0
- package/yida-skills/skills/yida-ppt-slider/references/examples.md +3 -3
- package/yida-skills/skills/yida-prd/SKILL.md +5 -1
- package/yida-skills/skills/yida-publish-page/SKILL.md +3 -0
- package/yida-skills/skills/yida-requirement-analysis/SKILL.md +4 -1
- package/yida-skills/skills/yida-requirement-analysis/references/handoff.md +4 -1
- package/yida-skills/skills/yida-requirement-analysis/workflow/prepare-brief.md +3 -0
- package/yida-skills/skills-index.json +2 -2
package/lib/design-plan/init.js
CHANGED
|
@@ -8,6 +8,7 @@ const { readJson, writeFiles } = require('./files');
|
|
|
8
8
|
const { planBase } = require('./parallel');
|
|
9
9
|
const { collectIssues } = require('./validate');
|
|
10
10
|
const { assertVisualFieldObjects } = require('./normalize');
|
|
11
|
+
const { normalizeCssColorToHex } = require('../app/custom-theme');
|
|
11
12
|
|
|
12
13
|
const { DESIGN_SKILL_ROOT, PLAN_SKILL_ROOT: ROOT, loadThemeIndex, themeTemplatePath, themeNavTheme } = require('./themes');
|
|
13
14
|
|
|
@@ -15,6 +16,59 @@ function list(value) {
|
|
|
15
16
|
return Array.isArray(value) ? value : [];
|
|
16
17
|
}
|
|
17
18
|
|
|
19
|
+
// Fill structural defaults only; explicit values and unresolved business choices stay authoritative.
|
|
20
|
+
function defaults(value, fallback) {
|
|
21
|
+
if (value === undefined) {return { ...fallback };}
|
|
22
|
+
return value && typeof value === 'object' && !Array.isArray(value) ? { ...fallback, ...value } : value;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function prepareSkeleton(plan) {
|
|
26
|
+
for (const model of plan.dataModels) {
|
|
27
|
+
model.fields = model.fields.map(field => defaults(field, {
|
|
28
|
+
name: '', type: '', defaultOrOptions: '', relation: '', group: '', description: '',
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
for (const page of plan.pages.customPageDetails) {
|
|
32
|
+
page.layoutPattern = defaults(page.layoutPattern, { id: 'custom-page-pattern', reason: '', adaptations: [] });
|
|
33
|
+
// contentLayers is derived from completed blocks by the existing normalizer.
|
|
34
|
+
page.contentRichness = defaults(page.contentRichness, { requirement: 'rich-but-relevant' });
|
|
35
|
+
}
|
|
36
|
+
const user = plan.visualStyle.forUser;
|
|
37
|
+
const primary = normalizeCssColorToHex(user.colorStrategy.primaryColor);
|
|
38
|
+
if (primary) {
|
|
39
|
+
user.colorStrategy.primaryColor = primary;
|
|
40
|
+
plan.visualStyle.tokens = defaults(plan.visualStyle.tokens, { '--color-brand1-6': primary });
|
|
41
|
+
}
|
|
42
|
+
user.assetStrategy = defaults(user.assetStrategy, { pages: [] });
|
|
43
|
+
for (const entry of list(plan.execution.entryRecommendation?.entries)) {
|
|
44
|
+
if (!entry || typeof entry !== 'object' || Array.isArray(entry)) {continue;}
|
|
45
|
+
const page = plan.pages.customPageDetails.find(item => item.sceneKey === entry?.sceneKey);
|
|
46
|
+
const leaves = [];
|
|
47
|
+
const usedKeys = new Set();
|
|
48
|
+
const reserve = items => list(items).forEach(item => { if (item?.key) {usedKeys.add(item.key);} reserve(item?.children); });
|
|
49
|
+
reserve(entry.menu);
|
|
50
|
+
const visit = (items, prefix = '') => list(items).forEach((item, index) => {
|
|
51
|
+
if (!item || typeof item !== 'object' || Array.isArray(item)) {return;}
|
|
52
|
+
if (item.key === undefined) {
|
|
53
|
+
const base = `menu-${prefix}${index + 1}`;
|
|
54
|
+
item.key = base;
|
|
55
|
+
for (let suffix = 2; usedKeys.has(item.key); suffix++) {item.key = `${base}-${suffix}`;}
|
|
56
|
+
usedKeys.add(item.key);
|
|
57
|
+
}
|
|
58
|
+
if (item.children !== undefined) {visit(item.children, `${prefix}${index + 1}-`); return;}
|
|
59
|
+
if (item.targetType === 'local' && page) {
|
|
60
|
+
if (item.resource === undefined) {item.resource = page.name;}
|
|
61
|
+
if (item.viewKey === undefined) {item.viewKey = item.key;}
|
|
62
|
+
}
|
|
63
|
+
if (item.label === undefined && typeof item.resource === 'string') {item.label = item.resource;}
|
|
64
|
+
// Scope and entry purpose are business decisions; do not fabricate access requirements.
|
|
65
|
+
leaves.push(item);
|
|
66
|
+
});
|
|
67
|
+
visit(entry?.menu);
|
|
68
|
+
if (entry && entry.defaultMenuKey === undefined && leaves.length === 1) {entry.defaultMenuKey = leaves[0].key;}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
18
72
|
function normalizeColorStrategy(value) {
|
|
19
73
|
if (value === undefined || value === null) {return {};}
|
|
20
74
|
if (typeof value === 'string') {return { usage: value };}
|
|
@@ -53,8 +107,18 @@ function loadCatalog() {
|
|
|
53
107
|
};
|
|
54
108
|
}
|
|
55
109
|
|
|
56
|
-
function catalog() {
|
|
110
|
+
function catalog(options = {}) {
|
|
57
111
|
const { themes, pagePatterns } = loadCatalog();
|
|
112
|
+
if (options.compact) {
|
|
113
|
+
const compact = theme => ({ themeId: theme.themeId, label: theme.label,
|
|
114
|
+
contentTone: theme.contentTone, navTheme: theme.navTheme,
|
|
115
|
+
...(theme.supportedNavigationLayouts ? { supportedNavigationLayouts: theme.supportedNavigationLayouts } : {}),
|
|
116
|
+
...(theme.themeId === 'app-pop' ? { selectionEligibility: getVisualDecisionPolicy().themeSelection.eligibility['app-pop'] } : {}),
|
|
117
|
+
});
|
|
118
|
+
return { success: true, format: 'compact', themes: themes.filter(theme => theme.mode !== 'creative').map(compact),
|
|
119
|
+
creativeOption: compact(themes.find(theme => theme.mode === 'creative')),
|
|
120
|
+
previewDefault: false, fullCatalogArgv: ['design-plan', 'catalog', '--json'] };
|
|
121
|
+
}
|
|
58
122
|
const previews = readJson(path.join(DESIGN_SKILL_ROOT, 'references/theme-preview-images.json'));
|
|
59
123
|
return {
|
|
60
124
|
success: true,
|
|
@@ -74,7 +138,14 @@ function catalog() {
|
|
|
74
138
|
// Format examples stay outside business facts, so examples never become requirements.
|
|
75
139
|
function authoringGuidance(plan, business, visual, businessReady, visualReady) {
|
|
76
140
|
const color = plan.visualStyle.forUser.colorStrategy;
|
|
77
|
-
const
|
|
141
|
+
const sampleModel = plan.dataModels.find(item => !String(item?.formType || '').includes('流程'));
|
|
142
|
+
const model = sampleModel || plan.dataModels[0];
|
|
143
|
+
const field = model?.fields?.[0];
|
|
144
|
+
const modelName = typeof model?.name === 'string' && model.name.trim() ? model.name : '业务资源';
|
|
145
|
+
const fieldName = typeof field?.name === 'string' && field.name.trim() ? field.name : '业务字段';
|
|
146
|
+
const page = plan.pages.customPageDetails[0];
|
|
147
|
+
const pendingFields = collectIssues(plan, { authoringContract: true }).map(issue => ({
|
|
148
|
+
...issue,
|
|
78
149
|
file: issue.path.startsWith('visualStyle.') ? visual : business,
|
|
79
150
|
path: `facts.${issue.path}`,
|
|
80
151
|
message: issue.message,
|
|
@@ -89,7 +160,14 @@ function authoringGuidance(plan, business, visual, businessReady, visualReady) {
|
|
|
89
160
|
examples: {
|
|
90
161
|
colorStrategy: { primaryColor: color.primaryColor, primaryColorName: color.primaryColorName, usage: color.usage },
|
|
91
162
|
blocks: [{ name: '客房选择', purpose: '按日期和人数筛选可预约房型' }, { name: '预约结果', purpose: '查看提交结果,失败时保留已填内容并显示原因' }],
|
|
92
|
-
field: { name:
|
|
163
|
+
field: { name: fieldName, type: typeof field?.type === 'string' && field.type.trim() ? field.type : 'TextField',
|
|
164
|
+
required: typeof field?.required === 'boolean' ? field.required : true, defaultOrOptions: '', relation: '', group: '', description: '' },
|
|
165
|
+
entryMenu: { key: 'task', label: modelName, resource: modelName, targetType: 'page',
|
|
166
|
+
access: [{ resource: modelName, operation: 'OPERATE_VIEW', dataScope: '填写当前角色已确认的数据范围' }] },
|
|
167
|
+
localMenu: { key: 'task', label: page?.name || '页面内任务', resource: page?.name || '承载页面名称', targetType: 'local', viewKey: 'task',
|
|
168
|
+
access: [{ resource: page?.name || '承载页面名称', operation: 'OPERATE_VIEW', dataScope: '填写当前角色已确认的数据范围' }] },
|
|
169
|
+
contentRichness: { requirement: 'rich-but-relevant', contentLayers: ['填写当前页面的实际内容层次;也可省略,由完整 blocks 派生'] },
|
|
170
|
+
assetStrategy: { pages: [] },
|
|
93
171
|
businessFragment: { facts: {
|
|
94
172
|
overview: { businessGraph: { relations: [{ from: '订单', to: '客户', label: '归属客户', description: '一个客户可以拥有多笔订单' }] } },
|
|
95
173
|
businessFlows: [{ name: '订单审核', type: '审批', description: '订单提交后审核', trigger: '订单提交', nodes: ['提交', '审批'], rules: ['审批通过后进入执行'] }],
|
|
@@ -101,7 +179,7 @@ function authoringGuidance(plan, business, visual, businessReady, visualReady) {
|
|
|
101
179
|
} },
|
|
102
180
|
skippedSampleDataPlan: { path: 'facts.execution.sampleDataPlan', value: [{ form: '订单', skipReason: '填写本项目跳过示例数据的原因' }] },
|
|
103
181
|
referenceRules: 'relations.from/to、field.relation、dataSources 必须填写 dataModels 中的完整名称;关系描述写 description,不放进引用值。示例中的模型名和流程只说明格式,无此业务时使用空数组。',
|
|
104
|
-
pageApplication: { pageId: '填写实际页面ID', firstScreenFocus: '待审批订单位于首屏左上,数量与最临近截止时间组成焦点',
|
|
182
|
+
pageApplication: { pageId: page?.pageId || '填写实际页面ID', firstScreenFocus: '待审批订单位于首屏左上,数量与最临近截止时间组成焦点',
|
|
105
183
|
layout: '桌面主列放待审批表格,右列放当前订单详情;两列比例为 2:1,区块间距 24px',
|
|
106
184
|
primaryAction: '待审批表格每行末尾提供审批按钮,打开该订单对应的原生审批页面,处理成功后刷新列表',
|
|
107
185
|
responsive: '宽度小于 768px 时详情移至表格下方,行内次操作收入菜单,主操作保持可见',
|
|
@@ -240,6 +318,7 @@ function initialize(inputPath, options = {}) {
|
|
|
240
318
|
},
|
|
241
319
|
askhuman: {},
|
|
242
320
|
};
|
|
321
|
+
prepareSkeleton(plan);
|
|
243
322
|
// Keep the business description and visual memory rules verbatim; the renderer consumes the full template.
|
|
244
323
|
const template = fs.readFileSync(themeTemplatePath(theme), 'utf8');
|
|
245
324
|
const overview = template.match(/^## 1\. 风格摘要\n([\s\S]*?)(?=^## |$(?![\s\S]))/m)?.[0];
|
|
@@ -279,7 +358,8 @@ function initialize(inputPath, options = {}) {
|
|
|
279
358
|
&& ['top', 'side'].includes(selectedVisual.navigationStyle.structure)
|
|
280
359
|
&& ['light', 'dark'].includes(selectedVisual.navigationStyle.tone)
|
|
281
360
|
&& ['label', 'description'].every(key => typeof selectedVisual.visualDirection[key] === 'string' && selectedVisual.visualDirection[key].trim())
|
|
282
|
-
&& !collectIssues(plan).some(issue => issue.path.startsWith('visualStyle.forUser.pageApplications[')
|
|
361
|
+
&& !collectIssues(plan, { authoringContract: true }).some(issue => issue.path.startsWith('visualStyle.forUser.pageApplications[')
|
|
362
|
+
|| issue.path.startsWith('visualStyle.forUser.assetStrategy')
|
|
283
363
|
|| issue.path.startsWith('visualStyle.creativeDirection.') || issue.path.startsWith('visualStyle.tokens.'));
|
|
284
364
|
const visualPart = `${JSON.stringify({ base, ready: visualReady, facts: { visualStyle: plan.visualStyle } }, null, 2)}\n`;
|
|
285
365
|
const authoring = authoringGuidance(plan, business, visual, businessReady, visualReady);
|
|
@@ -288,10 +368,15 @@ function initialize(inputPath, options = {}) {
|
|
|
288
368
|
writeFiles([[output, `${JSON.stringify(plan, null, 2)}\n`], [baseline, `${JSON.stringify({ schemaVersion: 1, base, plan }, null, 2)}\n`], [guide, context + formatContext], [business, businessPart], [visual, visualPart]]);
|
|
289
369
|
return { success: true, input, output, context: guide, contract: path.join(ROOT, 'references/build-plan-compact-schema.md'), draft: true,
|
|
290
370
|
materialize: { mode: 'complete_files_once', maxSuccessfulCalls: 1, repairPolicy: require('../core/source-repair').REPAIR_POLICY,
|
|
371
|
+
checkCommand: materializeCommand.replace(/ --json$/, ' --check --json'),
|
|
291
372
|
shell: process.platform === 'win32' ? 'powershell' : 'posix',
|
|
292
373
|
command: materializeCommand },
|
|
293
374
|
parallelTasks: [...(!businessReady ? [{ id: 'business', skill: 'yida-prd', output: business, dependsOn: [] }] : []),
|
|
294
375
|
...(!visualReady ? [{ id: 'visual-design', skill: 'yida-design', output: visual, dependsOn: !businessReady && pages.length ? ['business'] : [] }] : [])],
|
|
376
|
+
taskExecution: { capabilitySource: 'agent-capabilities.task_execution',
|
|
377
|
+
orchestration: 'one orchestrator; ready CLI batches or available host subagents for independent reasoning tasks',
|
|
378
|
+
inputs: [input, guide], exclusiveOutputs: [business, visual], dependencyField: 'parallelTasks[].dependsOn',
|
|
379
|
+
join: 'Validate each ready output before materialize; no concurrent writers to one fragment.' },
|
|
295
380
|
preparedInputs: { business, businessReady, visual, visualReady },
|
|
296
381
|
authoring: { pendingFields: authoring.pendingFields, completion: authoring.completion, visualDecision: authoring.visualDecision },
|
|
297
382
|
optionalTasks: [{ id: 'visual-refinement', skill: 'yida-design', input: business, output: visual, dependsOn: ['business'],
|
|
@@ -867,7 +867,7 @@ function prepareArtifacts(sourcePlan, outputDir, themeSeed, options = {}) {
|
|
|
867
867
|
};
|
|
868
868
|
const plan = measure('validationAndNormalizationMs', () => {
|
|
869
869
|
const normalized = normalizePlan(sourcePlan);
|
|
870
|
-
validateAuthoring(normalized);
|
|
870
|
+
validateAuthoring(normalized, { authoringContract: options.authoringContract });
|
|
871
871
|
return normalized;
|
|
872
872
|
});
|
|
873
873
|
const designFile = path.resolve(outputDir, 'design.md');
|
|
@@ -978,7 +978,7 @@ function materializeUnlocked(inputPath, options = {}) {
|
|
|
978
978
|
&& ['design.md', 'app-theme.css'].every(name => fs.existsSync(path.join(previewDir, name)))) {
|
|
979
979
|
themeSeed = { design: fs.readFileSync(path.join(previewDir, 'design.md'), 'utf8'), css: fs.readFileSync(path.join(previewDir, 'app-theme.css'), 'utf8') };
|
|
980
980
|
}
|
|
981
|
-
const artifacts = prepareArtifacts(merged, outputDir, themeSeed);
|
|
981
|
+
const artifacts = prepareArtifacts(merged, outputDir, themeSeed, { authoringContract: options.check === true });
|
|
982
982
|
const updates = prepareArtifactUpdate(artifacts, outputDir);
|
|
983
983
|
if (updates.files.some(([file]) => path.resolve(file) === input)) {
|
|
984
984
|
throw new CliError('输出文件不能覆盖 build-plan.json', { code: 'DESIGN_PLAN_OUTPUT_CONFLICT' });
|
|
@@ -8,16 +8,23 @@ const { PLAN_SKILL_ROOT: ROOT, loadThemeIndex } = require('./themes');
|
|
|
8
8
|
const { concretePageText } = require('../design/page-content');
|
|
9
9
|
const { ENTRY_MODES } = require('./entry-navigation');
|
|
10
10
|
const { t } = require('../core/i18n');
|
|
11
|
+
const { normalizeCssColorToHex } = require('../app/custom-theme');
|
|
11
12
|
|
|
12
13
|
const object = value => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
13
14
|
const filled = value => typeof value === 'string' && value.trim().length > 0;
|
|
14
15
|
|
|
15
16
|
// Collect independent authoring errors before running the full rendering and business validators.
|
|
16
|
-
function collectIssues(plan) {
|
|
17
|
+
function collectIssues(plan, options = {}) {
|
|
17
18
|
const issues = [];
|
|
18
|
-
const check = (valid, path, message
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const check = (valid, path, message, details = {}) => {
|
|
20
|
+
if (!valid) {issues.push({ path, message, code: 'INVALID_CONTRACT', ...details });} return !!valid;
|
|
21
|
+
};
|
|
22
|
+
const contract = (valid, path, expectedType, code, extra = {}) => check(valid, path,
|
|
23
|
+
t('design_document.invalid', path, code), { code, expectedType, ...extra });
|
|
24
|
+
const strings = (value, path, keys) => keys.forEach(key => check(filled(value?.[key]), `${path}.${key}`, '填写非空文本',
|
|
25
|
+
{ code: 'EXPECTED_NONEMPTY_STRING', expectedType: 'string' }));
|
|
26
|
+
const array = (value, path, required = false) => check(Array.isArray(value) && (!required || value.length > 0), path, required ? '填写非空数组' : '填写数组',
|
|
27
|
+
{ code: required ? 'EXPECTED_NONEMPTY_ARRAY' : 'EXPECTED_ARRAY', expectedType: 'array' });
|
|
21
28
|
if (!check(object(plan), '$', '填写计划对象')) {return issues;}
|
|
22
29
|
strings(plan.meta, 'meta', ['projectName', 'revision']);
|
|
23
30
|
if (plan.visualStyle?.forUser?.selectedTheme) {strings(plan.meta, 'meta', ['experienceTopology', 'businessDomain']);}
|
|
@@ -35,7 +42,8 @@ function collectIssues(plan) {
|
|
|
35
42
|
if (array(model.fields, `${p}.fields`, true)) {
|
|
36
43
|
model.fields.forEach((field, i) => {
|
|
37
44
|
strings(field, `${p}.fields[${i}]`, ['name', 'type']);
|
|
38
|
-
check(typeof field?.required === 'boolean', `${p}.fields[${i}].required`, '使用 true 或 false'
|
|
45
|
+
check(typeof field?.required === 'boolean', `${p}.fields[${i}].required`, '使用 true 或 false',
|
|
46
|
+
{ code: 'EXPECTED_BOOLEAN', expectedType: 'boolean', allowedValues: [true, false] });
|
|
39
47
|
});
|
|
40
48
|
}
|
|
41
49
|
});
|
|
@@ -85,7 +93,40 @@ function collectIssues(plan) {
|
|
|
85
93
|
const p = `execution.entryRecommendation.entries[${index}]`;
|
|
86
94
|
strings(entry, p, ['key', 'name', 'defaultMenuKey']);
|
|
87
95
|
check(['service', 'management', 'workspace'].includes(entry?.role), `${p}.role`, '选择 service/management/workspace');
|
|
88
|
-
array(entry?.menu, `${p}.menu`, true);
|
|
96
|
+
const hasMenu = array(entry?.menu, `${p}.menu`, true);
|
|
97
|
+
if (hasMenu && options.authoringContract) {
|
|
98
|
+
const keys = new Set();
|
|
99
|
+
const visit = (items, prefix) => items.forEach((item, menuIndex) => {
|
|
100
|
+
const m = `${prefix}[${menuIndex}]`;
|
|
101
|
+
if (!contract(object(item), m, 'object', 'EXPECTED_OBJECT')) {return;}
|
|
102
|
+
strings(item, m, ['key', 'label']);
|
|
103
|
+
contract(!keys.has(item.key), `${m}.key`, 'string', 'DUPLICATE_MENU_KEY'); keys.add(item.key);
|
|
104
|
+
if (item.children !== undefined) {
|
|
105
|
+
if (array(item.children, `${m}.children`, true)) {visit(item.children, `${m}.children`);}
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
strings(item, m, ['resource']);
|
|
109
|
+
const targets = ['local', 'submission', 'page', 'custom'];
|
|
110
|
+
contract(targets.includes(item.targetType), `${m}.targetType`, 'string', 'ENTRY_TARGET_REQUIRED', { allowedValues: targets });
|
|
111
|
+
if (item.targetType === 'local') {
|
|
112
|
+
strings(entry, p, ['sceneKey']);
|
|
113
|
+
strings(item, m, ['viewKey']);
|
|
114
|
+
const owner = Array.isArray(pages) ? pages.find(page => page?.sceneKey === entry?.sceneKey) : undefined;
|
|
115
|
+
contract(!!owner && item.resource === owner.name, `${m}.resource`, 'string', 'LOCAL_PAGE_BINDING_REQUIRED',
|
|
116
|
+
{ expected: owner?.name || null });
|
|
117
|
+
}
|
|
118
|
+
if (array(item.access, `${m}.access`, true)) {
|
|
119
|
+
item.access.forEach((access, accessIndex) => strings(access, `${m}.access[${accessIndex}]`, ['resource', 'operation', 'dataScope']));
|
|
120
|
+
if (targets.includes(item.targetType)) {
|
|
121
|
+
const operation = item.targetType === 'submission' ? 'OPERATE_CREATE' : 'OPERATE_VIEW';
|
|
122
|
+
contract(item.access.some(access => access?.resource === item.resource && access?.operation === operation
|
|
123
|
+
&& (access.viewUuid || '') === (item.viewUuid || '')), `${m}.access`, 'array', 'ENTRY_ACCESS_REQUIRED',
|
|
124
|
+
{ example: [{ resource: item.resource, operation, dataScope: '' }] });
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
visit(entry.menu, `${p}.menu`);
|
|
129
|
+
}
|
|
89
130
|
});
|
|
90
131
|
}
|
|
91
132
|
}
|
|
@@ -158,10 +199,24 @@ function collectIssues(plan) {
|
|
|
158
199
|
}
|
|
159
200
|
if (/^2(?:\.|$)/.test(String(plan.schemaVersion))) {
|
|
160
201
|
const user = plan.visualStyle?.forUser;
|
|
202
|
+
if (options.authoringContract && user?.assetStrategy !== undefined
|
|
203
|
+
&& contract(object(user.assetStrategy), 'visualStyle.forUser.assetStrategy', 'object', 'EXPECTED_OBJECT')) {
|
|
204
|
+
array(user.assetStrategy.pages, 'visualStyle.forUser.assetStrategy.pages');
|
|
205
|
+
}
|
|
161
206
|
strings(user?.visualDirection, 'visualStyle.forUser.visualDirection', ['label', 'description']);
|
|
162
207
|
check(['top', 'side'].includes(user?.navigationStyle?.structure), 'visualStyle.forUser.navigationStyle.structure', '选择 top 或 side');
|
|
163
208
|
check(['light', 'dark'].includes(user?.navigationStyle?.tone), 'visualStyle.forUser.navigationStyle.tone', '选择 light 或 dark');
|
|
164
|
-
check(/^#[0-9a-f]{6}$/i.test(user?.colorStrategy?.primaryColor || ''), 'visualStyle.forUser.colorStrategy.primaryColor', '填写 6 位 HEX 色值'
|
|
209
|
+
check(/^#[0-9a-f]{6}$/i.test(user?.colorStrategy?.primaryColor || ''), 'visualStyle.forUser.colorStrategy.primaryColor', '填写 6 位 HEX 色值',
|
|
210
|
+
{ code: 'EXPECTED_HEX_COLOR', expectedType: 'string', format: 'hex-color' });
|
|
211
|
+
if (options.authoringContract) {
|
|
212
|
+
const expected = normalizeCssColorToHex(user?.colorStrategy?.primaryColor);
|
|
213
|
+
const actual = normalizeCssColorToHex(plan.visualStyle?.tokens?.['--color-brand1-6']);
|
|
214
|
+
// Resolve literal colors here; variable chains still use the full theme renderer.
|
|
215
|
+
if (expected && actual) {
|
|
216
|
+
contract(expected === actual, 'visualStyle.tokens.--color-brand1-6', 'string', 'PRIMARY_COLOR_MISMATCH',
|
|
217
|
+
{ expected, actual, example: expected, format: 'hex-color' });
|
|
218
|
+
}
|
|
219
|
+
}
|
|
165
220
|
const selected = plan.visualStyle?.internal?.selectedTheme || user?.selectedTheme;
|
|
166
221
|
const themes = loadThemeIndex().themes;
|
|
167
222
|
check(themes.some(theme => theme.themeId === selected?.themeId), 'visualStyle.internal.selectedTheme.themeId', '使用主题索引中的 themeId');
|
|
@@ -179,8 +234,8 @@ function collectIssues(plan) {
|
|
|
179
234
|
return issues;
|
|
180
235
|
}
|
|
181
236
|
|
|
182
|
-
function validateAuthoring(plan) {
|
|
183
|
-
const issues = collectIssues(plan);
|
|
237
|
+
function validateAuthoring(plan, options = {}) {
|
|
238
|
+
const issues = collectIssues(plan, options);
|
|
184
239
|
// Report every gap here: stricter downstream validators would surface it with a different error shape.
|
|
185
240
|
if (issues.length) {
|
|
186
241
|
throw new CliError(`计划有 ${issues.length} 项待补充:\n${issues.map(issue => `${issue.path}: ${issue.message}`).join('\n')}`, {
|
|
@@ -502,7 +502,7 @@ function buildFlashNoteToPrdPrompt(flashNoteContent, options = {}) {
|
|
|
502
502
|
const isSegmented = totalSegments && totalSegments > 1;
|
|
503
503
|
|
|
504
504
|
// ---- 系统角色层 ----
|
|
505
|
-
const systemRole = `你是一名拥有 10
|
|
505
|
+
const systemRole = `你是一名拥有 10 年经验的资深产品经理,同时精通 AI 宜搭。你擅长:
|
|
506
506
|
- 从非结构化的会议讨论中精准提取产品需求
|
|
507
507
|
- 将模糊的口语化描述转化为清晰的功能规格
|
|
508
508
|
- 识别隐含需求和潜在风险
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
// Merge into one Canvas file. Bind verified app/form IDs; retain the business UI.
|
|
4
|
+
// Read-only, one page per request. No credentials, seed data or automatic retries.
|
|
5
|
+
function getCanvasBridge(key, method) {
|
|
6
|
+
let target = window;
|
|
7
|
+
const seen = [];
|
|
8
|
+
while (target && !seen.includes(target)) {
|
|
9
|
+
seen.push(target);
|
|
10
|
+
try {
|
|
11
|
+
if (target !== window && (!window.location.origin || window.location.origin === 'null'
|
|
12
|
+
|| target.location.origin !== window.location.origin)) return null;
|
|
13
|
+
const bridge = target[key];
|
|
14
|
+
if (bridge && typeof bridge[method] === 'function') return bridge;
|
|
15
|
+
const parent = target.parent;
|
|
16
|
+
if (!parent || parent === target) return null;
|
|
17
|
+
target = parent;
|
|
18
|
+
} catch { return null; }
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function canvasDataError(code) {
|
|
24
|
+
const error = new Error(code);
|
|
25
|
+
error.code = code;
|
|
26
|
+
return error;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function normalizeCanvasFormPage(payload, currentPage = 1, pageSize = 50) {
|
|
30
|
+
const queue = [payload], seen = new Set(), arrays = new Set(), counts = new Set();
|
|
31
|
+
while (queue.length) {
|
|
32
|
+
const item = queue.shift();
|
|
33
|
+
if (!item || typeof item !== 'object' || seen.has(item)) continue;
|
|
34
|
+
if (seen.size >= 32) throw canvasDataError('DATA_RESPONSE_TOO_DEEP');
|
|
35
|
+
seen.add(item);
|
|
36
|
+
if (Array.isArray(item)) { arrays.add(item); continue; }
|
|
37
|
+
if (item.success === false) throw canvasDataError('DATA_QUERY_FAILED');
|
|
38
|
+
for (const key of ['totalCount', 'total', 'count']) {
|
|
39
|
+
if (!Object.prototype.hasOwnProperty.call(item, key) || item[key] === null) continue;
|
|
40
|
+
const raw = item[key];
|
|
41
|
+
if (!(typeof raw === 'number' || typeof raw === 'string' && /^\d+$/.test(raw))) {
|
|
42
|
+
throw canvasDataError('DATA_TOTAL_INVALID');
|
|
43
|
+
}
|
|
44
|
+
const count = Number(raw);
|
|
45
|
+
if (!Number.isSafeInteger(count) || count < 0) throw canvasDataError('DATA_TOTAL_INVALID');
|
|
46
|
+
counts.add(count);
|
|
47
|
+
}
|
|
48
|
+
for (const key of ['data', 'list', 'values', 'records', 'result', 'content', 'value']) {
|
|
49
|
+
if (item[key] && typeof item[key] === 'object') queue.push(item[key]);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (arrays.size !== 1 || counts.size > 1) throw canvasDataError('DATA_RESPONSE_UNRECOGNIZED');
|
|
53
|
+
const rows = [...arrays][0];
|
|
54
|
+
if (!rows.every(row => row && typeof row === 'object' && !Array.isArray(row))) {
|
|
55
|
+
throw canvasDataError('DATA_ROWS_INVALID');
|
|
56
|
+
}
|
|
57
|
+
const totalCount = counts.size ? [...counts][0] : null;
|
|
58
|
+
if (totalCount !== null && (rows.length && (currentPage - 1) * pageSize + rows.length > totalCount
|
|
59
|
+
|| totalCount > (currentPage - 1) * pageSize && !rows.length)) {
|
|
60
|
+
throw canvasDataError('DATA_ROWS_MISSING');
|
|
61
|
+
}
|
|
62
|
+
// Preserve raw field values, including zero. Missing totals stay unknown.
|
|
63
|
+
return { rows, totalCount, currentPage, pageSize };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async function queryCanvasFormPage(binding, request = {}) {
|
|
67
|
+
if (!binding || typeof binding !== 'object' || !request || typeof request !== 'object') {
|
|
68
|
+
throw canvasDataError('DATA_BINDING_INVALID');
|
|
69
|
+
}
|
|
70
|
+
const currentPage = request.currentPage === undefined ? 1 : request.currentPage;
|
|
71
|
+
const pageSize = request.pageSize === undefined ? binding.pageSize === undefined ? 50 : binding.pageSize : request.pageSize;
|
|
72
|
+
const query = request.query === undefined ? binding.query === undefined ? [] : binding.query : request.query;
|
|
73
|
+
if (binding.mode !== undefined && binding.mode !== 'form'
|
|
74
|
+
|| !/^APP_[A-Za-z0-9_-]+$/.test(binding.appType || '')
|
|
75
|
+
|| typeof binding.formUuid !== 'string' || !binding.formUuid.trim()
|
|
76
|
+
|| !Number.isSafeInteger(currentPage) || currentPage < 1
|
|
77
|
+
|| !Number.isSafeInteger(pageSize) || pageSize < 1 || pageSize > 100
|
|
78
|
+
|| !query || typeof query !== 'object'
|
|
79
|
+
|| binding.dynamicOrder !== undefined && typeof binding.dynamicOrder !== 'string') {
|
|
80
|
+
throw canvasDataError('DATA_BINDING_INVALID');
|
|
81
|
+
}
|
|
82
|
+
const bridge = getCanvasBridge('__OPENYIDA_YIDA_API__', 'searchFormDatas');
|
|
83
|
+
if (!bridge) throw canvasDataError('DATA_BRIDGE_UNAVAILABLE');
|
|
84
|
+
let payload;
|
|
85
|
+
try {
|
|
86
|
+
payload = await bridge.searchFormDatas({
|
|
87
|
+
appType: binding.appType, formUuid: binding.formUuid, currentPage, pageSize,
|
|
88
|
+
searchFieldJson: JSON.stringify(query), dynamicOrder: binding.dynamicOrder || '',
|
|
89
|
+
});
|
|
90
|
+
} catch { throw canvasDataError('DATA_QUERY_FAILED'); }
|
|
91
|
+
return normalizeCanvasFormPage(payload, currentPage, pageSize);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function useCanvasFormData(binding, request = {}) {
|
|
95
|
+
// Keep binding/request as JSON data. Equal configurations do not refetch on render.
|
|
96
|
+
const key = JSON.stringify({ binding, request });
|
|
97
|
+
const source = React.useRef(null);
|
|
98
|
+
const [revision, setRevision] = React.useState(0);
|
|
99
|
+
const [state, setState] = React.useState({
|
|
100
|
+
rows: [], totalCount: null, loading: true, refreshing: false, error: null, lastUpdatedAt: null,
|
|
101
|
+
});
|
|
102
|
+
React.useEffect(() => {
|
|
103
|
+
let active = true, settled = false;
|
|
104
|
+
const sameSource = source.current === key;
|
|
105
|
+
source.current = key;
|
|
106
|
+
setState(previous => sameSource && previous.lastUpdatedAt !== null
|
|
107
|
+
? { ...previous, loading: false, refreshing: true, error: null }
|
|
108
|
+
: { rows: [], totalCount: null, loading: true, refreshing: false, error: null, lastUpdatedAt: null });
|
|
109
|
+
const timeoutMs = request.timeoutMs === undefined ? 15000 : request.timeoutMs;
|
|
110
|
+
let timer;
|
|
111
|
+
const finish = (data, error) => {
|
|
112
|
+
if (!active || settled) return;
|
|
113
|
+
settled = true;
|
|
114
|
+
clearTimeout(timer);
|
|
115
|
+
setState(previous => error
|
|
116
|
+
? { ...previous, loading: false, refreshing: false, error }
|
|
117
|
+
: { ...data, loading: false, refreshing: false, error: null, lastUpdatedAt: Date.now() });
|
|
118
|
+
};
|
|
119
|
+
if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > 60000) {
|
|
120
|
+
finish(null, canvasDataError('DATA_TIMEOUT_INVALID'));
|
|
121
|
+
} else {
|
|
122
|
+
timer = setTimeout(() => finish(null, canvasDataError('DATA_QUERY_TIMEOUT')), timeoutMs);
|
|
123
|
+
Promise.resolve().then(() => active ? queryCanvasFormPage(binding, request) : null)
|
|
124
|
+
.then(data => finish(data, null), error => finish(null, canvasDataError([
|
|
125
|
+
'DATA_BINDING_INVALID', 'DATA_BRIDGE_UNAVAILABLE', 'DATA_QUERY_FAILED', 'DATA_RESPONSE_TOO_DEEP',
|
|
126
|
+
'DATA_TOTAL_INVALID', 'DATA_RESPONSE_UNRECOGNIZED', 'DATA_ROWS_INVALID', 'DATA_ROWS_MISSING',
|
|
127
|
+
].includes(error && error.code) ? error.code : 'DATA_QUERY_FAILED')));
|
|
128
|
+
}
|
|
129
|
+
// The host bridge has no cancellation contract. Ignore late replies after
|
|
130
|
+
// timeout, configuration changes or unmount; do not claim transport abort.
|
|
131
|
+
return () => { active = false; clearTimeout(timer); };
|
|
132
|
+
}, [key, revision]);
|
|
133
|
+
const refetch = React.useCallback(() => setRevision(value => value + 1), []);
|
|
134
|
+
return { ...state, refetch };
|
|
135
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
// Merge into the business page. value contains confirmed files, never File objects.
|
|
4
|
+
// Use accept="image/*" for pictures; accept only guides the picker.
|
|
5
|
+
// Save AttachmentField and ImageField as file-object arrays, never URL arrays.
|
|
6
|
+
function CanvasFileUpload({ binding, value = [], onChange, onUploadingChange, accept, maxBytes, disabled = false }) {
|
|
7
|
+
const [busy, setBusy] = React.useState(false);
|
|
8
|
+
const [error, setError] = React.useState('');
|
|
9
|
+
const [pending, setPending] = React.useState(null);
|
|
10
|
+
const [api, setApi] = React.useState(() => window.__OPENYIDA_FILE_API__);
|
|
11
|
+
const locked = React.useRef(false);
|
|
12
|
+
const incomplete = React.useRef(false);
|
|
13
|
+
React.useEffect(() => {
|
|
14
|
+
if (api) return;
|
|
15
|
+
const timer = setInterval(() => {
|
|
16
|
+
if (window.__OPENYIDA_FILE_API__) {
|
|
17
|
+
setApi(window.__OPENYIDA_FILE_API__);
|
|
18
|
+
clearInterval(timer);
|
|
19
|
+
}
|
|
20
|
+
}, 200);
|
|
21
|
+
return () => clearInterval(timer);
|
|
22
|
+
}, [api]);
|
|
23
|
+
|
|
24
|
+
async function selectFiles(event) {
|
|
25
|
+
const files = Array.from(event.target.files || []);
|
|
26
|
+
event.target.value = '';
|
|
27
|
+
if (!files.length || locked.current || incomplete.current || disabled) return;
|
|
28
|
+
locked.current = true;
|
|
29
|
+
setBusy(true);
|
|
30
|
+
if (onUploadingChange) onUploadingChange(true);
|
|
31
|
+
setError('');
|
|
32
|
+
const next = value.slice();
|
|
33
|
+
try {
|
|
34
|
+
if (!api) throw new Error('上传服务未就绪,请刷新页面');
|
|
35
|
+
for (const file of files) {
|
|
36
|
+
let uploaded;
|
|
37
|
+
try {
|
|
38
|
+
uploaded = await api.upload(binding, file, { maxBytes });
|
|
39
|
+
} catch (failure) {
|
|
40
|
+
if (!failure.uploadedFile) throw failure;
|
|
41
|
+
// Confirm succeeded: retry only the URL step, not the upload.
|
|
42
|
+
incomplete.current = true;
|
|
43
|
+
setPending(failure.uploadedFile);
|
|
44
|
+
throw failure;
|
|
45
|
+
}
|
|
46
|
+
next.push(uploaded);
|
|
47
|
+
onChange(next.slice());
|
|
48
|
+
}
|
|
49
|
+
} catch (failure) {
|
|
50
|
+
setError(failure.code === 'FILE_LOGIN_REQUIRED' ? '请登录后上传附件或图片' : failure.message);
|
|
51
|
+
} finally {
|
|
52
|
+
locked.current = false;
|
|
53
|
+
setBusy(false);
|
|
54
|
+
if (onUploadingChange) onUploadingChange(incomplete.current);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async function retryDownload() {
|
|
59
|
+
if (!pending || locked.current || disabled) return;
|
|
60
|
+
locked.current = true;
|
|
61
|
+
setBusy(true);
|
|
62
|
+
if (onUploadingChange) onUploadingChange(true);
|
|
63
|
+
try {
|
|
64
|
+
const urls = await api.getDownloadUrl(binding, pending.objectName);
|
|
65
|
+
onChange(value.concat(Object.assign({}, pending, urls)));
|
|
66
|
+
setPending(null);
|
|
67
|
+
incomplete.current = false;
|
|
68
|
+
setError('');
|
|
69
|
+
} catch (failure) {
|
|
70
|
+
setError(failure.message);
|
|
71
|
+
} finally {
|
|
72
|
+
locked.current = false;
|
|
73
|
+
setBusy(false);
|
|
74
|
+
if (onUploadingChange) onUploadingChange(incomplete.current);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return <div aria-busy={busy} style={{ color: 'var(--color-text1-4)' }}>
|
|
79
|
+
<label>选择附件或图片 <input type="file" multiple accept={accept}
|
|
80
|
+
disabled={disabled || busy || !!pending || !api} onChange={selectFiles} /></label>
|
|
81
|
+
{busy && <p role="status">正在上传,请稍候再提交</p>}
|
|
82
|
+
{!api && <p role="alert">上传服务未就绪,请刷新页面</p>}
|
|
83
|
+
{error && <p role="alert">{error}</p>}
|
|
84
|
+
{pending && <p>文件已上传,获取地址失败。
|
|
85
|
+
<button type="button" disabled={disabled || busy} onClick={retryDownload}>重试获取地址</button>
|
|
86
|
+
<button type="button" disabled={disabled || busy} onClick={() => {
|
|
87
|
+
incomplete.current = false;
|
|
88
|
+
setPending(null);
|
|
89
|
+
setError('');
|
|
90
|
+
if (onUploadingChange) onUploadingChange(false);
|
|
91
|
+
}}>移除</button>
|
|
92
|
+
</p>}
|
|
93
|
+
<ul>{value.map((file, index) => <li key={file.objectName}>
|
|
94
|
+
<a href={file.downloadUrl} target="_blank" rel="noopener noreferrer">{file.name}</a>
|
|
95
|
+
{file.previewUrl && <a href={file.previewUrl} target="_blank" rel="noopener noreferrer">预览</a>}
|
|
96
|
+
<button type="button" disabled={disabled || busy}
|
|
97
|
+
onClick={() => onChange(value.filter((_, i) => i !== index))}>移除</button>
|
|
98
|
+
</li>)}</ul>
|
|
99
|
+
</div>;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// After saveFormData/updateFormData/startProcessInstance succeeds, pass the
|
|
103
|
+
// actual returned instance ID. Keep that ID on failure and retry this action only.
|
|
104
|
+
async function bindSavedFiles(binding, savedInstId, files) {
|
|
105
|
+
return window.__OPENYIDA_FILE_API__.bindFiles(binding, savedInstId, files);
|
|
106
|
+
}
|