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

fix: block add modal bug #3332

Merged
merged 2 commits into from
Sep 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,6 @@ const Adder: React.FC<AdderProps> = props => {
const [fromCheck, setFromCheck] = useState<boolean>(false);

const [form] = Form.useForm();
// const [npmClients, setNpmClients] = useState<string[]>(['npm']);
useEffect(() => {
if (api.detectNpmClients) {
api.detectNpmClients().then(clients => {
form.setFieldsValue({
npmClient: clients[0],
});
});
}
}, []);

// 展示哪个界面
// log 日志 form 表单
Expand All @@ -103,6 +93,21 @@ const Adder: React.FC<AdderProps> = props => {
},
);

useEffect(
() => {
if (api.detectNpmClients) {
api.detectNpmClients().then(clients => {
form.setFieldsValue({
npmClient: clients.find(c => {
return npmClients.includes(c);
}),
});
});
}
},
[npmClients],
);

useEffect(() => {
/**
* 成功之后清理状态
Expand Down Expand Up @@ -290,12 +295,14 @@ const Adder: React.FC<AdderProps> = props => {
<AddBlockFormForUI form={form} blockTarget={blockTarget} />
)}

<Form.Item name="js" label="编译为 JS" valuePropName="checked">
<Switch />
</Form.Item>
<Form.Item name="uni18n" label="移除国际化" valuePropName="checked">
<Form.Item name="js" label="编译为 JS" valuePropName="checked" style={{ display: 'none' }}>
<Switch />
</Form.Item>
{blockType === 'template' && (
<Form.Item name="uni18n" label="移除国际化" valuePropName="checked">
<Switch />
</Form.Item>
)}
<Form.Item name="npmClient" label="包管理器">
<Select>
{npmClients.map(client => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const BlockList: React.FC<BlockListProps> = props => {
useEffect(
() => {
setSelectedTag('');
setCurrentPage(1);
},
[list],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,15 @@ const BlocksViewer: React.FC<Props> = props => {
() => {
return activeResource || resources.filter(item => item.blockType === type)[0];
},
[resources, activeResource],
[resources, activeResource, type],
);

const blocks = current && block.blockData[current.id] ? block.blockData[current.id] : [];
const blocks = useMemo<Block[]>(
() => {
return current && block.blockData[current.id] ? block.blockData[current.id] : [];
},
[block, current],
);

// 初始化 block dva model data
useEffect(
Expand Down