MCPcopy Create free account
hub / github.com/MankaiHuang/screen-visualization / Grid

Function Grid

src/components/Grid/Grid.jsx:9–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7
8
9const Grid = props => {
10 const [modalData, setModalData] = useState({ showModal: false, modalId: '' }) // 设置弹窗id以及是否展示,id为空则为新建
11 const [data, setData] = useState({
12 previewVisible: false,
13 insertBtn: true,
14 previewImage: '',
15 fileList: props.templateList
16 })
17 const createBlankScreen = async () => {
18 // 新建空白模板
19 props.setLoading(true)
20 props.setLoading(false)
21 router.push({
22 pathname: '/workspace',
23 query: { templateName: '123' }
24 });
25 }
26 const copyScreen = async (id) => {
27 // 根据id copy模板
28 props.setLoading(true)
29 const params = copyData.data
30 const componentList = JSON.parse(JSON.stringify(params.componentList))
31 params.componentList = []
32 componentList.map(item => {
33 params.componentList.push({ extend: item.extend })
34 })
35 params.name = `${params.name}_copy`
36 params.extend.title = `${params.name}_copy`
37 params.extend.description = params.description
38 delete params.id
39 delete params.createTime
40 params.type = props.type
41 props.setLoading(false)
42 props.initData()
43
44 }
45 const deleteSelectedTemplate = async (id) => {
46 // 删除模板
47 data.fileList.splice(searchIndex(id), 1)
48 props.initData()
49 }
50 const openModal = (id = '') => {
51 setModalData({
52 showModal: true,
53 id,
54 })
55 }
56 const close = (values = '', id = '') => {
57 if (values !== '') {
58 addTemplate(values)
59 }
60 setModalData({
61 showModal: false,
62 id,
63 })
64 }
65 function addTemplate (values) {
66 data.fileList.unshift({ id: values.id, name: values.name, preview: values.preview, description: values.extend && values.extend.description, _public:values._public})

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected