Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: update attribute value parsing logic #149

Merged
merged 15 commits into from
May 16, 2024
Merged
2 changes: 1 addition & 1 deletion apps/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
"@music163/antd": "^0.2.4",
"antd": "^4.24.2",
"coral-system": "^1.0.5",
"umi": "^4.0.89"
"umi": "^4.2.3"
}
}
43 changes: 40 additions & 3 deletions apps/playground/src/helpers/mock-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const packageJson = {
name: 'demo',
private: true,
dependencies: {
'@music163/antd': '0.2.2',
'@music163/antd': '0.2.5',
'@music163/tango-boot': '0.2.5',
react: '17.0.2',
'react-dom': '17.0.2',
Expand Down Expand Up @@ -56,11 +56,12 @@ const tangoConfigJson = {
},
'@music163/antd': {
description: '云音乐低代码中后台应用基础物料',
version: '0.2.2',
version: '0.2.5',
library: 'TangoAntd',
type: 'baseDependency',
resources: [
'https://unpkg.com/@music163/antd@{{version}}/dist/index.js',
// 'http://localhost:9002/designer.js',
'https://unpkg.com/antd@4.24.13/dist/antd.css',
],
designerResources: [
Expand All @@ -85,13 +86,19 @@ export function registerComponentPrototype(proto) {

const routesCode = `
import Index from "./pages/list";
import Detail from "./pages/detail";

const routes = [
{
path: '/',
exact: true,
component: Index
},
{
path: '/detail',
exact: true,
component: Detail
},
];

export default routes;
Expand Down Expand Up @@ -150,16 +157,25 @@ import {
Input,
FormilyForm,
FormilyFormItem,
Table,
} from "@music163/antd";
import { Space } from "@music163/antd";
import { LocalButton } from "../components";
class App extends React.Component {
render() {
return (
<Page title={tango.stores.app.title}>
<Page title={tango.stores.app.title} subTitle={111}>
<Section tid="section1" title="Section Title">
your input: <Input tid="input1" defaultValue="hello" />
copy input: <Input value={tango.page.input1?.value} />
<Table
columns={[
{ title: "姓名", dataIndex: "name", key: "name" },
{ title: "年龄", dataIndex: "age", key: "age" },
{ title: "住址", dataIndex: "address", key: "address" },
]}
tid="table1"
/>
</Section>
<Section tid="section2">
<Space tid="space1">
Expand All @@ -174,6 +190,9 @@ class App extends React.Component {
</FormilyForm>
</Section>
<Section title="原生 DOM" tid="section4">
<h1 style={{ ...{ color: "red" }, fontSize: 64 }}>
hello world
</h1>
<div
style={{
border: "1px solid #ccc",
Expand Down Expand Up @@ -234,6 +253,23 @@ class App extends React.Component {
export default definePage(App);
`;

export const emptyPageCode = `
import React from "react";
import { definePage } from "@music163/tango-boot";
import {
Page,
Section,
} from "@music163/antd";

function App() {
return (<Page title="Detail Page">
<Section></Section>
</Page>)
}

export default definePage(App);
`;

const componentsButtonCode = `
import React from 'react';
import { registerComponentPrototype } from '../utils';
Expand Down Expand Up @@ -373,6 +409,7 @@ export const sampleFiles = [
{ filename: '/src/style.css', code: cssCode },
{ filename: '/src/index.js', code: entryCode },
{ filename: '/src/pages/list.js', code: viewHomeCode },
{ filename: '/src/pages/detail.js', code: emptyPageCode },
{ filename: '/src/components/button.js', code: componentsButtonCode },
{ filename: '/src/components/input.js', code: componentsInputCode },
{ filename: '/src/components/index.js', code: componentsEntryCode },
Expand Down
8 changes: 2 additions & 6 deletions apps/playground/src/layouts/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import React, { StrictMode } from 'react';
import React from 'react';
import { Outlet } from 'umi';
import './index.less';

export default function Layout() {
return (
<StrictMode>
<Outlet />
</StrictMode>
);
return <Outlet />;
}
45 changes: 43 additions & 2 deletions apps/playground/src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Box } from 'coral-system';
import { Button, Space } from 'antd';
import { Button, Form, Input, Modal, Space } from 'antd';
import {
Designer,
DesignerPanel,
Expand All @@ -15,15 +15,18 @@ import {
} from '@music163/tango-designer';
import { createEngine, Workspace } from '@music163/tango-core';
import prototypes from '../helpers/prototypes';
import { Logo, ProjectDetail, bootHelperVariables, sampleFiles } from '../helpers';
import { Logo, ProjectDetail, bootHelperVariables, emptyPageCode, sampleFiles } from '../helpers';
import {
ApiOutlined,
AppstoreAddOutlined,
BuildOutlined,
ClusterOutlined,
FunctionOutlined,
PlusOutlined,
createFromIconfontCN,
} from '@ant-design/icons';
import { Action } from '@music163/tango-ui';
import { useState } from 'react';

// 1. 实例化工作区
const workspace = new Workspace({
Expand Down Expand Up @@ -80,13 +83,19 @@ const menuData = {
title: 'Formily表单',
items: ['FormilyForm', 'FormilyFormItem', 'FormilySubmit', 'FormilyReset'],
},
{
title: '数据展示',
items: ['Comment'],
},
],
};

/**
* 5. 平台初始化,访问 https://local.netease.com:6006/
*/
export default function App() {
const [showNewPageModal, setShowNewPageModal] = useState(false);
const [form] = Form.useForm();
return (
<Designer
theme={themeLight}
Expand All @@ -104,6 +113,14 @@ export default function App() {
<Box px="l">
<Toolbar>
<Toolbar.Item key="routeSwitch" placement="left" />
<Toolbar.Item key="addPage" placement="left">
<Action
tooltip="添加页面"
shape="outline"
icon={<PlusOutlined />}
onClick={() => setShowNewPageModal(true)}
/>
</Toolbar.Item>
<Toolbar.Item key="history" placement="left" />
<Toolbar.Item key="preview" placement="left" />
<Toolbar.Item key="modeSwitch" placement="right" />
Expand All @@ -115,6 +132,30 @@ export default function App() {
</Space>
</Toolbar.Item>
</Toolbar>
<Modal
title="添加新页面"
open={showNewPageModal}
onCancel={() => setShowNewPageModal(false)}
footer={null}
>
<Form
form={form}
onFinish={(values) => {
workspace.addViewFile(values.name, emptyPageCode);
setShowNewPageModal(false);
}}
layout="vertical"
>
<Form.Item label="文件名" name="name" required rules={[{ required: true }]}>
<Input placeholder="请输入文件名" />
</Form.Item>
<Form.Item>
<Button type="primary" htmlType="submit">
提交
</Button>
</Form.Item>
</Form>
</Modal>
</Box>
}
>
Expand Down
4 changes: 2 additions & 2 deletions apps/storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"dependencies": {
"@music163/tango-setting-form": "*",
"@music163/tango-ui": "*",
"mobx": "6.12.0",
"mobx-react-lite": "4.0.5"
"mobx": "6.12.3",
"mobx-react-lite": "4.0.7"
},
"devDependencies": {
"@ant-design/icons": "^4.8.0",
Expand Down
Loading
Loading