Skip to content

Commit

Permalink
fix: block add modal bug (#3332)
Browse files Browse the repository at this point in the history
* fix: set page after list changed

* fix: block add modal bug
  • Loading branch information
Yu authored Sep 29, 2019
1 parent 46ee7bf commit 7f5f20d
Showing 1 changed file with 21 additions and 14 deletions.
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

0 comments on commit 7f5f20d

Please sign in to comment.