Skip to content

Commit ffaa276

Browse files
authored
feat: refactor parse attribute value (#149)
* refactor: update attribute value parsing logic * fix: refactor toggle setter logic * fix: enhance basic setters * fix: move basic value setter to setting-form package * fix: add setter type * fix: update * feat: support toggle formObject to codeSetter * fix: update invalid setter notice * fix: update node2value * fix: trigger onChange for formObject * docs: update * chore: up * feat: improve code2value function and fix related issues * Revert "chore: up" This reverts commit a87d8fc. * chore: update npm dependencies to latest versions
1 parent 56d0877 commit ffaa276

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2189
-1289
lines changed

apps/playground/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
"@music163/antd": "^0.2.4",
1616
"antd": "^4.24.2",
1717
"coral-system": "^1.0.5",
18-
"umi": "^4.0.89"
18+
"umi": "^4.2.3"
1919
}
2020
}

apps/playground/src/helpers/mock-files.ts

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const packageJson = {
22
name: 'demo',
33
private: true,
44
dependencies: {
5-
'@music163/antd': '0.2.2',
5+
'@music163/antd': '0.2.5',
66
'@music163/tango-boot': '0.2.5',
77
react: '17.0.2',
88
'react-dom': '17.0.2',
@@ -56,11 +56,12 @@ const tangoConfigJson = {
5656
},
5757
'@music163/antd': {
5858
description: '云音乐低代码中后台应用基础物料',
59-
version: '0.2.2',
59+
version: '0.2.5',
6060
library: 'TangoAntd',
6161
type: 'baseDependency',
6262
resources: [
6363
'https://unpkg.com/@music163/antd@{{version}}/dist/index.js',
64+
// 'http://localhost:9002/designer.js',
6465
'https://unpkg.com/[email protected]/dist/antd.css',
6566
],
6667
designerResources: [
@@ -85,13 +86,19 @@ export function registerComponentPrototype(proto) {
8586

8687
const routesCode = `
8788
import Index from "./pages/list";
89+
import Detail from "./pages/detail";
8890
8991
const routes = [
9092
{
9193
path: '/',
9294
exact: true,
9395
component: Index
9496
},
97+
{
98+
path: '/detail',
99+
exact: true,
100+
component: Detail
101+
},
95102
];
96103
97104
export default routes;
@@ -150,16 +157,25 @@ import {
150157
Input,
151158
FormilyForm,
152159
FormilyFormItem,
160+
Table,
153161
} from "@music163/antd";
154162
import { Space } from "@music163/antd";
155163
import { LocalButton } from "../components";
156164
class App extends React.Component {
157165
render() {
158166
return (
159-
<Page title={tango.stores.app.title}>
167+
<Page title={tango.stores.app.title} subTitle={111}>
160168
<Section tid="section1" title="Section Title">
161169
your input: <Input tid="input1" defaultValue="hello" />
162170
copy input: <Input value={tango.page.input1?.value} />
171+
<Table
172+
columns={[
173+
{ title: "姓名", dataIndex: "name", key: "name" },
174+
{ title: "年龄", dataIndex: "age", key: "age" },
175+
{ title: "住址", dataIndex: "address", key: "address" },
176+
]}
177+
tid="table1"
178+
/>
163179
</Section>
164180
<Section tid="section2">
165181
<Space tid="space1">
@@ -174,6 +190,9 @@ class App extends React.Component {
174190
</FormilyForm>
175191
</Section>
176192
<Section title="原生 DOM" tid="section4">
193+
<h1 style={{ ...{ color: "red" }, fontSize: 64 }}>
194+
hello world
195+
</h1>
177196
<div
178197
style={{
179198
border: "1px solid #ccc",
@@ -234,6 +253,23 @@ class App extends React.Component {
234253
export default definePage(App);
235254
`;
236255

256+
export const emptyPageCode = `
257+
import React from "react";
258+
import { definePage } from "@music163/tango-boot";
259+
import {
260+
Page,
261+
Section,
262+
} from "@music163/antd";
263+
264+
function App() {
265+
return (<Page title="Detail Page">
266+
<Section></Section>
267+
</Page>)
268+
}
269+
270+
export default definePage(App);
271+
`;
272+
237273
const componentsButtonCode = `
238274
import React from 'react';
239275
import { registerComponentPrototype } from '../utils';
@@ -373,6 +409,7 @@ export const sampleFiles = [
373409
{ filename: '/src/style.css', code: cssCode },
374410
{ filename: '/src/index.js', code: entryCode },
375411
{ filename: '/src/pages/list.js', code: viewHomeCode },
412+
{ filename: '/src/pages/detail.js', code: emptyPageCode },
376413
{ filename: '/src/components/button.js', code: componentsButtonCode },
377414
{ filename: '/src/components/input.js', code: componentsInputCode },
378415
{ filename: '/src/components/index.js', code: componentsEntryCode },

apps/playground/src/layouts/index.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
import React, { StrictMode } from 'react';
1+
import React from 'react';
22
import { Outlet } from 'umi';
33
import './index.less';
44

55
export default function Layout() {
6-
return (
7-
<StrictMode>
8-
<Outlet />
9-
</StrictMode>
10-
);
6+
return <Outlet />;
117
}

apps/playground/src/pages/index.tsx

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Box } from 'coral-system';
2-
import { Button, Space } from 'antd';
2+
import { Button, Form, Input, Modal, Space } from 'antd';
33
import {
44
Designer,
55
DesignerPanel,
@@ -15,15 +15,18 @@ import {
1515
} from '@music163/tango-designer';
1616
import { createEngine, Workspace } from '@music163/tango-core';
1717
import prototypes from '../helpers/prototypes';
18-
import { Logo, ProjectDetail, bootHelperVariables, sampleFiles } from '../helpers';
18+
import { Logo, ProjectDetail, bootHelperVariables, emptyPageCode, sampleFiles } from '../helpers';
1919
import {
2020
ApiOutlined,
2121
AppstoreAddOutlined,
2222
BuildOutlined,
2323
ClusterOutlined,
2424
FunctionOutlined,
25+
PlusOutlined,
2526
createFromIconfontCN,
2627
} from '@ant-design/icons';
28+
import { Action } from '@music163/tango-ui';
29+
import { useState } from 'react';
2730

2831
// 1. 实例化工作区
2932
const workspace = new Workspace({
@@ -80,13 +83,19 @@ const menuData = {
8083
title: 'Formily表单',
8184
items: ['FormilyForm', 'FormilyFormItem', 'FormilySubmit', 'FormilyReset'],
8285
},
86+
{
87+
title: '数据展示',
88+
items: ['Comment'],
89+
},
8390
],
8491
};
8592

8693
/**
8794
* 5. 平台初始化,访问 https://local.netease.com:6006/
8895
*/
8996
export default function App() {
97+
const [showNewPageModal, setShowNewPageModal] = useState(false);
98+
const [form] = Form.useForm();
9099
return (
91100
<Designer
92101
theme={themeLight}
@@ -104,6 +113,14 @@ export default function App() {
104113
<Box px="l">
105114
<Toolbar>
106115
<Toolbar.Item key="routeSwitch" placement="left" />
116+
<Toolbar.Item key="addPage" placement="left">
117+
<Action
118+
tooltip="添加页面"
119+
shape="outline"
120+
icon={<PlusOutlined />}
121+
onClick={() => setShowNewPageModal(true)}
122+
/>
123+
</Toolbar.Item>
107124
<Toolbar.Item key="history" placement="left" />
108125
<Toolbar.Item key="preview" placement="left" />
109126
<Toolbar.Item key="modeSwitch" placement="right" />
@@ -115,6 +132,30 @@ export default function App() {
115132
</Space>
116133
</Toolbar.Item>
117134
</Toolbar>
135+
<Modal
136+
title="添加新页面"
137+
open={showNewPageModal}
138+
onCancel={() => setShowNewPageModal(false)}
139+
footer={null}
140+
>
141+
<Form
142+
form={form}
143+
onFinish={(values) => {
144+
workspace.addViewFile(values.name, emptyPageCode);
145+
setShowNewPageModal(false);
146+
}}
147+
layout="vertical"
148+
>
149+
<Form.Item label="文件名" name="name" required rules={[{ required: true }]}>
150+
<Input placeholder="请输入文件名" />
151+
</Form.Item>
152+
<Form.Item>
153+
<Button type="primary" htmlType="submit">
154+
提交
155+
</Button>
156+
</Form.Item>
157+
</Form>
158+
</Modal>
118159
</Box>
119160
}
120161
>

apps/storybook/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"dependencies": {
1717
"@music163/tango-setting-form": "*",
1818
"@music163/tango-ui": "*",
19-
"mobx": "6.12.0",
20-
"mobx-react-lite": "4.0.5"
19+
"mobx": "6.12.3",
20+
"mobx-react-lite": "4.0.7"
2121
},
2222
"devDependencies": {
2323
"@ant-design/icons": "^4.8.0",

0 commit comments

Comments
 (0)