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

Function initTemplate

src/pages/Workspace/index.jsx:120–157  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

118 return data.header
119 }
120 async function initTemplate() {
121 // 根据url传来的参数选择模板
122 const res ={"msg":"查询成功","code":200,"data":{"id":"6b62be22860ae9e2fc06dab73d67a3ea","createTime":"2021-06-18 16:13:23","updateTime":null,"name":"空白模板","preview":null,"previewId":null,"backgroundId":null,"extend":{"description":""},"type":0,"_public":0,"source":1,"componentList":[]}}
123 const { componentList, extend, backgroundId, previewId, preview } = res.data
124 setSSEServer(extend.SSEServer)
125 for(const item of componentList){
126 if(item.extend.property.dataBindType.default === 'system'){
127 const proxyHeader = await initProxyPackFunc(item.extend.property.dataOrigin.default) // 获取最新的header
128 item.extend.property.dataOriginConfig.body.header = proxyHeader
129 }
130 if (item.extend.type === 'GIS') {
131 let user = window.localStorage.getItem('currentUser');
132 try {
133 user = JSON.parse(user)
134 item.extend.property.option.site = user.site;
135 } catch (error) { }
136 }
137 }
138
139 const allTemplateList = {
140 templateList: componentList,
141 ...extend
142 }
143 allTemplateList.width ? '' : allTemplateList.width = width // 有就赋值 没有就初始化
144 allTemplateList.height ? '' : allTemplateList.height = height
145 !allTemplateList.window && (allTemplateList.window = [0])
146 allTemplateList.backgroundId = backgroundId // 保存模板时需要此id 因此一起传给iframe
147 allTemplateList.background ? '' : allTemplateList.background = '#0D1D31' // 初始化颜色
148 allTemplateList.previewId = previewId
149 setBasicProperty({ ...extend, ...{ preview } })
150 basicWidth = allTemplateList.width
151 basicHeight = allTemplateList.height
152 effectFrame({
153 command: 'init',
154 templateList: allTemplateList
155 });
156 fullScreen()// 初始化缩放
157 }
158 // react每次新增图标时保持一份属性名, vue那边删除复制时给react放数据保持组件数量和标题一致
159 window.receiveMessage = async function (event) {
160 if (event && event.origin === iframeIp) {

Callers 1

WorkspaceFunction · 0.85

Calls 3

initProxyPackFuncFunction · 0.85
effectFrameFunction · 0.85
fullScreenFunction · 0.85

Tested by

no test coverage detected