-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
1,288 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,34 @@ | ||
import { create } from 'zustand' | ||
import { create, StateCreator } from 'zustand' | ||
import { MenuDataItem } from "@ant-design/pro-components"; | ||
import { createJSONStorage, persist } from "zustand/middleware"; | ||
|
||
interface BearState { | ||
menu: MenuDataItem[] | ||
setMenu: (menu: MenuDataItem[]) => void | ||
} | ||
|
||
const menuPersist = (initializer: StateCreator<BearState>) => | ||
persist(initializer, { | ||
name: 'menu', | ||
storage: createJSONStorage(() => sessionStorage), | ||
}) | ||
|
||
const menuOnePersist = (initializer: StateCreator<BearState>) => | ||
persist(initializer, { | ||
name: 'menu-one', | ||
storage: createJSONStorage(() => sessionStorage), | ||
}) | ||
|
||
export const useMenuStore = create<BearState>()( | ||
(set) => ({ | ||
menuPersist((set) => ({ | ||
menu: [], | ||
setMenu: (menu: MenuDataItem[]) => set({ menu: menu }), | ||
})), | ||
) | ||
|
||
export const useMenuOneStore = create<BearState>()( | ||
menuOnePersist((set) => ({ | ||
menu: [], | ||
setMenu: (menu) => set({ menu: menu }), | ||
})) | ||
setMenu: (menu: MenuDataItem[]) => set({ menu: menu }), | ||
})), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { useState } from "react"; | ||
import { | ||
ProForm, ProFormSelect, ProFormSwitch, | ||
ProFormText, | ||
} from '@ant-design/pro-components'; | ||
import { Form, message } from 'antd'; | ||
import { MdEditor } from "md-editor-rt"; | ||
import 'md-editor-rt/lib/style.css'; | ||
import http from "@/services/axios.ts"; | ||
|
||
export default function BlogAdd() { | ||
const [ text, setText ] = useState(''); | ||
return ( | ||
<ProForm | ||
title="新建表单" | ||
onFinish={async (values: any) => { | ||
console.log(values); | ||
message.success('提交成功'); | ||
return true; | ||
}} | ||
> | ||
<ProFormText | ||
width="md" | ||
name="title" | ||
label="标题" | ||
tooltip="最长为 24 位" | ||
placeholder="请输入名称" | ||
/> | ||
|
||
<ProFormText | ||
width="md" | ||
name="summary" | ||
label="摘要" | ||
placeholder="请输入名称" | ||
/> | ||
<ProForm.Group> | ||
<ProFormSelect | ||
options={[ | ||
{ | ||
value: 'chapter', | ||
label: '盖章后生效', | ||
}, | ||
]} | ||
width="md" | ||
name="typeList" | ||
label='分类' | ||
request={async () => { | ||
const tags = await http.get('/api/type/list'); | ||
const tagResp = [] | ||
tags.forEach((tag) => { | ||
const obj = {}; | ||
obj.label = tag.name; | ||
obj.value = tag.id; | ||
obj.obj = tag; | ||
tagResp.push(obj); | ||
}) | ||
return tagResp; | ||
}} | ||
/> | ||
<ProFormSelect | ||
width="md" | ||
name="tagList" | ||
label='标签' | ||
mode='multiple' | ||
request={async () => { | ||
const tags = await http.get('/api/tag/list'); | ||
const tagResp = [] | ||
tags.forEach((tag) => { | ||
const obj = {}; | ||
obj.label = tag.name; | ||
obj.value = tag.id; | ||
obj.obj = tag; | ||
tagResp.push(obj); | ||
}) | ||
return tagResp; | ||
}} | ||
/> | ||
</ProForm.Group> | ||
<ProForm.Group> | ||
<ProFormSwitch name="status" label="是否发布"/> | ||
<ProFormSwitch name="isHot" label="是否热门"/> | ||
<ProFormSwitch name="isComment" label="是否开启评论"/> | ||
</ProForm.Group> | ||
<Form.Item name={[ "article", "context" ]} label="正文" valuePropName={text}> | ||
<MdEditor modelValue={text} onChange={setText}/> | ||
</Form.Item> | ||
</ProForm> | ||
); | ||
} |
Oops, something went wrong.