@yimoka/designable-playground 0.0.0-stage → 0.1.1
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 +8 -2
- package/dist/demo/components/Alert/index.d.ts +4 -0
- package/dist/demo/components/Alert/index.js +41 -0
- package/dist/demo/components/ArrayCards/index.d.ts +17 -0
- package/dist/demo/components/ArrayCards/index.js +62 -0
- package/dist/demo/components/ArrayList/index.d.ts +25 -0
- package/dist/demo/components/ArrayList/index.js +143 -0
- package/dist/demo/components/ArrayTable/index.d.ts +39 -0
- package/dist/demo/components/ArrayTable/index.js +247 -0
- package/dist/demo/components/AutoComplete/index.d.ts +4 -0
- package/dist/demo/components/AutoComplete/index.js +52 -0
- package/dist/demo/components/Avatar/index.d.ts +4 -0
- package/dist/demo/components/Avatar/index.js +34 -0
- package/dist/demo/components/Badge/index.d.ts +4 -0
- package/dist/demo/components/Badge/index.js +35 -0
- package/dist/demo/components/Button/index.d.ts +4 -0
- package/dist/demo/components/Button/index.js +86 -0
- package/dist/demo/components/Card/index.d.ts +4 -0
- package/dist/demo/components/Card/index.js +72 -0
- package/dist/demo/components/Carousel/index.d.ts +4 -0
- package/dist/demo/components/Carousel/index.js +33 -0
- package/dist/demo/components/Cascader/index.d.ts +4 -0
- package/dist/demo/components/Cascader/index.js +60 -0
- package/dist/demo/components/Checkbox/index.d.ts +8 -0
- package/dist/demo/components/Checkbox/index.js +55 -0
- package/dist/demo/components/ColorPicker/index.d.ts +4 -0
- package/dist/demo/components/ColorPicker/index.js +38 -0
- package/dist/demo/components/DatePicker/index.d.ts +4 -0
- package/dist/demo/components/DatePicker/index.js +61 -0
- package/dist/demo/components/DateRangePicker/index.d.ts +4 -0
- package/dist/demo/components/DateRangePicker/index.js +58 -0
- package/dist/demo/components/Divider/index.d.ts +4 -0
- package/dist/demo/components/Divider/index.js +39 -0
- package/dist/demo/components/Empty/index.d.ts +4 -0
- package/dist/demo/components/Empty/index.js +29 -0
- package/dist/demo/components/Flex/index.d.ts +4 -0
- package/dist/demo/components/Flex/index.js +51 -0
- package/dist/demo/components/Form/index.d.ts +21 -0
- package/dist/demo/components/Form/index.js +116 -0
- package/dist/demo/components/FormCollapse/index.d.ts +28 -0
- package/dist/demo/components/FormCollapse/index.js +164 -0
- package/dist/demo/components/FormGrid/index.d.ts +22 -0
- package/dist/demo/components/FormGrid/index.js +134 -0
- package/dist/demo/components/FormItem/index.d.ts +14 -0
- package/dist/demo/components/FormItem/index.js +33 -0
- package/dist/demo/components/FormLayout/index.d.ts +26 -0
- package/dist/demo/components/FormLayout/index.js +260 -0
- package/dist/demo/components/FormTab/index.d.ts +15 -0
- package/dist/demo/components/FormTab/index.js +186 -0
- package/dist/demo/components/GridCol/index.d.ts +4 -0
- package/dist/demo/components/GridCol/index.js +53 -0
- package/dist/demo/components/GridRow/index.d.ts +4 -0
- package/dist/demo/components/GridRow/index.js +70 -0
- package/dist/demo/components/HTMLContent/index.d.ts +4 -0
- package/dist/demo/components/HTMLContent/index.js +34 -0
- package/dist/demo/components/I18nEditor/index.d.ts +8 -0
- package/dist/demo/components/I18nEditor/index.js +64 -0
- package/dist/demo/components/Image/index.d.ts +4 -0
- package/dist/demo/components/Image/index.js +36 -0
- package/dist/demo/components/Input/index.d.ts +4 -0
- package/dist/demo/components/Input/index.js +36 -0
- package/dist/demo/components/InputSearch/index.d.ts +4 -0
- package/dist/demo/components/InputSearch/index.js +40 -0
- package/dist/demo/components/Link/index.d.ts +4 -0
- package/dist/demo/components/Link/index.js +37 -0
- package/dist/demo/components/Mentions/index.d.ts +4 -0
- package/dist/demo/components/Mentions/index.js +41 -0
- package/dist/demo/components/NumberPicker/index.d.ts +6 -0
- package/dist/demo/components/NumberPicker/index.js +63 -0
- package/dist/demo/components/ObjectContainer/index.d.ts +14 -0
- package/dist/demo/components/ObjectContainer/index.js +46 -0
- package/dist/demo/components/Password/index.d.ts +6 -0
- package/dist/demo/components/Password/index.js +44 -0
- package/dist/demo/components/QRCode/index.d.ts +4 -0
- package/dist/demo/components/QRCode/index.js +34 -0
- package/dist/demo/components/Radio/index.d.ts +6 -0
- package/dist/demo/components/Radio/index.js +49 -0
- package/dist/demo/components/Rate/index.d.ts +6 -0
- package/dist/demo/components/Rate/index.js +43 -0
- package/dist/demo/components/Search/index.d.ts +4 -0
- package/dist/demo/components/Search/index.js +42 -0
- package/dist/demo/components/SearchSelect/index.d.ts +4 -0
- package/dist/demo/components/SearchSelect/index.js +53 -0
- package/dist/demo/components/Select/index.d.ts +4 -0
- package/dist/demo/components/Select/index.js +59 -0
- package/dist/demo/components/Slider/index.d.ts +6 -0
- package/dist/demo/components/Slider/index.js +61 -0
- package/dist/demo/components/Space/index.d.ts +9 -0
- package/dist/demo/components/Space/index.js +61 -0
- package/dist/demo/components/Statistic/index.d.ts +4 -0
- package/dist/demo/components/Statistic/index.js +33 -0
- package/dist/demo/components/Switch/index.d.ts +4 -0
- package/dist/demo/components/Switch/index.js +49 -0
- package/dist/demo/components/Tabs/index.d.ts +10 -0
- package/dist/demo/components/Tabs/index.js +181 -0
- package/dist/demo/components/Tag/index.d.ts +4 -0
- package/dist/demo/components/Tag/index.js +33 -0
- package/dist/demo/components/Text/index.d.ts +11 -0
- package/dist/demo/components/Text/index.js +64 -0
- package/dist/demo/components/TextArea/index.d.ts +6 -0
- package/dist/demo/components/TextArea/index.js +43 -0
- package/dist/demo/components/TimePicker/index.d.ts +4 -0
- package/dist/demo/components/TimePicker/index.js +69 -0
- package/dist/demo/components/TimeRangePicker/index.d.ts +4 -0
- package/dist/demo/components/TimeRangePicker/index.js +68 -0
- package/dist/demo/components/Transfer/index.d.ts +6 -0
- package/dist/demo/components/Transfer/index.js +59 -0
- package/dist/demo/components/TreeSelect/index.d.ts +4 -0
- package/dist/demo/components/TreeSelect/index.js +63 -0
- package/dist/demo/components/Upload/index.d.ts +8 -0
- package/dist/demo/components/Upload/index.js +64 -0
- package/dist/demo/components/index.d.ts +55 -0
- package/dist/demo/components/index.js +55 -0
- package/dist/demo/components/shared.d.ts +143 -0
- package/dist/demo/components/shared.js +315 -0
- package/dist/src/Playground.d.ts +3 -0
- package/dist/src/Playground.js +304 -0
- package/dist/src/antd/AntdPlayground.d.ts +16 -0
- package/dist/src/antd/AntdPlayground.js +136 -0
- package/dist/src/antd/index.d.ts +1 -0
- package/dist/src/antd/index.js +1 -0
- package/dist/src/context.d.ts +4 -0
- package/dist/src/context.js +13 -0
- package/dist/src/examples/index.d.ts +267 -0
- package/dist/src/examples/index.js +824 -0
- package/dist/src/hooks/index.d.ts +4 -0
- package/dist/src/hooks/index.js +4 -0
- package/dist/src/hooks/remoteSchemaAdapter.d.ts +53 -0
- package/dist/src/hooks/remoteSchemaAdapter.js +262 -0
- package/dist/src/hooks/usePlayground.d.ts +38 -0
- package/dist/src/hooks/usePlayground.js +642 -0
- package/dist/src/hooks/usePlaygroundRemotePersistence.d.ts +135 -0
- package/dist/src/hooks/usePlaygroundRemotePersistence.js +736 -0
- package/dist/src/hooks/useSchemaEditorDraft.d.ts +4 -0
- package/dist/src/hooks/useSchemaEditorDraft.js +44 -0
- package/dist/src/index.d.ts +14 -0
- package/dist/src/index.js +14 -0
- package/dist/src/layouts/PlaygroundLayout/ErrorBoundaries.d.ts +59 -0
- package/dist/src/layouts/PlaygroundLayout/ErrorBoundaries.js +161 -0
- package/dist/src/layouts/PlaygroundLayout/index.d.ts +7 -0
- package/dist/src/layouts/PlaygroundLayout/index.js +443 -0
- package/dist/src/layouts/index.d.ts +1 -0
- package/dist/src/layouts/index.js +1 -0
- package/dist/src/panels/CompositePanel/index.d.ts +6 -0
- package/dist/src/panels/CompositePanel/index.js +139 -0
- package/dist/src/panels/ToolbarPanel/index.d.ts +3 -0
- package/dist/src/panels/ToolbarPanel/index.js +24 -0
- package/dist/src/panels/index.d.ts +2 -0
- package/dist/src/panels/index.js +2 -0
- package/dist/src/presets/antd.d.ts +19 -0
- package/dist/src/presets/antd.js +112 -0
- package/dist/src/presets/index.d.ts +4 -0
- package/dist/src/presets/index.js +3 -0
- package/dist/src/presets/runtime-array-helpers.d.ts +8 -0
- package/dist/src/presets/runtime-array-helpers.js +147 -0
- package/dist/src/presets/runtime-component-props.d.ts +3 -0
- package/dist/src/presets/runtime-component-props.js +5 -0
- package/dist/src/presets/runtime-components.d.ts +5 -0
- package/dist/src/presets/runtime-components.js +419 -0
- package/dist/src/presets/runtime-form-components.d.ts +9 -0
- package/dist/src/presets/runtime-form-components.js +94 -0
- package/dist/src/presets/scenario-catalog.d.ts +6 -0
- package/dist/src/presets/scenario-catalog.js +128 -0
- package/dist/src/presets/scenarios.d.ts +52 -0
- package/dist/src/presets/scenarios.js +603 -0
- package/dist/src/runtime/actions.d.ts +19 -0
- package/dist/src/runtime/actions.js +307 -0
- package/dist/src/runtime/contracts.d.ts +149 -0
- package/dist/src/runtime/contracts.js +1 -0
- package/dist/src/runtime/document-bindings.d.ts +3 -0
- package/dist/src/runtime/document-bindings.js +101 -0
- package/dist/src/runtime/document-core.d.ts +57 -0
- package/dist/src/runtime/document-core.js +379 -0
- package/dist/src/runtime/document-entity.d.ts +12 -0
- package/dist/src/runtime/document-entity.js +351 -0
- package/dist/src/runtime/document-expressions.d.ts +35 -0
- package/dist/src/runtime/document-expressions.js +346 -0
- package/dist/src/runtime/document-security.d.ts +34 -0
- package/dist/src/runtime/document-security.js +538 -0
- package/dist/src/runtime/document.d.ts +16 -0
- package/dist/src/runtime/document.js +212 -0
- package/dist/src/runtime/environment.d.ts +16 -0
- package/dist/src/runtime/environment.js +76 -0
- package/dist/src/runtime/i18n-schema.d.ts +36 -0
- package/dist/src/runtime/i18n-schema.js +338 -0
- package/dist/src/runtime/i18n.d.ts +25 -0
- package/dist/src/runtime/i18n.js +447 -0
- package/dist/src/runtime/index.d.ts +8 -0
- package/dist/src/runtime/index.js +8 -0
- package/dist/src/runtime/navigation.d.ts +5 -0
- package/dist/src/runtime/navigation.js +43 -0
- package/dist/src/runtime/playground.d.ts +30 -0
- package/dist/src/runtime/playground.js +243 -0
- package/dist/src/runtime/preview-boundaries.d.ts +13 -0
- package/dist/src/runtime/preview-boundaries.js +43 -0
- package/dist/src/runtime/preview.d.ts +44 -0
- package/dist/src/runtime/preview.js +574 -0
- package/dist/src/runtime/settings/RuntimeJsonEditor.d.ts +10 -0
- package/dist/src/runtime/settings/RuntimeJsonEditor.js +21 -0
- package/dist/src/runtime/settings/RuntimeStoreEntitySettings.d.ts +15 -0
- package/dist/src/runtime/settings/RuntimeStoreEntitySettings.js +65 -0
- package/dist/src/runtime/templates.d.ts +1560 -0
- package/dist/src/runtime/templates.js +508 -0
- package/dist/src/runtime/website-contact-template.d.ts +1 -0
- package/dist/src/runtime/website-contact-template.js +66 -0
- package/dist/src/runtime/website-template-shared.d.ts +14 -0
- package/dist/src/runtime/website-template-shared.js +210 -0
- package/dist/src/runtime/website-templates.d.ts +5 -0
- package/dist/src/runtime/website-templates.js +976 -0
- package/dist/src/shared/clipboard.d.ts +4 -0
- package/dist/src/shared/clipboard.js +56 -0
- package/dist/src/shared/componentRegistry.d.ts +133 -0
- package/dist/src/shared/componentRegistry.js +381 -0
- package/dist/src/shared/formilyCompatibility.d.ts +8 -0
- package/dist/src/shared/formilyCompatibility.js +40 -0
- package/dist/src/shared/index.d.ts +6 -0
- package/dist/src/shared/index.js +6 -0
- package/dist/src/shared/productionAcceptance.d.ts +63 -0
- package/dist/src/shared/productionAcceptance.js +201 -0
- package/dist/src/shared/schema-options.d.ts +16 -0
- package/dist/src/shared/schema-options.js +138 -0
- package/dist/src/shared/schema.d.ts +63 -0
- package/dist/src/shared/schema.js +627 -0
- package/dist/src/shared/styleSecurity.d.ts +2 -0
- package/dist/src/shared/styleSecurity.js +35 -0
- package/dist/src/transformers/formily.d.ts +34 -0
- package/dist/src/transformers/formily.js +943 -0
- package/dist/src/transformers/index.d.ts +1 -0
- package/dist/src/transformers/index.js +1 -0
- package/dist/src/types.d.ts +186 -0
- package/dist/src/types.js +1 -0
- package/dist/src/widgets/ActionsWidget/index.d.ts +3 -0
- package/dist/src/widgets/ActionsWidget/index.js +10 -0
- package/dist/src/widgets/ComponentTreeWidget/index.d.ts +3 -0
- package/dist/src/widgets/ComponentTreeWidget/index.js +333 -0
- package/dist/src/widgets/NodeActionsWidget/index.d.ts +2 -0
- package/dist/src/widgets/NodeActionsWidget/index.js +125 -0
- package/dist/src/widgets/OutlineTreeWidget/index.d.ts +3 -0
- package/dist/src/widgets/OutlineTreeWidget/index.js +432 -0
- package/dist/src/widgets/OutlineTreeWidget/shared.d.ts +32 -0
- package/dist/src/widgets/OutlineTreeWidget/shared.js +79 -0
- package/dist/src/widgets/PreviewWidget/index.d.ts +2 -0
- package/dist/src/widgets/PreviewWidget/index.js +1566 -0
- package/dist/src/widgets/ProductionReadinessWidget/index.d.ts +18 -0
- package/dist/src/widgets/ProductionReadinessWidget/index.js +356 -0
- package/dist/src/widgets/RemotePersistenceStatusWidget/index.d.ts +18 -0
- package/dist/src/widgets/RemotePersistenceStatusWidget/index.js +438 -0
- package/dist/src/widgets/RemoteVersionHistoryWidget/index.d.ts +39 -0
- package/dist/src/widgets/RemoteVersionHistoryWidget/index.js +475 -0
- package/dist/src/widgets/ResourceWidget/index.d.ts +3 -0
- package/dist/src/widgets/ResourceWidget/index.js +491 -0
- package/dist/src/widgets/SchemaCodeView/index.d.ts +7 -0
- package/dist/src/widgets/SchemaCodeView/index.js +225 -0
- package/dist/src/widgets/SchemaEditorWidget/index.d.ts +10 -0
- package/dist/src/widgets/SchemaEditorWidget/index.js +484 -0
- package/dist/src/widgets/SettingsPanelWidget/index.d.ts +3 -0
- package/dist/src/widgets/SettingsPanelWidget/index.js +190 -0
- package/dist/src/widgets/StorageActionsWidget/index.d.ts +2 -0
- package/dist/src/widgets/StorageActionsWidget/index.js +284 -0
- package/dist/src/widgets/index.d.ts +13 -0
- package/dist/src/widgets/index.js +13 -0
- package/package.json +100 -4
|
@@ -0,0 +1,508 @@
|
|
|
1
|
+
import { RuntimeDocumentValidationError, validateRuntimeDocument, } from "./document.js";
|
|
2
|
+
import { aboutTemplateDocumentSource, contactTemplateDocumentSource, landingHomeTemplateDocumentV2Source, newsDetailTemplateDocumentSource, newsIndexTemplateDocumentSource, } from "./website-templates.js";
|
|
3
|
+
export class RuntimeTemplateError extends Error {
|
|
4
|
+
code;
|
|
5
|
+
constructor(code, message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = 'RuntimeTemplateError';
|
|
8
|
+
this.code = code;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export const freezeRuntimeData = (value) => {
|
|
12
|
+
if (value && typeof value === 'object') {
|
|
13
|
+
Object.values(value).forEach(freezeRuntimeData);
|
|
14
|
+
if (!Object.isFrozen(value))
|
|
15
|
+
Object.freeze(value);
|
|
16
|
+
}
|
|
17
|
+
return value;
|
|
18
|
+
};
|
|
19
|
+
const LANDING_IMAGE_DATA_URI = [
|
|
20
|
+
'data:image/png;base64,',
|
|
21
|
+
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJ',
|
|
22
|
+
'AAAADUlEQVR42mNk+M/wHwAF/gL+3dVgNwAAAABJRU5ErkJggg==',
|
|
23
|
+
].join('');
|
|
24
|
+
const landingHomeTemplateDocumentV1Source = freezeRuntimeData({
|
|
25
|
+
kind: 'yimoka.designable.runtime-document',
|
|
26
|
+
version: 1,
|
|
27
|
+
metadata: {
|
|
28
|
+
scenarioId: 'website',
|
|
29
|
+
template: {
|
|
30
|
+
id: 'landing-home-classic',
|
|
31
|
+
version: 1,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
schema: {
|
|
35
|
+
type: 'object',
|
|
36
|
+
properties: {
|
|
37
|
+
navigation: {
|
|
38
|
+
type: 'void',
|
|
39
|
+
'x-component': 'Flex',
|
|
40
|
+
'x-component-props': {
|
|
41
|
+
align: 'center',
|
|
42
|
+
gap: 16,
|
|
43
|
+
justify: 'space-between',
|
|
44
|
+
style: {
|
|
45
|
+
padding: '16px 24px',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
properties: {
|
|
49
|
+
brand: {
|
|
50
|
+
type: 'void',
|
|
51
|
+
'x-component': 'Text',
|
|
52
|
+
'x-component-props': {
|
|
53
|
+
children: 'Yimoka Site',
|
|
54
|
+
strong: true,
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
navLinks: {
|
|
58
|
+
type: 'void',
|
|
59
|
+
'x-component': 'Space',
|
|
60
|
+
properties: {
|
|
61
|
+
overview: {
|
|
62
|
+
type: 'void',
|
|
63
|
+
'x-component': 'Link',
|
|
64
|
+
'x-component-props': {
|
|
65
|
+
children: '产品能力',
|
|
66
|
+
href: 'https://example.com/product',
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
cases: {
|
|
70
|
+
type: 'void',
|
|
71
|
+
'x-component': 'Link',
|
|
72
|
+
'x-component-props': {
|
|
73
|
+
children: '客户案例',
|
|
74
|
+
href: 'https://example.com/cases',
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
contact: {
|
|
78
|
+
type: 'void',
|
|
79
|
+
'x-component': 'Button',
|
|
80
|
+
'x-component-props': {
|
|
81
|
+
children: '联系我们',
|
|
82
|
+
href: 'https://example.com/contact',
|
|
83
|
+
type: 'primary',
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
hero: {
|
|
91
|
+
type: 'void',
|
|
92
|
+
'x-component': 'Card',
|
|
93
|
+
'x-component-props': {
|
|
94
|
+
bordered: false,
|
|
95
|
+
style: {
|
|
96
|
+
background: '#f0f5ff',
|
|
97
|
+
margin: '0 24px 24px',
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
properties: {
|
|
101
|
+
heroLayout: {
|
|
102
|
+
type: 'void',
|
|
103
|
+
'x-component': 'GridRow',
|
|
104
|
+
'x-component-props': {
|
|
105
|
+
align: 'middle',
|
|
106
|
+
gutter: 24,
|
|
107
|
+
},
|
|
108
|
+
properties: {
|
|
109
|
+
heroContent: {
|
|
110
|
+
type: 'void',
|
|
111
|
+
'x-component': 'GridCol',
|
|
112
|
+
'x-component-props': {
|
|
113
|
+
span: 15,
|
|
114
|
+
},
|
|
115
|
+
properties: {
|
|
116
|
+
heroStack: {
|
|
117
|
+
type: 'void',
|
|
118
|
+
'x-component': 'Flex',
|
|
119
|
+
'x-component-props': {
|
|
120
|
+
gap: 12,
|
|
121
|
+
vertical: true,
|
|
122
|
+
},
|
|
123
|
+
properties: {
|
|
124
|
+
heroBadge: {
|
|
125
|
+
type: 'void',
|
|
126
|
+
'x-component': 'Tag',
|
|
127
|
+
'x-component-props': {
|
|
128
|
+
children: '低码官网基础模板',
|
|
129
|
+
color: 'blue',
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
heroTitle: {
|
|
133
|
+
type: 'void',
|
|
134
|
+
'x-component': 'Text',
|
|
135
|
+
'x-component-props': {
|
|
136
|
+
children: '用可组合设计能力快速搭建可信官网',
|
|
137
|
+
strong: true,
|
|
138
|
+
style: {
|
|
139
|
+
fontSize: 32,
|
|
140
|
+
lineHeight: 1.3,
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
heroSummary: {
|
|
145
|
+
type: 'void',
|
|
146
|
+
'x-component': 'Text',
|
|
147
|
+
'x-component-props': {
|
|
148
|
+
children: '模板只承载页面结构和安全静态数据,单位、权限、域名与发布由未来宿主负责。',
|
|
149
|
+
type: 'secondary',
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
heroActions: {
|
|
153
|
+
type: 'void',
|
|
154
|
+
'x-component': 'Space',
|
|
155
|
+
properties: {
|
|
156
|
+
primaryAction: {
|
|
157
|
+
type: 'void',
|
|
158
|
+
'x-component': 'Button',
|
|
159
|
+
'x-component-props': {
|
|
160
|
+
children: '立即体验',
|
|
161
|
+
href: 'https://example.com/start',
|
|
162
|
+
size: 'large',
|
|
163
|
+
type: 'primary',
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
secondaryAction: {
|
|
167
|
+
type: 'void',
|
|
168
|
+
'x-component': 'Button',
|
|
169
|
+
'x-component-props': {
|
|
170
|
+
children: '查看文档',
|
|
171
|
+
href: 'https://example.com/docs',
|
|
172
|
+
size: 'large',
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
heroImage: {
|
|
182
|
+
type: 'void',
|
|
183
|
+
'x-component': 'GridCol',
|
|
184
|
+
'x-component-props': {
|
|
185
|
+
span: 9,
|
|
186
|
+
},
|
|
187
|
+
properties: {
|
|
188
|
+
visual: {
|
|
189
|
+
type: 'void',
|
|
190
|
+
'x-component': 'Image',
|
|
191
|
+
'x-component-props': {
|
|
192
|
+
alt: '官网模板无网络占位图',
|
|
193
|
+
preview: false,
|
|
194
|
+
src: LANDING_IMAGE_DATA_URI,
|
|
195
|
+
style: {
|
|
196
|
+
background: '#d6e4ff',
|
|
197
|
+
height: 180,
|
|
198
|
+
objectFit: 'cover',
|
|
199
|
+
width: '100%',
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
features: {
|
|
210
|
+
type: 'void',
|
|
211
|
+
'x-component': 'GridRow',
|
|
212
|
+
'x-component-props': {
|
|
213
|
+
gutter: 16,
|
|
214
|
+
style: {
|
|
215
|
+
padding: '0 24px 24px',
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
properties: {
|
|
219
|
+
featureDesign: {
|
|
220
|
+
type: 'void',
|
|
221
|
+
'x-component': 'GridCol',
|
|
222
|
+
'x-component-props': {
|
|
223
|
+
span: 8,
|
|
224
|
+
},
|
|
225
|
+
properties: {
|
|
226
|
+
card: {
|
|
227
|
+
type: 'void',
|
|
228
|
+
'x-component': 'Card',
|
|
229
|
+
'x-component-props': {
|
|
230
|
+
title: '可视化编排',
|
|
231
|
+
},
|
|
232
|
+
properties: {
|
|
233
|
+
text: {
|
|
234
|
+
type: 'void',
|
|
235
|
+
'x-component': 'Text',
|
|
236
|
+
'x-component-props': {
|
|
237
|
+
children: '官网与表单共用编辑器内核,场景预设决定物料和布局。',
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
featureRuntime: {
|
|
245
|
+
type: 'void',
|
|
246
|
+
'x-component': 'GridCol',
|
|
247
|
+
'x-component-props': {
|
|
248
|
+
span: 8,
|
|
249
|
+
},
|
|
250
|
+
properties: {
|
|
251
|
+
card: {
|
|
252
|
+
type: 'void',
|
|
253
|
+
'x-component': 'Card',
|
|
254
|
+
'x-component-props': {
|
|
255
|
+
title: 'Runtime 注入',
|
|
256
|
+
},
|
|
257
|
+
properties: {
|
|
258
|
+
text: {
|
|
259
|
+
type: 'void',
|
|
260
|
+
'x-component': 'Text',
|
|
261
|
+
'x-component-props': {
|
|
262
|
+
children: '页面 JSON 与 Store、Entity、executor 等宿主能力严格分离。',
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
},
|
|
269
|
+
featureTemplate: {
|
|
270
|
+
type: 'void',
|
|
271
|
+
'x-component': 'GridCol',
|
|
272
|
+
'x-component-props': {
|
|
273
|
+
span: 8,
|
|
274
|
+
},
|
|
275
|
+
properties: {
|
|
276
|
+
card: {
|
|
277
|
+
type: 'void',
|
|
278
|
+
'x-component': 'Card',
|
|
279
|
+
'x-component-props': {
|
|
280
|
+
title: '版本化模板',
|
|
281
|
+
},
|
|
282
|
+
properties: {
|
|
283
|
+
text: {
|
|
284
|
+
type: 'void',
|
|
285
|
+
'x-component': 'Text',
|
|
286
|
+
'x-component-props': {
|
|
287
|
+
children: '模板复制后再编辑,不共享源对象,也不会越过场景边界。',
|
|
288
|
+
},
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
},
|
|
294
|
+
},
|
|
295
|
+
},
|
|
296
|
+
audience: {
|
|
297
|
+
type: 'string',
|
|
298
|
+
title: '关注方向',
|
|
299
|
+
'x-component': 'Select',
|
|
300
|
+
'x-component-props': {
|
|
301
|
+
dataKey: 'dict.status',
|
|
302
|
+
placeholder: '选择关注方向',
|
|
303
|
+
style: {
|
|
304
|
+
margin: '0 24px 24px',
|
|
305
|
+
width: 240,
|
|
306
|
+
},
|
|
307
|
+
},
|
|
308
|
+
},
|
|
309
|
+
callToAction: {
|
|
310
|
+
type: 'void',
|
|
311
|
+
'x-component': 'Card',
|
|
312
|
+
'x-component-props': {
|
|
313
|
+
style: {
|
|
314
|
+
margin: '0 24px 24px',
|
|
315
|
+
textAlign: 'center',
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
properties: {
|
|
319
|
+
title: {
|
|
320
|
+
type: 'void',
|
|
321
|
+
'x-component': 'Text',
|
|
322
|
+
'x-component-props': {
|
|
323
|
+
children: '准备好创建下一页了吗?',
|
|
324
|
+
strong: true,
|
|
325
|
+
},
|
|
326
|
+
},
|
|
327
|
+
action: {
|
|
328
|
+
type: 'void',
|
|
329
|
+
'x-component': 'Button',
|
|
330
|
+
'x-component-props': {
|
|
331
|
+
children: '创建页面',
|
|
332
|
+
href: 'https://example.com/create',
|
|
333
|
+
style: {
|
|
334
|
+
marginLeft: 16,
|
|
335
|
+
},
|
|
336
|
+
type: 'primary',
|
|
337
|
+
},
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
},
|
|
341
|
+
},
|
|
342
|
+
},
|
|
343
|
+
store: {
|
|
344
|
+
type: 'base',
|
|
345
|
+
defaultValues: {
|
|
346
|
+
audience: 'designer',
|
|
347
|
+
},
|
|
348
|
+
dictConfig: [
|
|
349
|
+
{
|
|
350
|
+
field: 'status',
|
|
351
|
+
data: [
|
|
352
|
+
{
|
|
353
|
+
label: '可视化设计',
|
|
354
|
+
value: 'designer',
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
label: 'Runtime 接入',
|
|
358
|
+
value: 'runtime',
|
|
359
|
+
},
|
|
360
|
+
],
|
|
361
|
+
},
|
|
362
|
+
],
|
|
363
|
+
},
|
|
364
|
+
});
|
|
365
|
+
export const runtimeTemplates = freezeRuntimeData([
|
|
366
|
+
{
|
|
367
|
+
category: '官网首页',
|
|
368
|
+
description: '大字号 Hero、产品叙事、编辑式卡片和克制 CTA 组成的现代极简官网首页。',
|
|
369
|
+
document: landingHomeTemplateDocumentV2Source,
|
|
370
|
+
id: 'landing-home',
|
|
371
|
+
scenarioId: 'website',
|
|
372
|
+
title: '官网首页',
|
|
373
|
+
version: 2,
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
category: '官网首页',
|
|
377
|
+
description: '保留原导航、Hero、能力卡片和 CTA 的兼容首页,便于比较与回退。',
|
|
378
|
+
document: landingHomeTemplateDocumentV1Source,
|
|
379
|
+
id: 'landing-home-classic',
|
|
380
|
+
scenarioId: 'website',
|
|
381
|
+
title: '官网首页(经典版)',
|
|
382
|
+
version: 1,
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
category: '内容页面',
|
|
386
|
+
description: '带精选内容、文章卡片和分类入口的新闻与观点列表页。',
|
|
387
|
+
document: newsIndexTemplateDocumentSource,
|
|
388
|
+
id: 'news-index',
|
|
389
|
+
scenarioId: 'website',
|
|
390
|
+
title: '新闻中心',
|
|
391
|
+
version: 1,
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
category: '内容页面',
|
|
395
|
+
description: '带文章元信息、正文层级、引用和延伸阅读的沉浸式新闻详情页。',
|
|
396
|
+
document: newsDetailTemplateDocumentSource,
|
|
397
|
+
id: 'news-detail',
|
|
398
|
+
scenarioId: 'website',
|
|
399
|
+
title: '新闻详情',
|
|
400
|
+
version: 1,
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
category: '品牌页面',
|
|
404
|
+
description: '呈现品牌故事、价值观、方法和团队数据的关于页面。',
|
|
405
|
+
document: aboutTemplateDocumentSource,
|
|
406
|
+
id: 'about',
|
|
407
|
+
scenarioId: 'website',
|
|
408
|
+
title: '关于我们',
|
|
409
|
+
version: 1,
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
category: '品牌页面',
|
|
413
|
+
description: '结合联系信息、需求表单和响应承诺的联系页面。',
|
|
414
|
+
document: contactTemplateDocumentSource,
|
|
415
|
+
id: 'contact',
|
|
416
|
+
scenarioId: 'website',
|
|
417
|
+
title: '联系我们',
|
|
418
|
+
version: 1,
|
|
419
|
+
},
|
|
420
|
+
]);
|
|
421
|
+
const getBundledRuntimeTemplateDocument = (templateId) => {
|
|
422
|
+
const template = runtimeTemplates.find(item => item.id === templateId);
|
|
423
|
+
if (!template) {
|
|
424
|
+
throw new Error(`内置 Runtime 模板不存在:${templateId}`);
|
|
425
|
+
}
|
|
426
|
+
return template.document;
|
|
427
|
+
};
|
|
428
|
+
export const landingHomeTemplateDocument = getBundledRuntimeTemplateDocument('landing-home');
|
|
429
|
+
export const newsIndexTemplateDocument = getBundledRuntimeTemplateDocument('news-index');
|
|
430
|
+
export const newsDetailTemplateDocument = getBundledRuntimeTemplateDocument('news-detail');
|
|
431
|
+
export const aboutTemplateDocument = getBundledRuntimeTemplateDocument('about');
|
|
432
|
+
export const contactTemplateDocument = getBundledRuntimeTemplateDocument('contact');
|
|
433
|
+
const failRuntimeTemplate = (code, message, onError) => {
|
|
434
|
+
const error = new RuntimeTemplateError(code, message);
|
|
435
|
+
onError?.(error);
|
|
436
|
+
return {
|
|
437
|
+
applied: false,
|
|
438
|
+
error,
|
|
439
|
+
};
|
|
440
|
+
};
|
|
441
|
+
export const findRuntimeTemplate = (templateId, templates = []) => (runtimeTemplates.find(template => template.id === templateId)
|
|
442
|
+
?? templates.find(template => template.id === templateId));
|
|
443
|
+
const shouldCancelRuntimeTemplateApply = async (dirty, confirm, template) => {
|
|
444
|
+
if (!dirty)
|
|
445
|
+
return false;
|
|
446
|
+
if (!confirm)
|
|
447
|
+
return true;
|
|
448
|
+
return !await confirm(template);
|
|
449
|
+
};
|
|
450
|
+
export const applyRuntimeTemplate = async ({ confirm, currentDocument, dirty, getCurrentDocument, onError, scenarioId, templateId, templates, version, }) => {
|
|
451
|
+
const openingDocumentSnapshot = JSON.stringify(currentDocument);
|
|
452
|
+
const template = findRuntimeTemplate(templateId, templates);
|
|
453
|
+
if (!template) {
|
|
454
|
+
return failRuntimeTemplate('template-not-found', `未找到模板 ${templateId}`, onError);
|
|
455
|
+
}
|
|
456
|
+
if (template.version !== version) {
|
|
457
|
+
return failRuntimeTemplate('template-version-unsupported', `模板 ${templateId} 不支持版本 ${version}`, onError);
|
|
458
|
+
}
|
|
459
|
+
if (template.scenarioId !== scenarioId) {
|
|
460
|
+
return failRuntimeTemplate('template-scenario-mismatch', `模板 ${templateId} 属于 ${template.scenarioId} 场景,不能用于 ${scenarioId}`, onError);
|
|
461
|
+
}
|
|
462
|
+
const validation = validateRuntimeDocument(template.document);
|
|
463
|
+
if (!validation.valid || !validation.document) {
|
|
464
|
+
const error = new RuntimeDocumentValidationError(validation.issues);
|
|
465
|
+
onError?.(error);
|
|
466
|
+
return {
|
|
467
|
+
applied: false,
|
|
468
|
+
error,
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
if (validation.document.metadata?.scenarioId
|
|
472
|
+
&& validation.document.metadata.scenarioId !== scenarioId) {
|
|
473
|
+
return failRuntimeTemplate('template-scenario-mismatch', `模板文档属于 ${validation.document.metadata.scenarioId} 场景,不能用于 ${scenarioId}`, onError);
|
|
474
|
+
}
|
|
475
|
+
const documentTemplate = validation.document.metadata?.template;
|
|
476
|
+
if (documentTemplate
|
|
477
|
+
&& (documentTemplate.id !== template.id
|
|
478
|
+
|| documentTemplate.version !== template.version)) {
|
|
479
|
+
return failRuntimeTemplate('template-metadata-mismatch', `模板描述符 ${template.id}@${template.version} 与文档来源 ${documentTemplate.id}@${documentTemplate.version} 不一致`, onError);
|
|
480
|
+
}
|
|
481
|
+
if (await shouldCancelRuntimeTemplateApply(dirty, confirm, template)) {
|
|
482
|
+
return {
|
|
483
|
+
applied: false,
|
|
484
|
+
reason: 'cancelled',
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
if (JSON.stringify(getCurrentDocument?.() ?? currentDocument)
|
|
488
|
+
!== openingDocumentSnapshot) {
|
|
489
|
+
return {
|
|
490
|
+
applied: false,
|
|
491
|
+
reason: 'document-changed',
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
const copied = validateRuntimeDocument(template.document);
|
|
495
|
+
if (!copied.valid || !copied.document) {
|
|
496
|
+
const error = new RuntimeDocumentValidationError(copied.issues);
|
|
497
|
+
onError?.(error);
|
|
498
|
+
return {
|
|
499
|
+
applied: false,
|
|
500
|
+
error,
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
return {
|
|
504
|
+
applied: true,
|
|
505
|
+
document: copied.document,
|
|
506
|
+
template,
|
|
507
|
+
};
|
|
508
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const contactTemplateDocumentSource: import("./contracts").RuntimeDocumentV1;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { ACCENT, createWebsiteDocument, createWebsiteFooter, createWebsiteNavigation, INK, MUTED, PAGE_BACKGROUND, } from "./website-template-shared.js";
|
|
2
|
+
export const contactTemplateDocumentSource = createWebsiteDocument('contact', 1, {
|
|
3
|
+
navigation: createWebsiteNavigation(),
|
|
4
|
+
hero: {
|
|
5
|
+
type: 'void',
|
|
6
|
+
'x-component': 'Card',
|
|
7
|
+
'x-component-props': { bordered: false, style: { background: PAGE_BACKGROUND, padding: '38px 12px 22px' } },
|
|
8
|
+
properties: {
|
|
9
|
+
eyebrow: { type: 'void', 'x-component': 'Tag', 'x-component-props': { children: 'CONTACT / 联系', color: 'lime' } },
|
|
10
|
+
title: { type: 'void', 'x-component': 'Text', 'x-component-props': { children: '一起把下一件事\n做得更清晰', strong: true, style: { color: INK, display: 'block', fontSize: 48, letterSpacing: -1.8, lineHeight: 1.12, margin: '20px 0 16px', whiteSpace: 'pre-line' } } },
|
|
11
|
+
summary: { type: 'void', 'x-component': 'Text', 'x-component-props': { children: '告诉我们目标、时间与当前挑战,我们会在两个工作日内回复。', style: { color: MUTED, fontSize: 18 } } },
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
contact: {
|
|
15
|
+
type: 'void',
|
|
16
|
+
'x-component': 'GridRow',
|
|
17
|
+
'x-component-props': {
|
|
18
|
+
gutter: 18,
|
|
19
|
+
style: { background: PAGE_BACKGROUND, marginInline: 0, padding: '0 24px 32px' },
|
|
20
|
+
},
|
|
21
|
+
properties: {
|
|
22
|
+
details: {
|
|
23
|
+
type: 'void',
|
|
24
|
+
'x-component': 'GridCol',
|
|
25
|
+
'x-component-props': { md: 9, span: 9, xs: 24 },
|
|
26
|
+
properties: {
|
|
27
|
+
card: {
|
|
28
|
+
type: 'void',
|
|
29
|
+
'x-component': 'Card',
|
|
30
|
+
'x-component-props': { bordered: false, style: { background: INK, borderRadius: 20, minHeight: 360 } },
|
|
31
|
+
properties: {
|
|
32
|
+
label: { type: 'void', 'x-component': 'Text', 'x-component-props': { children: '直接联系', strong: true, style: { color: '#ffffff', display: 'block', fontSize: 13, letterSpacing: 1, marginBottom: 70 } } },
|
|
33
|
+
email: { type: 'void', 'x-component': 'Link', 'x-component-props': { children: 'hello@yimoka.cn', href: 'mailto:hello@yimoka.cn', strong: true, style: { color: ACCENT, display: 'block', fontSize: 22, marginBottom: 18 } } },
|
|
34
|
+
address: { type: 'void', 'x-component': 'Text', 'x-component-props': { children: '上海 · 杭州 · 远程协作', style: { color: '#c9ccd3', display: 'block', lineHeight: 1.8, marginBottom: 80 } } },
|
|
35
|
+
qrcode: { type: 'void', 'x-component': 'QRCode', 'x-component-props': { bgColor: '#ffffff', color: INK, size: 96, value: 'https://yimoka.cn/contact' } },
|
|
36
|
+
note: { type: 'void', 'x-component': 'Text', 'x-component-props': { children: '适合:品牌升级、数字产品、设计系统与低代码体验。', style: { color: '#8f939d', lineHeight: 1.8 } } },
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
form: {
|
|
42
|
+
type: 'void',
|
|
43
|
+
'x-component': 'GridCol',
|
|
44
|
+
'x-component-props': { md: 15, span: 15, xs: 24 },
|
|
45
|
+
properties: {
|
|
46
|
+
card: {
|
|
47
|
+
type: 'void',
|
|
48
|
+
'x-component': 'Card',
|
|
49
|
+
'x-component-props': { bordered: false, style: { background: '#ffffff', border: '1px solid #e3e4de', borderRadius: 20 } },
|
|
50
|
+
properties: {
|
|
51
|
+
title: { type: 'void', 'x-component': 'Text', 'x-component-props': { children: '项目简报', strong: true, style: { display: 'block', fontSize: 28, marginBottom: 24 } } },
|
|
52
|
+
nameLabel: { type: 'void', 'x-component': 'Text', 'x-component-props': { children: '怎么称呼你?', strong: true, style: { display: 'block', marginBottom: 8 } } },
|
|
53
|
+
name: { type: 'string', 'x-component': 'Input', 'x-component-props': { placeholder: '姓名 / 团队', size: 'large', style: { marginBottom: 20 } } },
|
|
54
|
+
typeLabel: { type: 'void', 'x-component': 'Text', 'x-component-props': { children: '希望一起解决什么?', strong: true, style: { display: 'block', marginBottom: 8 } } },
|
|
55
|
+
type: { type: 'string', 'x-component': 'Select', 'x-component-props': { options: [{ label: '品牌与官网', value: 'brand' }, { label: '数字产品', value: 'product' }, { label: '设计系统', value: 'system' }], placeholder: '选择项目类型', size: 'large', style: { marginBottom: 20, width: '100%' } } },
|
|
56
|
+
emailLabel: { type: 'void', 'x-component': 'Text', 'x-component-props': { children: '你的工作邮箱', strong: true, style: { display: 'block', marginBottom: 8 } } },
|
|
57
|
+
email: { type: 'string', 'x-component': 'Input', 'x-component-props': { placeholder: 'name@company.com', size: 'large', style: { marginBottom: 24 } } },
|
|
58
|
+
submit: { type: 'void', 'x-component': 'Button', 'x-component-props': { block: true, children: '发送项目简报', size: 'large', style: { background: ACCENT, borderColor: ACCENT, borderRadius: 999, color: INK } } },
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
footer: createWebsiteFooter(),
|
|
66
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IFormilySchemaNode } from "../transformers/index.js";
|
|
2
|
+
import type { RuntimeDocumentV1 } from "./contracts.js";
|
|
3
|
+
type WebsiteProperties = Record<string, IFormilySchemaNode>;
|
|
4
|
+
export declare const PAGE_BACKGROUND = "#f5f5f0";
|
|
5
|
+
export declare const INK = "#111318";
|
|
6
|
+
export declare const MUTED = "#62666f";
|
|
7
|
+
export declare const ACCENT = "#b7f34a";
|
|
8
|
+
export declare const VIOLET = "#7768ff";
|
|
9
|
+
export declare const STUDIO_IMAGE_DATA_URI: string;
|
|
10
|
+
export declare const createWebsiteDocument: (templateId: string, templateVersion: number, properties: WebsiteProperties) => RuntimeDocumentV1;
|
|
11
|
+
export declare const createWebsiteNavigation: () => IFormilySchemaNode;
|
|
12
|
+
export declare const createWebsiteFooter: () => IFormilySchemaNode;
|
|
13
|
+
export declare const createNewsCard: (category: string, date: string, title: string, summary: string) => IFormilySchemaNode;
|
|
14
|
+
export {};
|