View.vue 80 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620
  1. <template>
  2. <div class="meta2d">
  3. <div class="tools">
  4. <t-tooltip placement="bottom" :content="$t('新建')">
  5. <a @click="newFile">
  6. <!-- <t-icon name="add" @click="newFile" /> -->
  7. <add-icon />
  8. </a>
  9. </t-tooltip>
  10. <t-tooltip :content="$t('保存为方案')" placement="bottom">
  11. <a @click="!route.query.c && save(SaveType.Save, '', true,1)">
  12. <t-badge
  13. :class="{ gray: route.query.c }"
  14. dot
  15. :showZero="false"
  16. :count="!route.query.c && dot ? 1 : 0"
  17. >
  18. <save-icon
  19. class="hover"
  20. />
  21. <!-- <t-icon
  22. name="save"
  23. class="hover"
  24. @click="!route.query.c && save(SaveType.Save, '', true,1)"
  25. /> -->
  26. </t-badge>
  27. </a>
  28. </t-tooltip>
  29. <t-tooltip placement="bottom" :content="$t('保存为模板')">
  30. <a @click="!route.query.c && save(SaveType.Save, 'v-template', true,2)">
  31. <t-badge
  32. :class="{ gray: route.query.c }"
  33. dot
  34. :showZero="false"
  35. :count="!route.query.c && dot ? 1 : 0"
  36. >
  37. <!-- <root-list-icon class="hover"
  38. @click="!route.query.c && save(SaveType.Save, 'v-template', true,2)"/> -->
  39. <!-- <t-icon
  40. name="root-list"
  41. class="hover"
  42. @click="
  43. !route.query.c && save(SaveType.Save, 'v-template', true,2)
  44. "
  45. /> -->
  46. <RootListIcon class="hover"
  47. />
  48. </t-badge>
  49. </a>
  50. </t-tooltip>
  51. <t-tooltip placement="bottom" :content="$t('保存为我的组件')">
  52. <a :class="{ gray: route.query.id && !route.query.c }" @click="save(SaveType.Save, 'v.component', true,1)">
  53. <t-badge dot :showZero="false" :count="route.query.c && dot ? 1 : 0">
  54. <!-- <t-icon
  55. name="app"
  56. @click="save(SaveType.Save, 'le5leV-components', true)"
  57. /> -->
  58. <!-- <LayersIcon class="hover" @click="save(SaveType.Save, 'v.component', true,1)"/> -->
  59. <i class="l-icon l-zujian">
  60. </i>
  61. </t-badge>
  62. </a>
  63. </t-tooltip>
  64. <t-tooltip placement="bottom" :content="$t('格式化(双击可连续使用)')">
  65. <a @click="oneFormat" @dblclick="alwaysFormat" :style="{
  66. background: one || always ? '#4480F929' : '',
  67. color: one || always ?( theme==='light'?'#4480F9':'#4480F9'):''
  68. }"
  69. >
  70. <svg
  71. width="1em"
  72. height="1em"
  73. viewBox="0 0 256 256"
  74. xmlns="http://www.w3.org/2000/svg"
  75. xmlns:xlink="http://www.w3.org/1999/xlink"
  76. >
  77. <defs>
  78. <path id="77456364" d="M0 0h256v256H0z"></path>
  79. </defs>
  80. <g fill="none" fill-rule="evenodd">
  81. <mask id="3804093554b" fill="#fff">
  82. <use xlink:href="#77456364"></use>
  83. </mask>
  84. <path
  85. d="M213 77c0 14.36-11.64 26-26 26H69c-14.36 0-26-11.64-26-26V51c0-14.36 11.64-26 26-26h118c14.36 0 26 11.64 26 26v2h9.125c9.83 0 17.82 7.88 17.997 17.67l.003.33v50c0 9.83-7.88 17.82-17.67 17.997l-.33.003h-84.626v18H139c9.83 0 17.82 7.88 17.997 17.67l.003.33v35c0 16.016-12.984 29-29 29-15.856 0-28.74-12.725-28.996-28.52L99 210v-35c0-9.83 7.88-17.82 17.67-17.997L117 157h.499l.001-20c0-9.83 7.88-17.82 17.67-17.997l.33-.003h84.625V73H213Zm-76 100h-18v33a9 9 0 0 0 8.471 8.985l.264.011.265.004a9 9 0 0 0 8.996-8.735L137 210v-33Zm50-132H69a6 6 0 0 0-6 6v26a6 6 0 0 0 6 6h118a6 6 0 0 0 6-6V51a6 6 0 0 0-6-6Z"
  86. fill="currentColor"
  87. fill-rule="nonzero"
  88. mask="url(#3804093554b)"
  89. ></path>
  90. </g>
  91. </svg>
  92. </a>
  93. </t-tooltip>
  94. <t-tooltip placement="bottom" :content="$t('清除格式')">
  95. <a @click="clearFormat">
  96. <svg
  97. width="1em"
  98. height="1em"
  99. viewBox="0 0 1024 1024"
  100. xmlns="http://www.w3.org/2000/svg"
  101. >
  102. <path
  103. d="M889.186 384.07 677.671 172.56c-53.063-53.063-139.094-53.063-192.157 0L134.617 523.457c-53.063 53.063-53.063 139.099 0 192.158l170.196 170.2a41.354 41.354 0 0 0 29.243 12.11h215.001a41.354 41.354 0 0 0 29.184-12.05L889.155 576.26c53.094-53.09 53.094-139.126.031-192.19zM830.7 442.558c20.48 20.472 20.764 53.492.855 74.319l-.961.984-298.618 297.358H351.185l-158.09-158.086c-20.76-20.763-20.76-54.43 0-75.193l350.901-350.897c20.764-20.764 54.43-20.764 75.193 0l211.515 211.511z"
  104. fill="currentColor"
  105. ></path>
  106. <path
  107. d="m685.505 678.754-58.19 58.77-317.587-314.43 58.191-58.774zm197.55 136.508c23.46 0 42.483 18.514 42.483 41.353 0 22.45-18.38 40.724-41.294 41.338l-1.19.016h-454.6c-23.462 0-42.485-18.514-42.485-41.354 0-22.449 18.381-40.723 41.295-41.338l1.19-.015h454.6z"
  108. fill="currentColor"
  109. ></path>
  110. </svg>
  111. </a>
  112. </t-tooltip>
  113. <div class="flex-grow"></div>
  114. <t-tooltip placement="bottom" :content="$t('直线')">
  115. <a :draggable="true" @dragstart="onAddShape($event, 'line')" @click="onAddShape($event, 'line')">
  116. <slash-icon></slash-icon>
  117. <!-- <t-icon name="slash" /> -->
  118. </a>
  119. </t-tooltip>
  120. <t-tooltip placement="bottom" :content="$t('文字')">
  121. <a :draggable="true" @dragstart="onAddShape($event, 'text')" @click="onAddShape($event, 'text')">T</a>
  122. </t-tooltip>
  123. <t-tooltip placement="bottom" :content="$t('铅笔')">
  124. <a @click="onPencil" :style="{
  125. background: pencil ? '#4480F929' : '',
  126. color: pencil ?( theme==='light'?'#4480F9':'#4480F9'):''
  127. }">
  128. <PenBrushIcon />
  129. </a>
  130. </t-tooltip>
  131. <t-tooltip placement="bottom" :content="$t('钢笔(双击可连续使用)')">
  132. <a @click="oneDraw" @dblclick.stop="alwaysDraw" :style="{
  133. background: oneD || alwaysD ? '#4480F929' : '',
  134. color: oneD || alwaysD ?( theme==='light'?'#4480F9':'#4480F9'):''
  135. }"
  136. >
  137. <PenIcon />
  138. <!-- <svg
  139. width="1em"
  140. height="1em"
  141. viewBox="0 0 1024 1024"
  142. xmlns="http://www.w3.org/2000/svg"
  143. >
  144. <path
  145. d="M192 64a128 128 0 0 1 123.968 96H384a160 160 0 0 1 159.68 149.504L544 320v384a96 96 0 0 0 86.784 95.552L640 800h68.032a128 128 0 1 1 0 64.064L640 864a160 160 0 0 1-159.68-149.504L480 704V320a96 96 0 0 0-86.784-95.552L384 224l-68.032 0.064A128 128 0 1 1 192 64z m640 704a64 64 0 1 0 0 128 64 64 0 0 0 0-128zM192 128a64 64 0 1 0 0 128 64 64 0 0 0 0-128z"
  146. fill="currentColor"
  147. ></path>
  148. </svg> -->
  149. </a>
  150. </t-tooltip>
  151. <t-dropdown
  152. :minColumnWidth="200"
  153. :maxHeight="560"
  154. :delay2="[10, 150]"
  155. overlayClassName="header-dropdown"
  156. >
  157. <a>
  158. <svg class="l-icon" aria-hidden="true">
  159. <use
  160. :xlink:href="
  161. lineTypes.find((item) => item.value === currentLineType)?.icon
  162. "
  163. ></use>
  164. </svg>
  165. </a>
  166. <t-dropdown-menu>
  167. <t-dropdown-item v-for="item in lineTypes">
  168. <div class="flex middle" @click="changeLineType(item.value)">
  169. {{ item.name }} <span class="flex-grow"></span>
  170. <svg class="l-icon" aria-hidden="true">
  171. <use :xlink:href="item.icon"></use>
  172. </svg>
  173. </div>
  174. </t-dropdown-item>
  175. </t-dropdown-menu>
  176. </t-dropdown>
  177. <t-dropdown
  178. :minColumnWidth="200"
  179. :maxHeight="560"
  180. :delay2="[10, 150]"
  181. overlayClassName="header-dropdown"
  182. >
  183. <a>
  184. <svg class="l-icon" aria-hidden="true">
  185. <use
  186. :xlink:href="
  187. fromArrows.find((item) => item.value === fromArrow)?.icon
  188. "
  189. ></use>
  190. </svg>
  191. </a>
  192. <t-dropdown-menu>
  193. <t-dropdown-item v-for="item in fromArrows">
  194. <div
  195. class="flex middle"
  196. style="height: 30px"
  197. @click="changeFromArrow(item.value)"
  198. >
  199. <svg class="l-icon" aria-hidden="true">
  200. <use :xlink:href="item.icon"></use>
  201. </svg>
  202. </div>
  203. </t-dropdown-item>
  204. </t-dropdown-menu>
  205. </t-dropdown>
  206. <t-dropdown
  207. :minColumnWidth="200"
  208. :maxHeight="560"
  209. :delay2="[10, 150]"
  210. overlayClassName="header-dropdown"
  211. >
  212. <a>
  213. <svg class="l-icon" aria-hidden="true">
  214. <use
  215. :xlink:href="
  216. toArrows.find((item) => item.value === toArrow)?.icon
  217. "
  218. ></use>
  219. </svg>
  220. </a>
  221. <t-dropdown-menu>
  222. <t-dropdown-item v-for="item in toArrows">
  223. <div
  224. class="flex middle"
  225. style="height: 30px"
  226. @click="changeToArrow(item.value)"
  227. >
  228. <svg class="l-icon" aria-hidden="true">
  229. <use :xlink:href="item.icon"></use>
  230. </svg>
  231. </div>
  232. </t-dropdown-item>
  233. </t-dropdown-menu>
  234. </t-dropdown>
  235. <!-- </t-tooltip> -->
  236. <t-tooltip placement="bottom" :content="$t('视图大小')">
  237. <div style="line-height: 40px; margin-left: 8px;width:34px;">{{ scale }}%</div>
  238. </t-tooltip>
  239. <t-tooltip placement="bottom" :content="$t('100%视图')">
  240. <a @click="onScaleFull">
  241. <refresh-icon />
  242. <!-- <t-icon name="refresh" /> -->
  243. </a>
  244. </t-tooltip>
  245. <t-tooltip placement="bottom" :content="$t('窗口大小')">
  246. <a @click="onScaleWindow">
  247. <fullscreen-exit-icon />
  248. <!-- <t-icon name="fullscreen-exit" /> -->
  249. </a>
  250. </t-tooltip>
  251. <t-tooltip :content="!canScale ? $t('允许缩放') : $t('禁止缩放')" placement="bottom">
  252. <a>
  253. <svg
  254. v-if="!canScale"
  255. class="l-icon"
  256. aria-hidden="true"
  257. @click="onCanScale(true)"
  258. >
  259. <use xlink:href="#l-suofang"></use>
  260. </svg>
  261. <svg
  262. v-else
  263. class="l-icon"
  264. aria-hidden="true"
  265. @click="onCanScale(false)"
  266. >
  267. <use xlink:href="#l-jinzhisuofang"></use>
  268. </svg>
  269. </a>
  270. </t-tooltip>
  271. <t-tooltip placement="bottom" :content="$t('自适应设置')">
  272. <a :style="{
  273. background: fitFlag ? '#4480F929' : '',
  274. color: fitFlag ?( theme==='light'?'#4480F9':'#4480F9'):''
  275. }"
  276. @click="changeFit">
  277. <LayoutIcon />
  278. </a>
  279. </t-tooltip>
  280. <div class="flex-grow"></div>
  281. <!-- <t-tooltip content="数据管理" placement="bottom">
  282. <a @click="onShowDataDialog">
  283. <server-icon />
  284. </a>
  285. </t-tooltip> -->
  286. <t-divider style="margin: 15px 4px" layout="vertical"></t-divider>
  287. <t-tooltip :content="isLock ? $t('浏览模式') : $t('编辑模式')" placement="bottom">
  288. <a class="a-1">
  289. <svg
  290. v-if="isLock"
  291. class="l-icon"
  292. aria-hidden="true"
  293. @click="onLock(0)"
  294. >
  295. <use xlink:href="#l-lock"></use>
  296. </svg>
  297. <svg v-else class="l-icon" aria-hidden="true" @click="onLock(1)">
  298. <use xlink:href="#l-unlock"></use>
  299. </svg>
  300. </a>
  301. </t-tooltip>
  302. <t-tooltip placement="bottom" :content="$t('运行(预览)')">
  303. <a class="a-1" @click="preview">
  304. <caret-right-icon />
  305. <!-- <t-icon name="caret-right" /> -->
  306. </a>
  307. </t-tooltip>
  308. <t-tooltip placement="bottom" :content="$t('分享')">
  309. <a @click="share" :class="{ 'share-primary': shared }">
  310. <share-icon />
  311. <!-- <t-icon name="share" :class="{ primary: shared }" /> -->
  312. </a>
  313. </t-tooltip>
  314. <t-popup placement="bottom" v-model="qrcode.visible">
  315. <a>
  316. <qrcode-icon />
  317. <!-- <t-icon name="qrcode" /> -->
  318. </a>
  319. <template #content>
  320. <div style="padding: 12px 12px 6px 12px">
  321. <img v-if="route.query.id && !route.query.c" :src="qrcode.url">
  322. <div v-else-if="!route.query.id" class="gray center mb-4" style="font-size: 10px; margin-bottom: 6px">
  323. {{$t('当前项目为本地编辑模式')}}<br>
  324. {{$t('请保存为大屏项目后访问')}}
  325. </div>
  326. <div v-else class="gray center mb-4" style="font-size: 10px; margin-bottom: 6px">
  327. {{$t('仅支持手机访问大屏项目')}}
  328. </div>
  329. </div>
  330. </template>
  331. </t-popup>
  332. <t-tooltip placement="bottom" :content="$t('云发布')">
  333. <a @click="onShowPublish">
  334. <cloud-icon />
  335. <!-- <t-icon name="cloud" /> -->
  336. </a>
  337. </t-tooltip>
  338. </div>
  339. <div id="meta2d"></div>
  340. <ContextMenu v-if="contextmenu.visible" :type="contextmenu.type" :style="contextmenu.style" @changeVisible="changeContextMenuVisible" @replaceScene="replaceScene"></ContextMenu>
  341. <t-dialog v-if="dataDialog.show" width="800px" :visible="true" @close="closeDataDialog" :header="$t('数据管理')">
  342. <t-tabs v-model="dataDialog.tab" class="body">
  343. <t-tab-panel :value="1" :destroy-on-hide="false" :label="$t('数据获取')">
  344. <template #panel>
  345. <div v-if="!dataDialog.editNetwork">
  346. <div class="mt-16 flex between middle">
  347. <div>
  348. <!-- <label class="ml-8"> 轮询间隔 </label>
  349. <t-input-number
  350. style="width: 100px"
  351. v-model="dataDialog.networkInterval"
  352. @change="networkIntervalChange"
  353. theme="normal"
  354. :min="30"
  355. placeholder="毫秒"
  356. suffix="ms"
  357. /> -->
  358. </div>
  359. <div>
  360. <t-select-input
  361. v-model:inputValue="dataDialog.input"
  362. :placeholder="$t('搜索我的数据获取')"
  363. allow-input
  364. clearable
  365. @focus="dataDialog.popupVisible = true"
  366. @blur="dataDialog.popupVisible = false"
  367. @input-change="onInputNetwork"
  368. style="width: 240px"
  369. >
  370. <template #panel>
  371. <ul style="padding: 4px">
  372. <li
  373. class="hover-background item"
  374. v-for="(item, i) in dataDialog.networkList"
  375. :key="item.url"
  376. @click="onSelectNetWork(item)"
  377. >
  378. <div style="font-size: 14px">{{ item.name }}</div>
  379. <div class="desc">{{ item.url }}</div>
  380. <span class="del" @click.stop="onDelNetWork(item, i)">
  381. <delete-icon />
  382. <!-- <t-icon name="delete" /> -->
  383. </span>
  384. </li>
  385. <li
  386. v-if="dataDialog.networkList.length >= 10"
  387. style="
  388. line-height: 1.5;
  389. padding: 8px;
  390. border-radius: 2px;
  391. "
  392. :key="-1"
  393. >
  394. <div class="desc">...</div>
  395. </li>
  396. <li v-if="!dataDialog.networkList.length" style="
  397. line-height: 1.5;
  398. padding: 8px;
  399. border-radius: 2px;
  400. " :key="-1">
  401. <div class="desc">{{$t('暂无数据')}}</div>
  402. </li>
  403. </ul>
  404. </template>
  405. <template #suffixIcon>
  406. <search-icon class="hover"/>
  407. <!-- <t-icon name="search" class="hover" /> -->
  408. </template>
  409. </t-select-input>
  410. <t-button class="ml-12" style="height: 30px" @click="addNetwork">
  411. {{$t('添加数据获取')}}
  412. </t-button>
  413. </div>
  414. </div>
  415. <t-table
  416. class="mt-12"
  417. row-key="id"
  418. :data="dataDialog.networks"
  419. :columns="networkColumns"
  420. :max-height="280"
  421. size="small"
  422. >
  423. <template #protocol="{ row, rowIndex }">
  424. {{ row.protocol || 'MQTT' }}
  425. </template>
  426. <template #url="{ row, rowIndex }">
  427. {{ row.url }}
  428. </template>
  429. <template #actions="{ row, rowIndex }">
  430. <a @click="editNetwork(row, rowIndex)"> {{$t('编辑')}} </a>
  431. <a class="ml-12" @click="deleteNetwork(rowIndex)"> {{$t('删除')}} </a>
  432. </template>
  433. <template #empty>
  434. <div class="center">
  435. <div>{{$t('暂无数据')}}</div>
  436. <div class="mt-8">
  437. <a @click="addNetwork"> + {{$t('添加数据获取')}}</a>
  438. </div>
  439. </div>
  440. </template>
  441. </t-table>
  442. </div>
  443. <div v-else>
  444. <div class="mt-8">
  445. <a
  446. @click="
  447. dataDialog.network = dataDialog.networkBak;
  448. dataDialog.editNetwork = false;
  449. "
  450. class="flex middle"
  451. style="width: 44px"
  452. >
  453. <rollback-icon class="mr-4"/>
  454. <!-- <t-icon name="rollback" class="mr-4" /> -->
  455. {{$t('返回')}}
  456. </a>
  457. </div>
  458. <div style="height: 300px; overflow-y: auto">
  459. <Network v-model="dataDialog.network" />
  460. </div>
  461. </div>
  462. </template>
  463. </t-tab-panel>
  464. <t-tab-panel :value="2" :destroy-on-hide="false">
  465. <template #label> {{$t('变量列表')}} </template>
  466. <template #panel>
  467. <template v-if="!dataDialog.editDataset">
  468. <div class="form-item mt-16 flex between middle">
  469. <div>
  470. <a @click="showAddData()"> + {{$t('新建变量')}}</a>
  471. <a class="ml-16" @click="clearData()"> × {{$t('清空列表')}}</a>
  472. </div>
  473. <div class="form-item flex">
  474. <!-- <div class="form-item flex"> -->
  475. <label style="text-align: end;margin-left: 8px;font-size: 13px;">{{$t('导入变量')}}:</label>
  476. <t-select style="width: 120px" v-model="dataDialog.datasetType" :placeholder="$t('选择变量')">
  477. <t-option :key="1" :value="1" :label="$t('我的变量列表')"></t-option>
  478. <t-option :key="2" :value="2" :label="$t('从Excel导入')"></t-option>
  479. <t-option :key="3" :value="3" :label="$t('在线接口')"></t-option>
  480. </t-select>
  481. <!-- </div> -->
  482. <!-- <label style="width: 100px"> 当前变量列表 </label> -->
  483. <!-- <div class="flex"> -->
  484. <div style="width: 240px;padding-left: 8px;">
  485. <t-select
  486. v-if="dataDialog.datasetType === 1"
  487. v-model="dataDialog.datasetId"
  488. filterable
  489. :placeholder="$t('选择变量列表')"
  490. :on-search="onInputDatasets"
  491. :popup-props="{ overlayClassName: 'select-options' }"
  492. @change="onSelDataset()"
  493. >
  494. <t-option
  495. v-for="(item, i) in dataDialog.datasetList"
  496. :key="item.id"
  497. :value="item.id"
  498. :label="item.name"
  499. >
  500. <div class="hover-background item">
  501. <div style="font-size: 14px">{{ item.name }}</div>
  502. <div v-if="item.url" class="desc">
  503. {{ item.url }}
  504. </div>
  505. <div v-else class="desc">{{$t('自定义')}}</div>
  506. <span class="del" @click.stop="onDelDataset(item, i)">
  507. <delete-icon />
  508. <!-- <t-icon name="delete" /> -->
  509. </span>
  510. </div>
  511. </t-option>
  512. <t-option
  513. v-if="dataDialog.datasetList.length >= 10"
  514. :disabled="true"
  515. >
  516. <div class="ml-8 gray">...</div>
  517. </t-option>
  518. </t-select>
  519. <div class="flex middle" v-if="dataDialog.datasetType === 2">
  520. <t-button class="shrink-0 ml-24" style="width: 90px; height: 30px" @click="importDataset">
  521. {{$t('导入')}}Excel
  522. </t-button>
  523. <a :href="cdn ? cdn + '/v/data.xlsx' : '/data.xlsx'" download class="ml-12 mt-4 nowrap">
  524. {{$t('下载')}}Excel{{$t('示例')}}
  525. </a>
  526. </div>
  527. <div v-if="dataDialog.datasetType === 3" class="form-item">
  528. <t-input v-model="dataDialog.dataset.url" @blur="getDatas" @enter="getDatas" :label="$t('地址:')" :placeholder="$t('点击图标或回车获取数据')">
  529. <template #suffixIcon>
  530. <CloudDownloadIcon @click="getDatas" :style="{ cursor: 'pointer' }" />
  531. </template>
  532. </t-input>
  533. </div>
  534. </div>
  535. </div>
  536. <!-- <t-button
  537. class="ml-12 shrink-0"
  538. style="height: 30px"
  539. @click="addDataset"
  540. >
  541. 添加变量列表
  542. </t-button> -->
  543. <!-- </div> -->
  544. </div>
  545. <t-table
  546. class="mt-12"
  547. row-key="id"
  548. :data="dataDialog.dataset.devices"
  549. :columns="datasetColumns"
  550. size="small"
  551. :max-height="280"
  552. >
  553. <template #type="{ row }">
  554. {{ row.type || 'string' }}
  555. </template>
  556. <template #actions="{ row, rowIndex }">
  557. <edit-icon class="hover" @click="showAddData(row, rowIndex)"/>
  558. <delete-icon class="ml-12 hover"
  559. @click="dataDialog.dataset.devices.splice(rowIndex, 1)"/>
  560. </template>
  561. </t-table>
  562. </template>
  563. <div v-else>
  564. <div class="mt-8">
  565. <a @click="backDataset" class="flex middle" style="width: 44px">
  566. <rollback-icon class="mr-4"/>
  567. <!-- <t-icon name="rollback" class="mr-4" /> -->
  568. {{$t('返回')}}
  569. </a>
  570. </div>
  571. <div style="height: 300px; overflow-y: auto">
  572. <Dataset v-model="dataDialog.dataset" />
  573. </div>
  574. </div>
  575. </template>
  576. </t-tab-panel>
  577. </t-tabs>
  578. <template #footer>
  579. <div
  580. v-if="dataDialog.tab === 1 && dataDialog.editNetwork"
  581. class="flex middle"
  582. >
  583. <div class="flex-grow"></div>
  584. <t-checkbox v-model="dataDialog.save" class="mr-12">
  585. {{$t('同时保存到我的数据获取')}}
  586. </t-checkbox>
  587. <t-button @click="onOkNetwork">{{$t('确定')}}</t-button>
  588. </div>
  589. <div v-else-if="dataDialog.tab === 2" class="flex middle">
  590. <template v-if="dataDialog.editDataset === 1">
  591. <div class="flex-grow"></div>
  592. <t-checkbox v-model="dataDialog.save" class="mr-12">
  593. {{$t('同时保存为我的变量列表')}}
  594. </t-checkbox>
  595. <t-button @click="onOkDataset()">{{$t('保存')}}</t-button>
  596. </template>
  597. <template v-else-if="dataDialog.editDataset === 2">
  598. <div class="flex-grow"></div>
  599. <t-button @click="onOkDataset(true)"> {{$t('另存为新变量列表')}} </t-button>
  600. <t-button @click="onOkDataset()">{{$t('保存')}}</t-button>
  601. </template>
  602. <template v-else>
  603. <!-- <a
  604. v-if="dataDialog.dataset && dataDialog.dataset.id"
  605. @click="editDataset"
  606. >
  607. 编辑当前变量列表
  608. </a> -->
  609. <t-checkbox style="display: inline;" v-model="dataDialog.enableMock" @change="onChangeMock">
  610. {{$t('开启模拟数据')}}
  611. </t-checkbox>
  612. <div class="flex-grow"></div>
  613. <t-button @click="downloadAsJson" variant="outline" theme="primary">
  614. <template #icon><FileIcon></FileIcon></template>
  615. {{$t('下载为')}}JSON
  616. </t-button>
  617. <t-button @click="downloadAsExcel" variant="outline" theme="primary">
  618. <template #icon><FileExcelIcon></FileExcelIcon></template>
  619. {{$t('下载为')}}Excel
  620. </t-button>
  621. <t-button @click="onOkDataset()"> {{$t('保存为我的变量列表')}} </t-button>
  622. <!-- <t-button @click="dataDialog.show = false"> 完成 </t-button> -->
  623. </template>
  624. </div>
  625. <div v-else class="flex middle">
  626. <div class="flex-grow"></div>
  627. <t-button @click="onFinishDataDialog"> {{$t('完成')}} </t-button>
  628. </div>
  629. </template>
  630. </t-dialog>
  631. <t-dialog
  632. v-if="publishDialog.show"
  633. width="700px"
  634. :header="$t('云发布')"
  635. :visible="true"
  636. :cancel-btn="null"
  637. :confirm-btn="$t('完成')"
  638. @close="publishDialog.show = false"
  639. @confirm="publishDialog.show = false"
  640. >
  641. <div class="body" style="height: 350px">
  642. <div class="form-item mt-8">
  643. <label>{{$t('项目名称')}}</label>
  644. <div class="flex middle">
  645. <laptop-icon class="mr-8"></laptop-icon>
  646. <!-- <t-icon name="laptop" class="mr-8" /> -->
  647. {{ publishDialog.name }}
  648. </div>
  649. </div>
  650. <template v-if="publishDialog.data">
  651. <div class="form-item mt-8">
  652. <label>{{$t('发布状态')}}</label>
  653. <div v-if="publishDialog.data.id" class="flex middle">
  654. <div v-if="publishDialog.data.isExpired" class="warning">
  655. <stop-circle-icon class="mr-4" />
  656. <!-- <t-icon name="stop-circle-1" class="mr-4" /> -->
  657. {{$t('已过期')}}
  658. </div>
  659. <div v-else class="primary">
  660. <play-circle-icon class="mr-4" />
  661. <!-- <t-icon name="play-circle" class="mr-4" /> -->
  662. {{$t('正在运行')}}
  663. </div>
  664. <div class="gray" style="margin-left: 32px; margin-top: -2px">
  665. {{$t(' 有效期至:')}}{{ publishDialog.data.expired }}
  666. </div>
  667. <p>{{$t('需要开通高级会员')}}</p>
  668. <!-- <a class="bland ml-12" @click="publishChargeDialog.show = true">
  669. 续费
  670. </a> -->
  671. </div>
  672. <div v-else class="flex middle">
  673. <play-circle-stroke-icon class="mr-4" />
  674. <!-- <t-icon name="play-circle-stroke" class="mr-4" /> -->
  675. {{$t('未发布')}}
  676. </div>
  677. </div>
  678. <div class="form-item mt-16">
  679. <label>{{$t('乐吾乐域名')}}</label>
  680. <div class="flex w-full">
  681. <t-input :value="publishDialog.data.subDomain ? publishDialog.data.subDomain.split('.')[0] : ''" :maxlength="16" :status="publishDialog.status" :tips="publishDialog.tips" class="mr-4" style="width: 350px" @change="onChangeSubdomain" :placeholder="$t('子域名')"></t-input>
  682. <t-tooltip :content="$t('随机生成')">
  683. <refresh-icon class="hover" @click="refreshSubdomain"></refresh-icon>
  684. <!-- <t-icon
  685. name="refresh"
  686. class="hover"
  687. @click="refreshSubdomain"
  688. /> -->
  689. </t-tooltip>
  690. <div class="mt-4 ml-16">{{`v${rootDomain}`}}</div>
  691. </div>
  692. </div>
  693. <div class="form-item mt-24">
  694. <label>{{$t('访问域名')}}</label>
  695. <div class="w-full">
  696. <div class="flex middle">
  697. <t-input v-model="publishDialog.data.domain" style="width: 350px" :placeholder="$t('支持自定义域名')"></t-input>
  698. <template v-if="publishDialog.data.domain">
  699. <a :href="`http://${publishDialog.data.domain}`" target="_blank" class="hover" style="margin-left: 36px; text-decoration: underline">
  700. {{$t('点击访问')}}
  701. </a>
  702. <t-popup
  703. placement="bottom"
  704. v-model="publishDialog.qrcodeVisible"
  705. >
  706. <a class="hover" style="margin-left: 32px">
  707. <qrcode-icon />
  708. <!-- <t-icon name="qrcode" /> -->
  709. <span style="margin-left: 2px; position: relative; top: 1px">
  710. {{$t('手机访问')}}
  711. </span>
  712. </a>
  713. <template #content>
  714. <div style="padding: 12px 12px 6px 12px">
  715. <img :src="publishDialog.url">
  716. </div>
  717. </template>
  718. </t-popup>
  719. </template>
  720. </div>
  721. <div class="desc mt-12">
  722. <div class="title desc">- {{$t('注意')}}</div>
  723. <div>{{$t('仅支持')}}48{{$t('小时免费试用')}},{{$t('到期后需要续费使用')}}。</div>
  724. </div>
  725. <div class="desc mt-8">
  726. <div class="title desc">- {{$t('自定义域名')}}</div>
  727. <div>
  728. {{$t('在域名服务商的')}}DNS{{$t('控制台设置好对应的')}}CNAME,{{$t('值为乐吾乐域名')}}。
  729. <a :href="`https://doc${rootDomain}/document/126505408`" target="_blank">
  730. {{$t('更多帮助')}}
  731. </a>
  732. </div>
  733. </div>
  734. </div>
  735. </div>
  736. <div class="form-item mt-16">
  737. <label></label>
  738. <div class="w-full">
  739. <t-button @click="onPublish">{{$t('发布')}}</t-button>
  740. <t-button v-if="publishDialog.data.id&&!publishDialog.data.isExpired" @click="onCancelPublish" class="ml-16">{{$t('取消发布')}}</t-button>
  741. </div>
  742. </div>
  743. </template>
  744. <div v-else class="flex center" style="margin-top: 32px">
  745. <t-loading size="small" :text="$t('加载中...')"></t-loading>
  746. </div>
  747. </div>
  748. </t-dialog>
  749. <t-dialog
  750. v-if="publishChargeDialog.show"
  751. v-model:visible="publishChargeDialog.show"
  752. :header="$t('云发布续费')"
  753. :close-on-overlay-click="false"
  754. :width="700"
  755. :footer="false"
  756. >
  757. <ChargeCloudPublish
  758. :projectId="publishDialog.id"
  759. @success="onSuccessChargeCloud"
  760. />
  761. </t-dialog>
  762. <!-- 分享弹窗 -->
  763. <ShareModal :shared="shared" v-model:visible="shareVisible" />
  764. <t-dialog
  765. v-if="addDataDialog.show"
  766. :visible="true"
  767. class="data-dialog"
  768. :header="addDataDialog.header"
  769. @close="addDataDialog.show = false"
  770. @confirm="onOkAddData"
  771. >
  772. <!-- <div class="form-item mt-16">
  773. <label>设备</label>
  774. <t-input v-model="addDataDialog.data.device" placeholder="设备名称" />
  775. </div> -->
  776. <div class="form-item mt-16">
  777. <label>{{$t('显示名称')}}</label>
  778. <t-input @change="changeDataLabel($event)" :value="addDataDialog.data.label" :placeholder="$t('变量简短描述')"></t-input>
  779. </div>
  780. <div class="form-item mt-16">
  781. <label>{{$t('变量名')}}</label>
  782. <t-input @change="changeDataID($event)" :value="addDataDialog.data.id" :placeholder="$t('变量名')"></t-input>
  783. </div>
  784. <div class="form-item mt-16">
  785. <label>{{$t('类型')}}</label>
  786. <t-select class="w-full" :options="typeOptions" v-model="addDataDialog.data.type" @change="addDataDialog.data.value = null" :placeholder="$t('字符串')"></t-select>
  787. </div>
  788. <div class="form-item mt-16">
  789. <label>{{$t('值范围')}}</label>
  790. <div class="w-full">
  791. <t-input v-model="addDataDialog.data.mock" :placeholder="$t('值范围')"></t-input>
  792. <h6 class="desc mt-8">{{$t('值范围说明')}}</h6>
  793. <ul class="desc ml-16">
  794. <li>
  795. <label class="inline" style="width: 80px">{{$t('固定值')}}:</label>
  796. {{$t('直接填写')}},{{$t('例如')}}:10
  797. </li>
  798. <li>
  799. <label class="inline" style="width: 80px">{{$t( '随机值' )}}:</label>
  800. { {{$t( '值1,值2,' )}}...}。{{$t( '例如' )}}:{1,2,3,4,5}
  801. </li>
  802. <li>
  803. <label class="inline" style="width: 80px">{{$t('范围数字')}}:</label>
  804. {{$t('最小值')}}-{{$t('最大值')}}。{{$t('例如')}}:0-1.0 {{$t('或')}} 0-100
  805. </li>
  806. <li>
  807. <label class="inline" style="width: 80px">{{$t('随机字符串')}}:</label>
  808. [{{$t('长度')}}]。{{$t('例如')}}:[8]
  809. </li>
  810. </ul>
  811. </div>
  812. </div>
  813. </t-dialog>
  814. <t-dialog v-model:visible="replaceDialog.show" class="project-dialog" :width="700" @close="replaceDialog.show = false" @confirm="onReplace" :header="$t('方案列表')">
  815. <t-tabs :value="replaceDialog.collection" @change="sceneChange">
  816. <t-tab-panel
  817. v-for="item in replaceList"
  818. :value="item.key"
  819. :label="item.label"
  820. :destroy-on-hide="false"
  821. style="max-height: 420px"
  822. >
  823. <div class="flex box-list" style="flex-wrap:wrap;justify-content: flex-start;">
  824. <template v-if="replaceDialog.list?.length">
  825. <div class="box" :class="{active:replaceDialog.select?.id===_item.id}" @click="selectScene(_item)" v-for="_item in replaceDialog.list">
  826. <div class="box-img">
  827. <img :src="_item.image"></img>
  828. </div>
  829. <div class="item-title" :title="_item.name">{{_item.name}}</div>
  830. </div>
  831. </template>
  832. <template v-else >
  833. <div class="item-title" style="height:50px;">
  834. 暂无数据
  835. </div>
  836. </template>
  837. </div>
  838. <t-pagination :pageSizeOptions="[15,30,60]" :total="replaceDialog.total" v-model="replaceDialog.current" :pageSize="replaceDialog.pageSize" @change="pageChange" />
  839. </t-tab-panel>
  840. </t-tabs>
  841. </t-dialog>
  842. </div>
  843. </template>
  844. <script lang="ts" setup>
  845. import { onMounted, onUnmounted, watch, ref, reactive, toRaw, computed, getCurrentInstance } from 'vue';
  846. import { useRouter, useRoute } from 'vue-router';
  847. import {
  848. Meta2d,
  849. Options,
  850. Pen,
  851. deepClone,
  852. PenType,
  853. HoverType,
  854. } from '@meta2d/core';
  855. import localforage from 'localforage';
  856. import dayjs from 'dayjs';
  857. import QRCode from 'qrcode';
  858. import axios from 'axios';
  859. import { MessagePlugin } from 'tdesign-vue-next';
  860. import { registerBasicDiagram } from '@/services/register';
  861. import { useUser, getDomain } from '@/services/user';
  862. import {
  863. cdn,
  864. getComponents,
  865. getLe5leV,
  866. updateCollection,
  867. } from '@/services/api';
  868. import {
  869. save,
  870. autoSave,
  871. newFile,
  872. SaveType,
  873. onScaleFull,
  874. onScaleWindow,
  875. useDot,
  876. // autoSaveAS,
  877. } from '@/services/common';
  878. import { useSelection } from '@/services/selections';
  879. import { defaultFormat, fromArrows, toArrows, rootDomain } from '@/services/defaults';
  880. import { checkData, localStorageName, Meta2dBackData, noLoginTip } from '@/services/utils';
  881. import { debounce } from '@/services/debouce';
  882. import { s8 } from '@/services/random';
  883. import { setCookie, deleteCookie } from '@/services/cookie';
  884. import ShareModal from '@/views/components/common/ShareModal.vue';
  885. import ContextMenu from './ContextMenu.vue';
  886. import Network from './Network.vue';
  887. import Dataset from './Dataset.vue';
  888. import ChargeCloudPublish from './ChargeCloudPublish.vue';
  889. import { AddIcon, EditIcon, SaveIcon, RootListIcon,SlashIcon, RefreshIcon, ServerIcon, CaretRightIcon, ShareIcon, QrcodeIcon, CloudIcon, DeleteIcon, SearchIcon, RollbackIcon, LaptopIcon, StopCircleIcon , PlayCircleIcon, PlayCircleStrokeIcon, LayersIcon, FullscreenExitIcon, FileIcon, FileExcelIcon, CloudDownloadIcon, PenBrushIcon, PenIcon, LayoutIcon } from 'tdesign-icons-vue-next';
  890. import {transformData} from '@/services/utils';
  891. import { importExcel, saveAsExcel } from '@/services/excel';
  892. import { typeOptions } from '@/services/common';
  893. import { upload } from '@/services/file';
  894. import { getCollectionList } from '@/services/api';
  895. import { parseSearchToken } from '@le5le/auth-token';
  896. const router = useRouter();
  897. const route = useRoute();
  898. const { user, getUser } = useUser();
  899. const { dot, setDot } = useDot();
  900. const { select, selections } = useSelection();
  901. const { proxy } = getCurrentInstance();
  902. const $t = proxy.$t
  903. const meta2dOptions: Options = {
  904. cdn,
  905. rule: true,
  906. ruleColor:'#222E47',
  907. // background: '#1e2430',
  908. rotateCursor: cdn + '/v/rotate.cur', //'https://assets.le5lecdn.com/2d/rotate.cur',
  909. rightCursor: cdn + '/v/right.cur',
  910. downCursor: cdn + '/v/down.cur',
  911. ruleOptions:{
  912. background:'#121924',
  913. underline:true,
  914. baseline:'bottom',
  915. textTop:6,
  916. textLeft:-24,
  917. textColor:'#6E7B91'
  918. },
  919. x: 32,
  920. y: 32,
  921. width: 1920,
  922. height: 1080,
  923. // color: '#bdc7db',
  924. disableAnchor: true,
  925. defaultFormat: { ...defaultFormat },
  926. uploadFn: async (file: File) => {
  927. if (!(user&&user.id)) {
  928. MessagePlugin.warning(noLoginTip);
  929. return;
  930. }
  931. const res:any = await upload(
  932. file,
  933. true,
  934. file.name,
  935. `/大屏/图片/默认`,
  936. 'new'
  937. );
  938. return res.url;
  939. },
  940. };
  941. let timer: any = 0;
  942. const shared = ref<boolean>(false);
  943. const shareVisible = ref<boolean>(false);
  944. const qrcode = reactive({
  945. visible: false,
  946. url: '',
  947. });
  948. const publishDialog = reactive<any>({});
  949. const publishChargeDialog = reactive<any>({});
  950. onMounted(() => {
  951. meta2d = new Meta2d('meta2d', meta2dOptions);
  952. registerBasicDiagram();
  953. open(true);
  954. meta2d.on('active', active);
  955. meta2d.on('inactive', inactive);
  956. meta2d.on('fit',fit);
  957. meta2d.on('scale', scaleSubscriber);
  958. meta2d.on('add', lineAdd);
  959. meta2d.on('add', penAdd);
  960. meta2d.on('opened', openedListener);
  961. meta2d.on('undo', patchFlag);
  962. meta2d.on('redo', patchFlag);
  963. meta2d.on('add', patchFlag);
  964. meta2d.on('delete', patchFlag);
  965. meta2d.on('rotatePens', patchFlag);
  966. meta2d.on('translatePens', patchFlag);
  967. // 所有编辑栏所做修改
  968. meta2d.on('components-update-value', patchFlag);
  969. meta2d.on('contextmenu', onContextmenu);
  970. meta2d.on('click', canvasClick);
  971. timer = setInterval(autoSave, 60000);
  972. window.onbeforeunload = () => {
  973. autoSave();
  974. };
  975. // 注册自定义主题,这块仅供源码客户参考,注释
  976. // registerLe5leTheme();
  977. });
  978. onUnmounted(()=>{
  979. meta2d.off('active', active);
  980. meta2d.off('inactive', inactive);
  981. meta2d.off('fit',fit);
  982. meta2d.off('scale', scaleSubscriber);
  983. meta2d.off('add', lineAdd);
  984. meta2d.off('add', penAdd);
  985. meta2d.off('opened', openedListener);
  986. meta2d.off('undo', patchFlag);
  987. meta2d.off('redo', patchFlag);
  988. meta2d.off('add', patchFlag);
  989. meta2d.off('delete', patchFlag);
  990. meta2d.off('rotatePens', patchFlag);
  991. meta2d.off('translatePens', patchFlag);
  992. // 所有编辑栏所做修改
  993. meta2d.off('components-update-value', patchFlag);
  994. meta2d.off('contextmenu', onContextmenu);
  995. meta2d.off('click', canvasClick);
  996. // meta2d.off('business-showPayDiagram',showPayDiagram);
  997. })
  998. const watcher = watch(
  999. () => route.query,
  1000. async () => {
  1001. open();
  1002. }
  1003. );
  1004. //TODO 打开图纸
  1005. const open = async (flag: boolean = false) => {
  1006. if(route.query.token||route.query['x-token']){
  1007. parseSearchToken();
  1008. // setCookie('token', route.query.token + '', {
  1009. // path: '/',
  1010. // domain: getDomain(),
  1011. // });
  1012. getUser();
  1013. const newQuery = { ...route.query };
  1014. delete newQuery.token;
  1015. delete newQuery['x-token'];
  1016. router.replace({
  1017. path: '/',
  1018. query: newQuery,
  1019. });
  1020. return;
  1021. }
  1022. // if(route.query.saveas){
  1023. // //id需要
  1024. // await autoSaveAS((route.query.id)as string);
  1025. // return;
  1026. // }
  1027. if (route.query.id) {
  1028. let ret: any;
  1029. if (route.query.c) {
  1030. ret = await getComponents(route.query.id + '');
  1031. } else {
  1032. ret = await getLe5leV(route.query.id + '',undefined , route.query.historyId as string);
  1033. }
  1034. if (ret) {
  1035. if (!(ret.data.pens && ret.data.pens.length)) {
  1036. //获取不到pen说明是parse svg
  1037. MessagePlugin.warning($t('解析的svg图元不允许编辑!'));
  1038. newFile();
  1039. return;
  1040. }
  1041. ret.data.id = ret.id || route.query.id;;
  1042. ret.data.folder = ret.folder;
  1043. ret.data.name = ret.name;
  1044. ret.data.image = ret.image;
  1045. ret.data.ownerId = ret.ownerId;
  1046. ret.data.ownerName = ret.ownerName;
  1047. ret.data.case = ret.case;
  1048. ret.data.isSystem = ret.system;
  1049. ret.data.isTemplate = ret.template;
  1050. if(!ret.data.background){
  1051. ret.data.background = '#1e2430';
  1052. }
  1053. if(!ret.data.color){
  1054. ret.data.color = '#bdc7db';
  1055. }
  1056. if(!ret.data.width){ret.data.width= 1920};
  1057. if(!ret.data.height){ret.data.height= 1080};
  1058. meta2d.open(ret.data);
  1059. if (!route.query.c) {
  1060. shared.value = ret.shared;
  1061. const qr: any = await QRCode.toDataURL(
  1062. `https://view2d${rootDomain}/?id=${route.query.id + '&tag=v'}`
  1063. );
  1064. qrcode.url = qr;
  1065. }
  1066. }
  1067. } else if (flag) {
  1068. const data: any =JSON.parse(await localforage.getItem(localStorageName));
  1069. if(!data){
  1070. meta2d.open({
  1071. name: $t('新建项目'),
  1072. pens: [],
  1073. background: '#1e2430',
  1074. color: '#bdc7db',
  1075. width:1920,
  1076. height:1080,
  1077. enableMock: true,
  1078. folder: route.query.folder,
  1079. tags: route.query.tags ? [route.query.tags] : null,
  1080. } as any);
  1081. }else{
  1082. if(!data.background){
  1083. data.background = '#1e2430';
  1084. }
  1085. if(!data.color){
  1086. data.color = '#bdc7db';
  1087. }
  1088. if(!data.width){data.width= 1920};
  1089. if(!data.height){data.height= 1080};
  1090. if (data) {
  1091. meta2d.open(data);
  1092. }
  1093. }
  1094. } else if (!sessionStorage.getItem('opening')) {
  1095. meta2d.open({
  1096. name: $t('新建项目'),
  1097. pens: [],
  1098. background: '#1e2430',
  1099. color: '#bdc7db',
  1100. width:1920,
  1101. height:1080,
  1102. enableMock: true,
  1103. folder: route.query.folder,
  1104. tags: route.query.tags ? [route.query.tags] : null,
  1105. } as any);
  1106. }
  1107. sessionStorage.removeItem('opening');
  1108. !meta2d.store.data.x && (meta2d.store.data.x = meta2d.store.options.x || 0);
  1109. !meta2d.store.data.y && (meta2d.store.data.y = meta2d.store.options.y || 0);
  1110. };
  1111. const openedListener = () => {
  1112. const {
  1113. locked,
  1114. scale: canvasScale,
  1115. fromArrow: canvasFromArrow,
  1116. toArrow: canvasToArrow,
  1117. } = meta2d.store.data;
  1118. isLock.value = locked || 0;
  1119. scale.value = Math.round(canvasScale * 100);
  1120. fromArrow.value = canvasFromArrow || '';
  1121. toArrow.value = canvasToArrow || '';
  1122. deal2DToV();
  1123. meta2d.centerView();
  1124. meta2d.canvas.hideFit();
  1125. fitFlag.value = false;
  1126. };
  1127. const deal2DToV = ()=>{
  1128. if(!meta2d.store.data.width||!meta2d.store.data.height){
  1129. let rect = meta2d.getRect();
  1130. if(!meta2d.store.data.pens.length){
  1131. return;
  1132. }
  1133. let scale = meta2d.store.data.scale;
  1134. if(!(meta2d.store.data as any).oldV&&Math.abs(rect.width/scale-1920)<5&&Math.abs(rect.height/scale-1080)<5){ //1920 1080
  1135. //大致估算范围是大屏默认范围
  1136. return;
  1137. }
  1138. let origin = meta2d.store.data.origin;
  1139. if(rect.width/scale > 1920 || rect.height/scale > 1080){
  1140. //超出大屏默认范围
  1141. meta2d.store.data.width = rect.width/scale;
  1142. meta2d.store.data.height = rect.height/scale;
  1143. }
  1144. meta2d.store.data.pens.forEach((pen)=>{
  1145. if(pen.locked){
  1146. pen.locked = 0;
  1147. }
  1148. });
  1149. let pens = meta2d.store.data.pens.filter((pen)=>!pen.parentId);
  1150. meta2d.canvas.opening = false;
  1151. meta2d.translatePens(pens,origin.x - rect.x,origin.y - rect.y);
  1152. meta2d.store.data.pens.forEach((pen)=>{
  1153. if(!pen.type){
  1154. meta2d.canvas.updateLines(pen);
  1155. }
  1156. });
  1157. meta2d.render(true);
  1158. }
  1159. }
  1160. const patchFlag = () => {
  1161. setDot();
  1162. };
  1163. onUnmounted(() => {
  1164. clearInterval(timer);
  1165. watcher();
  1166. if (meta2d) {
  1167. meta2d.destroy();
  1168. }
  1169. });
  1170. const inactive = () => {
  1171. if(fitFlag.value){
  1172. return;
  1173. }
  1174. select();
  1175. };
  1176. const active = (pens: Pen[]) => {
  1177. if(fitFlag.value){
  1178. return;
  1179. }
  1180. select(pens);
  1181. //格式刷处理
  1182. if (one.value || always.value) {
  1183. meta2d.formatPainter();
  1184. one.value = false;
  1185. }
  1186. };
  1187. const fit = (fit) => {
  1188. select(undefined, fit);
  1189. }
  1190. const one = ref(false);
  1191. const always = ref(false);
  1192. const oneFormat = () => {
  1193. if (one.value) {
  1194. one.value = false;
  1195. } else {
  1196. one.value = true;
  1197. meta2d.setFormatPainter();
  1198. }
  1199. if (always.value) {
  1200. always.value = false;
  1201. one.value = false;
  1202. }
  1203. };
  1204. const alwaysFormat = () => {
  1205. always.value = true;
  1206. };
  1207. const clearFormat = () => {
  1208. always.value = false;
  1209. one.value = false;
  1210. meta2d.clearFormatPainter();
  1211. };
  1212. const scale = ref(100);
  1213. const scaleSubscriber = (val: number) => {
  1214. scale.value = Math.round(val * 100);
  1215. };
  1216. const dataDialog = reactive<any>({
  1217. tab: 1,
  1218. });
  1219. const currentLineType = ref('curve');
  1220. const lineTypes = reactive([
  1221. { name: $t('曲线'), icon: '#l-curve2', value: 'curve' },
  1222. { name: $t('线段'), icon: '#l-polyline', value: 'polyline' },
  1223. { name: $t('直线'), icon: '#l-line', value: 'line' },
  1224. { name: $t('脑图曲线'), icon: '#l-mind', value: 'mind' },
  1225. ]);
  1226. const changeLineType = (value: string) => {
  1227. currentLineType.value = value;
  1228. if (meta2d) {
  1229. meta2d.store.options.drawingLineName = value;
  1230. meta2d.canvas.drawingLineName && (meta2d.canvas.drawingLineName = value);
  1231. meta2d.store.active?.forEach((pen) => {
  1232. meta2d.updateLineType(pen, value);
  1233. });
  1234. }
  1235. };
  1236. const fromArrow = ref('');
  1237. // const fromArrows = [
  1238. // { icon: '#l-line', value: '' },
  1239. // { icon: '#l-from-triangle', value: 'triangle' },
  1240. // { icon: '#l-from-diamond', value: 'diamond' },
  1241. // { icon: '#l-from-circle', value: 'circle' },
  1242. // { icon: '#l-from-lineDown', value: 'lineDown' },
  1243. // { icon: '#l-from-lineUp', value: 'lineUp' },
  1244. // { icon: '#l-from-triangleSolid', value: 'triangleSolid' },
  1245. // { icon: '#l-from-diamondSolid', value: 'diamondSolid' },
  1246. // { icon: '#l-from-circleSolid', value: 'circleSolid' },
  1247. // { icon: '#l-from-line', value: 'line' },
  1248. // ];
  1249. const toArrow = ref('');
  1250. // const toArrows = [
  1251. // { icon: '#l-line', value: '' },
  1252. // { icon: '#l-to-triangle', value: 'triangle' },
  1253. // { icon: '#l-to-diamond', value: 'diamond' },
  1254. // { icon: '#l-to-circle', value: 'circle' },
  1255. // { icon: '#l-to-lineDown', value: 'lineDown' },
  1256. // { icon: '#l-to-lineUp', value: 'lineUp' },
  1257. // { icon: '#l-to-triangleSolid', value: 'triangleSolid' },
  1258. // { icon: '#l-to-diamondSolid', value: 'diamondSolid' },
  1259. // { icon: '#l-to-circleSolid', value: 'circleSolid' },
  1260. // { icon: '#l-to-line', value: 'line' },
  1261. // ];
  1262. const changeFromArrow = (value: string) => {
  1263. fromArrow.value = value;
  1264. // 画布默认值
  1265. meta2d.store.data.fromArrow = value;
  1266. // 活动层的箭头都变化
  1267. if (meta2d.store.active) {
  1268. meta2d.store.active.forEach((pen: Pen) => {
  1269. if (pen.type === PenType.Line) {
  1270. pen.fromArrow = value;
  1271. meta2d.setValue(
  1272. {
  1273. id: pen.id,
  1274. fromArrow: pen.fromArrow,
  1275. },
  1276. {
  1277. render: false,
  1278. }
  1279. );
  1280. }
  1281. });
  1282. meta2d.render();
  1283. }
  1284. };
  1285. const changeToArrow = (value: string) => {
  1286. toArrow.value = value;
  1287. // 画布默认值
  1288. meta2d.store.data.toArrow = value;
  1289. // 活动层的箭头都变化
  1290. if (meta2d.store.active) {
  1291. meta2d.store.active.forEach((pen: Pen) => {
  1292. if (pen.type === PenType.Line) {
  1293. pen.toArrow = value;
  1294. meta2d.setValue(
  1295. {
  1296. id: pen.id,
  1297. toArrow: pen.toArrow,
  1298. },
  1299. {
  1300. render: false,
  1301. }
  1302. );
  1303. }
  1304. });
  1305. meta2d.render();
  1306. }
  1307. };
  1308. const oneD = ref<boolean>(false);
  1309. const alwaysD = ref<boolean>(false);
  1310. const oneDraw = () => {
  1311. if(meta2d.canvas.pencil){
  1312. //关掉铅笔
  1313. pencil.value = false;
  1314. meta2d.stopPencil();
  1315. }
  1316. if (oneD.value) {
  1317. oneD.value = false;
  1318. if (!alwaysD.value) {
  1319. meta2d.finishDrawLine();
  1320. meta2d.drawLine();
  1321. meta2d.store.options.disableAnchor = true;
  1322. }
  1323. } else {
  1324. oneD.value = true;
  1325. meta2d.drawLine(meta2d.store.options.drawingLineName);
  1326. meta2d.store.options.disableAnchor = false;
  1327. }
  1328. if (alwaysD.value) {
  1329. meta2d.finishDrawLine();
  1330. meta2d.drawLine();
  1331. oneD.value = false;
  1332. alwaysD.value = false;
  1333. meta2d.store.options.disableAnchor = true;
  1334. }
  1335. };
  1336. const alwaysDraw = () => {
  1337. if(meta2d.canvas.pencil){
  1338. //关掉铅笔
  1339. pencil.value = false;
  1340. meta2d.stopPencil();
  1341. }
  1342. alwaysD.value = true;
  1343. meta2d.drawLine(meta2d.store.options.drawingLineName);
  1344. meta2d.store.options.disableAnchor = false;
  1345. };
  1346. const pencil = ref(false);
  1347. const onPencil = () => {
  1348. // 开了铅笔需要关掉钢笔
  1349. if(meta2d.canvas.drawingLineName){
  1350. meta2d.finishDrawLine();
  1351. meta2d.drawLine();
  1352. oneD.value = false;
  1353. alwaysD.value = false;
  1354. }
  1355. if (!meta2d.canvas.pencil) {
  1356. meta2d.drawingPencil();
  1357. } else {
  1358. meta2d.stopPencil();
  1359. }
  1360. pencil.value = meta2d.canvas.pencil;
  1361. }
  1362. const penAdd = (pen:Pen)=>{
  1363. // 画布新增一个pen,就需要根据当前主题调用setTheme
  1364. pen[0].setTheme && pen[0].setTheme(pen[0],meta2d.store.styles);
  1365. }
  1366. const lineAdd = (pens: Pen[]) => {
  1367. if (pens.length === 1 && pens[0].name === 'line') {
  1368. //连线类型
  1369. if (oneD.value && !alwaysD.value) {
  1370. if (meta2d.canvas.drawingLineName) {
  1371. oneD.value = false;
  1372. setTimeout(() => {
  1373. meta2d.finishDrawLine();
  1374. meta2d.drawLine();
  1375. meta2d.store.options.disableAnchor = true;
  1376. }, 100);
  1377. }
  1378. }
  1379. }
  1380. };
  1381. const onAddShape = (event: DragEvent | MouseEvent, name: string) => {
  1382. event.stopPropagation();
  1383. let data: any;
  1384. if (name === 'text') {
  1385. data = {
  1386. text: 'text',
  1387. width: 100,
  1388. height: 20,
  1389. name: 'text',
  1390. realTimes: [
  1391. {
  1392. label: '文字',
  1393. key: 'text',
  1394. type: 'string',
  1395. }
  1396. ]
  1397. };
  1398. } else if (name === 'line') {
  1399. data = {
  1400. anchors: [
  1401. { id: '0', x: 1, y: 0 },
  1402. { id: '1', x: 0, y: 1 },
  1403. ],
  1404. width: 100,
  1405. height: 100,
  1406. name: 'line',
  1407. lineName: 'line',
  1408. type: 1,
  1409. };
  1410. }
  1411. if (!(event as DragEvent).dataTransfer) {
  1412. meta2d.canvas.addCaches = deepClone([data]);
  1413. } else {
  1414. (event as DragEvent).dataTransfer?.setData('Meta2d', JSON.stringify(data));
  1415. }
  1416. };
  1417. const isLock = ref(0);
  1418. function onLock(lock: number) {
  1419. isLock.value = lock;
  1420. meta2d.lock(lock);
  1421. meta2d.hideInput();
  1422. }
  1423. const canScale = ref(true);
  1424. function onCanScale(can: boolean) {
  1425. canScale.value = can;
  1426. meta2d.setOptions({
  1427. disableScale: !can,
  1428. });
  1429. }
  1430. const preview = async () => {
  1431. meta2d.stopAnimate();
  1432. // @ts-ignore
  1433. const data: Meta2dBackData = meta2d.data();
  1434. checkData(data);
  1435. if (dot && user && data.id&&data.ownerId=== user.id) {
  1436. // 有 id ,是修改后保存 是自己的图纸
  1437. await save(SaveType.Save);
  1438. }
  1439. if (!data.id) {
  1440. await localforage.setItem(localStorageName, JSON.stringify(data));
  1441. }
  1442. // router.push({
  1443. // path: '/preview',
  1444. // query: {
  1445. // r: Date.now() + '',
  1446. // id: data._id,
  1447. // },
  1448. // });
  1449. // let screenWidth = window.screen.width;
  1450. // let screenHeight = window.screen.height;
  1451. let width = meta2d.store.data.width||meta2d.store.options.width||1920;
  1452. let height = meta2d.store.data.height||meta2d.store.options.height||1080;
  1453. let minScle = Math.min(window.innerWidth/width,window.innerHeight/height);
  1454. let url = import.meta.env.BASE_URL.slice(0, -1) + `/preview?r=${Date.now() + ''}`;
  1455. if (data.id) {
  1456. url += `&id=${data.id}`;
  1457. }
  1458. if(route.query.c||data.component){
  1459. url += '&c=1';
  1460. }
  1461. window.open(
  1462. url,
  1463. '',
  1464. `height=${minScle*height},width=${minScle*width},top=0,left=${(window.innerWidth-minScle*width)/2},toolbar=no,menubar=no, scrollbars=no,resizable=no,location=no, status=no`
  1465. );
  1466. };
  1467. const contextmenu = reactive<any>({
  1468. visible: false,
  1469. type: '',
  1470. style: {},
  1471. });
  1472. const onContextmenu = ({ e, rect }: { e: any; rect: any }) => {
  1473. contextmenu.type = '';
  1474. contextmenu.style = {
  1475. left: e.clientX + 'px',
  1476. top: e.clientY + 'px',
  1477. };
  1478. if (
  1479. meta2d.store.hoverAnchor &&
  1480. meta2d.canvas.hoverType === HoverType.LineAnchor
  1481. ) {
  1482. contextmenu.type = 'anchor';
  1483. if (document.body.clientHeight - e.clientY < 128) {
  1484. contextmenu.style = {
  1485. left: e.clientX + 'px',
  1486. bottom: '4px',
  1487. };
  1488. }
  1489. } else {
  1490. contextmenu.type = 'pen';
  1491. if (document.body.clientHeight - e.clientY < 450) {
  1492. contextmenu.style = {
  1493. left: e.clientX + 'px',
  1494. bottom: '4px',
  1495. };
  1496. }
  1497. }
  1498. if (contextmenu.type) {
  1499. contextmenu.visible = true;
  1500. } else {
  1501. contextmenu.visible = false;
  1502. }
  1503. };
  1504. const canvasClick = () => {
  1505. contextmenu.visible = false;
  1506. };
  1507. const changeContextMenuVisible = (e: boolean) => {
  1508. contextmenu.visible = e;
  1509. };
  1510. const networkColumns = ref([
  1511. {
  1512. colKey: 'name',
  1513. title: $t('名称'),
  1514. ellipsis: true,
  1515. width: 160,
  1516. },
  1517. {
  1518. colKey: 'protocol',
  1519. title: $t('通信方式'),
  1520. width: 120,
  1521. },
  1522. {
  1523. colKey: 'url',
  1524. title: $t('URL地址'),
  1525. ellipsis: true,
  1526. },
  1527. { colKey: 'actions', title: $t('操作'), width: 100 },
  1528. ]);
  1529. const onShowDataDialog = async () => {
  1530. dataDialog.input = '';
  1531. dataDialog.networks = meta2d.store.data.networks || [];
  1532. // @ts-ignore
  1533. dataDialog.dataset = meta2d.store.data.dataset || {};
  1534. dataDialog.datasetId = dataDialog.dataset.id;
  1535. // @ts-ignore
  1536. dataDialog.enableMock = meta2d.store.data.enableMock;
  1537. dataDialog.networkInterval = meta2d.store.data.networkInterval;
  1538. dataDialog.networkList = [];
  1539. dataDialog.datasetList = [];
  1540. dataDialog.editNetwork = false;
  1541. dataDialog.save = true;
  1542. dataDialog.show = true;
  1543. if(!dataDialog.datasetType){
  1544. dataDialog.datasetType = 1;
  1545. }
  1546. await getNetworks();
  1547. await getDatasets();
  1548. // onSelDataset(true);
  1549. };
  1550. const onFinishDataDialog = () => {
  1551. dataDialog.show = false;
  1552. if (dataDialog.networkInterval) {
  1553. meta2d.store.data.networkInterval = dataDialog.networkInterval;
  1554. }
  1555. meta2d.connectNetwork();
  1556. };
  1557. const onChangeMock = () => {
  1558. // @ts-ignore
  1559. meta2d.store.data.enableMock = dataDialog.enableMock;
  1560. };
  1561. const networkIntervalChange = (e) =>{
  1562. meta2d.store.data.networkInterval = e;
  1563. // meta2d.closeNetwork();
  1564. meta2d.connectNetwork();
  1565. }
  1566. const onSelectNetWork = (item: any) => {
  1567. const network: any = dataDialog.networks.find(
  1568. (elem: any) => item.id === elem.id
  1569. );
  1570. if (!network) {
  1571. dataDialog.networks.push(item);
  1572. meta2d.store.data.networks = toRaw(dataDialog.networks);
  1573. meta2d.connectNetwork();
  1574. setDot(true);
  1575. }
  1576. dataDialog.popupVisible = false;
  1577. };
  1578. const onDelNetWork = async (item: any, i: number) => {
  1579. const ret: any = await axios.post(`/api/data/datasource/delete`, {
  1580. id: item.id || item._id,
  1581. });
  1582. if (ret) {
  1583. dataDialog.networkList.splice(i, 1);
  1584. }
  1585. };
  1586. const onInputNetwork = () => {
  1587. debounce(getNetworks, 300);
  1588. };
  1589. // 请求我的实时数据
  1590. const getNetworks = async () => {
  1591. const ret: any = await axios.post(
  1592. `/api/data/datasource/list`,
  1593. {
  1594. // q: {
  1595. name: dataDialog.input,
  1596. // },
  1597. type: 'subscribe',
  1598. projection: "id,data,name,type",
  1599. },
  1600. {
  1601. params: {
  1602. current: 1,
  1603. pageSize: 10,
  1604. },
  1605. }
  1606. );
  1607. if (ret?.list) {
  1608. const list = [];
  1609. for (const item of ret.list) {
  1610. item.id = item.id || item._id;
  1611. list.push(transformData(item,'toMetaNetwork'));
  1612. }
  1613. dataDialog.networkList = list;
  1614. }
  1615. };
  1616. const onInputDatasets = (name: string) => {
  1617. debounce(getDatasets, 300, name);
  1618. };
  1619. // 请求我的数据模型
  1620. const getDatasets = async (name?: string) => {
  1621. const body: any = {
  1622. type: 'dataset',
  1623. projection: "id,data,name,type",
  1624. };
  1625. if (name) {
  1626. body.name = name;
  1627. }
  1628. const ret: any = await axios.post(`/api/data/datasource/list`, body, {
  1629. params: {
  1630. current: 1,
  1631. pageSize: 10,
  1632. },
  1633. });
  1634. if (ret?.list) {
  1635. const list = [];
  1636. let found = false;
  1637. for (const item of ret.list) {
  1638. item.id = item.id || item._id;
  1639. list.push(transformData(item,'toMetaNetwork'));
  1640. if (dataDialog.dataset?.id === item.id) {
  1641. found = true;
  1642. }
  1643. }
  1644. if (dataDialog.dataset?.id && !found) {
  1645. list.push(dataDialog.dataset);
  1646. }
  1647. dataDialog.datasetList = list;
  1648. }
  1649. };
  1650. const addNetwork = () => {
  1651. dataDialog.network = {
  1652. name: '',
  1653. type: 'subscribe',
  1654. protocol: 'mqtt',
  1655. url: '',
  1656. options: {
  1657. clientId: '',
  1658. username: '',
  1659. password: '',
  1660. customClientId: false,
  1661. },
  1662. };
  1663. dataDialog.editNetwork = 1;
  1664. };
  1665. const editNetwork = (data: any, index: number) => {
  1666. dataDialog.networkBak = data;
  1667. dataDialog.network = JSON.parse(JSON.stringify(data));
  1668. dataDialog.editNetwork = 2;
  1669. dataDialog.editNetworkIndex = index;
  1670. };
  1671. const deleteNetwork = (index: number) => {
  1672. dataDialog.networks.splice(index, 1);
  1673. meta2d.store.data.networks = toRaw(dataDialog.networks);
  1674. meta2d.connectNetwork();
  1675. setDot(true);
  1676. };
  1677. const onOkNetwork = async () => {
  1678. const data = transformData(dataDialog.network,'toNetwork');
  1679. if (dataDialog.editNetwork === 1) {
  1680. if(!dataDialog.network.url) {
  1681. MessagePlugin.error($t('URL地址不能为空!'));
  1682. return;
  1683. }
  1684. if(!dataDialog.network.name) {
  1685. MessagePlugin.error($t('名称不能为空!'));
  1686. return;
  1687. }
  1688. if (dataDialog.save) {
  1689. const ret: any = await axios.post(
  1690. `/api/data/datasource/add`,
  1691. data
  1692. );
  1693. if (!ret) {
  1694. return;
  1695. }
  1696. ret.id = ret.id || ret._id;
  1697. dataDialog.network.id = ret.id;
  1698. }
  1699. dataDialog.networks.push(dataDialog.network);
  1700. dataDialog.networkList.push(dataDialog.network);
  1701. } else if (dataDialog.editNetwork === 2) {
  1702. if (dataDialog.save) {
  1703. const ret: any = await axios.post(
  1704. `/api/data/datasource/update`,
  1705. data
  1706. );
  1707. if (!ret) {
  1708. return;
  1709. }
  1710. }
  1711. //替换
  1712. let index = dataDialog.editNetworkIndex;
  1713. if (index !== undefined) {
  1714. dataDialog.networks.splice(index, 1, dataDialog.network);
  1715. dataDialog.networkList.splice(index, 1, dataDialog.network);
  1716. }
  1717. }
  1718. dataDialog.editNetwork = false;
  1719. meta2d.store.data.networks = toRaw(dataDialog.networks);
  1720. meta2d.connectNetwork();
  1721. setDot(true);
  1722. delete dataDialog.networkBak;
  1723. };
  1724. const datasetColumns = ref([
  1725. // {
  1726. // colKey: 'device',
  1727. // title: '设备',
  1728. // ellipsis: true,
  1729. // },
  1730. {
  1731. colKey: 'label',
  1732. title: $t('显示名称'),
  1733. ellipsis: true,
  1734. },
  1735. {
  1736. colKey: 'id',
  1737. title: $t('变量名'),
  1738. ellipsis: true,
  1739. },
  1740. {
  1741. colKey: 'type',
  1742. title: $t('类型'),
  1743. ellipsis: true,
  1744. },
  1745. {
  1746. colKey: 'mock',
  1747. title: $t('值范围'),
  1748. ellipsis: true,
  1749. },
  1750. {
  1751. colKey: 'actions',
  1752. title: $t('操作'),
  1753. width: 100,
  1754. },
  1755. ]);
  1756. const importDataset = async () => {
  1757. let columns: any = [
  1758. // {
  1759. // header: $t('设备'),
  1760. // key: 'device',
  1761. // },
  1762. {
  1763. header: $t('显示名称'),
  1764. key: 'label',
  1765. },
  1766. {
  1767. header: $t('变量名'),
  1768. key: 'id',
  1769. },
  1770. {
  1771. header: $t('类型'),
  1772. key: 'type',
  1773. },
  1774. {
  1775. header: $t('值范围'),
  1776. key: 'mock',
  1777. },
  1778. ];
  1779. const data: any = await importExcel(columns);
  1780. // dataDialog.dataset.devices = data;
  1781. mergeDataset(dataDialog.dataset, data);
  1782. // modelValue.devices = data;
  1783. // emit('update:modelValue', modelValue);
  1784. // emit('change', modelValue);
  1785. };
  1786. const getDatas = async () => {
  1787. if (!dataDialog.dataset.url) {
  1788. return;
  1789. }
  1790. const ret = await axios.get(dataDialog.dataset.url);
  1791. let flattenRet = flattenTree(ret);
  1792. if (flattenRet) {
  1793. // dataDialog.dataset.devices = flattenRet;
  1794. mergeDataset(dataDialog.dataset,flattenRet);
  1795. }
  1796. };
  1797. //展开树
  1798. const flattenTree = (root) =>{
  1799. if (!root) return []; // 空树返回空数组
  1800. const result = []; // 存储展开后的数组
  1801. // 递归遍历树
  1802. function dfs(node) {
  1803. result.push({
  1804. id: node.id,
  1805. label: node.label||node.name,
  1806. device: node.device||node.id,
  1807. type: node.type,
  1808. mock: node.mock,
  1809. // children: node.children,
  1810. }); // 将当前节点值添加到结果数组
  1811. // 遍历当前节点的子节点
  1812. if(node.children){
  1813. for (let child of node.children) {
  1814. dfs(child); // 递归调用DFS
  1815. }
  1816. }
  1817. }
  1818. root.forEach((item) => {
  1819. dfs(item);
  1820. });
  1821. // dfs(root); // 从根节点开始遍历
  1822. return result;
  1823. }
  1824. const addDataDialog = reactive<any>({});
  1825. const showAddData = (row?: any, index?: number) => {
  1826. if (row) {
  1827. addDataDialog.header = '编辑数据';
  1828. addDataDialog.data = JSON.parse(JSON.stringify(row));
  1829. addDataDialog.index = index;
  1830. } else {
  1831. addDataDialog.header = $t('添加数据');
  1832. addDataDialog.data = { type: 'string' };
  1833. }
  1834. addDataDialog.show = true;
  1835. };
  1836. const clearData = () => {
  1837. dataDialog.datasetId = undefined;
  1838. dataDialog.dataset.id = undefined;
  1839. dataDialog.dataset.name = undefined;
  1840. dataDialog.dataset.url = undefined;
  1841. dataDialog.dataset.devices = [];
  1842. setDot(true);
  1843. }
  1844. const closeDataDialog = () => {
  1845. (meta2d.store.data as any).dataset = dataDialog.dataset;
  1846. dataDialog.show = false;
  1847. meta2d.connectNetwork();
  1848. }
  1849. const onOkAddData = () => {
  1850. if (!addDataDialog.data.label) {
  1851. MessagePlugin.error($t('请填写名称'));
  1852. return;
  1853. }
  1854. if (!addDataDialog.data.id) {
  1855. MessagePlugin.error($t('请填写数据ID'));
  1856. return;
  1857. }
  1858. if (addDataDialog.header === $t('添加数据')) {
  1859. dataDialog.dataset.devices.push(addDataDialog.data);
  1860. } else {
  1861. dataDialog.dataset.devices[addDataDialog.index] = addDataDialog.data;
  1862. //更新所有绑定该id的pen label
  1863. let binds = meta2d.store.bind[addDataDialog.data.id];
  1864. if (binds) {
  1865. binds.forEach((item) => {
  1866. const pen: Pen = meta2d.findOne(item.id);
  1867. pen.realTimes &&
  1868. pen.realTimes.forEach((_realTime) => {
  1869. if (_realTime.key === item.key) {
  1870. _realTime.bind.label = addDataDialog.data.label;
  1871. }
  1872. });
  1873. });
  1874. }
  1875. }
  1876. addDataDialog.show = false;
  1877. };
  1878. const changeDataID = (value) => {
  1879. if (!value) {
  1880. MessagePlugin.error($t('变量名不能为空!'));
  1881. return;
  1882. }
  1883. let item = dataDialog.dataset.devices.filter((item) => item.id === value);
  1884. if (item && item.length) {
  1885. MessagePlugin.error($t('变量名重复!'));
  1886. return;
  1887. }
  1888. addDataDialog.data.id = value;
  1889. };
  1890. const changeDataLabel = (value) => {
  1891. if (!value) {
  1892. MessagePlugin.error($t('显示名称不能为空!'));
  1893. return;
  1894. }
  1895. let item = dataDialog.dataset.devices.filter((item) => item.label === value);
  1896. if (item && item.length) {
  1897. MessagePlugin.error($t('显示名称重复!'));
  1898. return;
  1899. }
  1900. addDataDialog.data.label = value;
  1901. };
  1902. const addDataset = () => {
  1903. dataDialog.dataset = {
  1904. name: '',
  1905. type: 'dataset',
  1906. devices:[],
  1907. mode: 'api',
  1908. url: '',
  1909. };
  1910. dataDialog.editDataset = 1;
  1911. };
  1912. const editDataset = () => {
  1913. dataDialog.datasetBak = dataDialog.dataset;
  1914. dataDialog.dataset = JSON.parse(JSON.stringify(dataDialog.dataset));
  1915. dataDialog.editDataset = 2;
  1916. };
  1917. const backDataset = () => {
  1918. if (dataDialog.editDataset === 1 && !dataDialog.dataset._id) {
  1919. dataDialog.dataset = {};
  1920. }
  1921. dataDialog.datasetBak && (dataDialog.dataset = dataDialog.datasetBak);
  1922. dataDialog.dataset && (dataDialog.datasetId = dataDialog.dataset.id);
  1923. dataDialog.editDataset = 0;
  1924. };
  1925. const onOkDataset = async (saveas = false) => {
  1926. // if (!dataDialog.dataset.name) {
  1927. // MessagePlugin.error('名称不能为空');
  1928. // return;
  1929. // }
  1930. if(!(dataDialog.dataset.devices&&dataDialog.dataset.devices.length)){
  1931. MessagePlugin.error($t('变量列表不能为空'));
  1932. return;
  1933. }
  1934. const dataset = JSON.parse(JSON.stringify(dataDialog.dataset));
  1935. let data = dataset;
  1936. data.type = 'dataset';
  1937. if(!data.name){
  1938. data.name = meta2d.store.data.name;
  1939. }
  1940. data = transformData(dataset,'toNetwork');
  1941. // 保存到我的数据源
  1942. if (saveas || !dataset.id) {
  1943. delete dataset.id;
  1944. delete dataset._id;
  1945. dataset.type = 'dataset';
  1946. const ret: any = await axios.post(`/api/data/datasource/add`, data);
  1947. if (!ret) {
  1948. return;
  1949. }
  1950. ret.id = ret.id || ret._id;
  1951. dataDialog.datasetId = ret.id;
  1952. dataset.id = ret.id;
  1953. dataDialog.dataset.id = ret.id;
  1954. dataDialog.datasetList.push(dataset);
  1955. MessagePlugin.success($t('保存新增成功!'));
  1956. } else {
  1957. const ret: any = await axios.post(`/api/data/datasource/update`, data);
  1958. if (!ret) {
  1959. return;
  1960. }
  1961. dataDialog.datasetList.forEach((item: any, index: number) => {
  1962. if (item.id === dataset.id || (item._id === dataset._id && dataset._id != undefined)) {
  1963. dataDialog.datasetList.splice(index, 1, dataset);
  1964. }
  1965. });
  1966. MessagePlugin.success($t('保存更新成功!'));
  1967. }
  1968. delete dataset.devices;
  1969. // @ts-ignore
  1970. // console.log("dataset",dataset);
  1971. // meta2d.store.data.dataset = dataset;
  1972. // setDot(true);
  1973. dataDialog.editDataset = false;
  1974. delete dataDialog.datesetBak;
  1975. };
  1976. const downloadAsExcel = () => {
  1977. if(!(dataDialog.dataset.devices&&dataDialog.dataset.devices.length)){
  1978. MessagePlugin.error($t('变量列表不能为空!'));
  1979. return;
  1980. }
  1981. const name = meta2d.store.data.name;
  1982. const columns:any[] = [{
  1983. key: 'label',
  1984. header: $t('显示名称'),
  1985. },
  1986. {
  1987. key: 'id',
  1988. header: $t('变量名'),
  1989. },
  1990. {
  1991. key: 'type',
  1992. header: $t('类型'),
  1993. },
  1994. {
  1995. key: 'mock',
  1996. header: $t('值范围'),
  1997. }];
  1998. saveAsExcel(name,columns,dataDialog.dataset.devices);
  1999. }
  2000. const downloadAsJson = () => {
  2001. if(!(dataDialog.dataset.devices&&dataDialog.dataset.devices.length)){
  2002. MessagePlugin.error($t('变量列表不能为空!'));
  2003. return;
  2004. }
  2005. import('file-saver').then(({ saveAs }) => {
  2006. saveAs(
  2007. new Blob(
  2008. [JSON.stringify(dataDialog.dataset)],
  2009. {
  2010. type: 'text/plain;charset=utf-8',
  2011. }
  2012. ),
  2013. `${dataDialog.dataset.name || $t('未命名')}.json`
  2014. );
  2015. });
  2016. }
  2017. const onDelDataset = async (item: any, i: number) => {
  2018. const ret: any = await axios.post(`/api/data/datasource/delete`, {
  2019. id: item.id,
  2020. });
  2021. if (
  2022. (meta2d.store.data as any).dataset &&
  2023. (meta2d.store.data as any).dataset.id === item.id
  2024. ) {
  2025. //@ts-ignore
  2026. meta2d.store.data.dataset = {};
  2027. dataDialog.dataset = {};
  2028. dataDialog.datasetId = undefined;
  2029. }
  2030. if (ret) {
  2031. dataDialog.datasetList.splice(i, 1);
  2032. }
  2033. };
  2034. const onSelDataset = async (init = false) => {
  2035. if (dataDialog.datasetId) {
  2036. const dataset = dataDialog.datasetList.find((item: any) => {
  2037. return item.id === dataDialog.datasetId;
  2038. });
  2039. if (!dataset) {
  2040. return;
  2041. }
  2042. if (dataset.url) {
  2043. const ret = await axios.get(dataset.url);
  2044. if (ret) {
  2045. dataset.devices = ret;
  2046. }
  2047. } else {
  2048. const ret = await axios.post(`/api/data/datasource/get`, {
  2049. id: dataset.id,
  2050. });
  2051. if (ret?.data) {
  2052. Object.assign(dataset,{...ret.data});
  2053. }
  2054. }
  2055. mergeDataset(dataDialog.dataset,dataset.devices);
  2056. // dataDialog.dataset = dataset;
  2057. if (!init) {
  2058. const d = JSON.parse(JSON.stringify(dataset));
  2059. delete d.devices;
  2060. // @ts-ignore
  2061. meta2d.store.data.dataset = d;
  2062. setDot(true);
  2063. }
  2064. }
  2065. };
  2066. const registerLe5leTheme = ()=>{
  2067. fetch((cdn ? cdn + '/v' : import.meta.env.BASE_URL.slice(0, -1)) + '/theme/custom.json')
  2068. .then((r) => r.json())
  2069. .then((theme) => {
  2070. meta2d.registerTheme('custom',theme);
  2071. });
  2072. }
  2073. const mergeDataset = (arr1:any,arr2:any[]) => {
  2074. if(!(arr2&&arr2.length)){
  2075. return;
  2076. }
  2077. if(!arr1.devices){
  2078. arr1.devices = [];
  2079. }
  2080. arr2.forEach((item)=>{
  2081. let index = arr1.devices.findIndex((elem)=>elem.id === item.id);
  2082. if(index>=0){
  2083. Object.assign(arr1.devices[index],item);
  2084. }else{
  2085. arr1.devices.push(item);
  2086. }
  2087. });
  2088. }
  2089. const share = async () => {
  2090. if (!(user && user.id)) {
  2091. MessagePlugin.warning($t('请先登录!'));
  2092. return false;
  2093. }
  2094. if (!route.query.id) {
  2095. MessagePlugin.error($t('请先保存!'));
  2096. return;
  2097. }
  2098. if(route.query.c){
  2099. MessagePlugin.error($t('组件不允许分享!'));
  2100. return;
  2101. }
  2102. shareVisible.value = true;
  2103. };
  2104. let qrTimer: any;
  2105. const onEnterQrcode = () => {
  2106. if (!qrcode.visible && !qrTimer) {
  2107. qrTimer = setTimeout(() => {
  2108. qrTimer = undefined;
  2109. qrcode.visible = true;
  2110. }, 300);
  2111. }
  2112. };
  2113. const onLeaveQrcode = () => {
  2114. if (qrTimer) {
  2115. clearTimeout(qrTimer);
  2116. qrTimer = undefined;
  2117. }
  2118. };
  2119. const onShowPublish = async () => {
  2120. // @ts-ignore
  2121. publishDialog.name = meta2d.store.data.name;
  2122. publishDialog.status = '';
  2123. publishDialog.tips = '';
  2124. publishDialog.id = route.query.id + '';
  2125. publishDialog.show = true;
  2126. publishDialog.data = {
  2127. detail:''
  2128. };
  2129. const ret: any = await axios.post(`/api/domain/get`, {
  2130. id: publishDialog.id,
  2131. });
  2132. if (ret) {
  2133. if (ret.expired) {
  2134. const expired = new Date(ret.expired);
  2135. if (expired > new Date()) {
  2136. ret.isExpired = false;
  2137. } else if (expired > new Date('2023-01-17T08:00:00+08:00')) {
  2138. ret.isExpired = true;
  2139. } else {
  2140. ret.expired = undefined;
  2141. }
  2142. if (ret.expired) {
  2143. ret.expired = dayjs(ret.expired).format('YYYY-MM-DD HH:mm:ss');
  2144. }
  2145. }
  2146. publishDialog.data = ret;
  2147. makePublishQrcode();
  2148. }
  2149. };
  2150. const refreshSubdomain = async () => {
  2151. // publishDialog.data.subDomain = s8();
  2152. onChangeSubdomain(s8());
  2153. };
  2154. const onChangeSubdomain = async (value:string) => {
  2155. if (!value) {
  2156. publishDialog.status = 'error';
  2157. publishDialog.tips = $t('请填写子域名');
  2158. }
  2159. publishDialog.data.subDomain = value + `.v${rootDomain}`;
  2160. const ret: any = await axios.post(`/api/domain/exists`, {
  2161. subDomain: publishDialog.data.subDomain,
  2162. });
  2163. if (ret && ret.id) {
  2164. publishDialog.status = 'error';
  2165. publishDialog.tips = $t('已经存在相同子域名');
  2166. } else {
  2167. publishDialog.status = '';
  2168. publishDialog.tips = '';
  2169. }
  2170. if (
  2171. !publishDialog.data.domain ||
  2172. publishDialog.data.domain.indexOf(`.v${rootDomain}`) >= 0
  2173. ) {
  2174. publishDialog.data.domain = publishDialog.data.subDomain;
  2175. }
  2176. makePublishQrcode();
  2177. };
  2178. const onPublish = async () => {
  2179. if (publishDialog.status) {
  2180. return;
  2181. }
  2182. if (!publishDialog.data.subDomain) {
  2183. publishDialog.status = 'error';
  2184. publishDialog.tips = $t('请填写子域名');
  2185. }
  2186. if (!publishDialog.data.domain) {
  2187. publishDialog.data.domain = publishDialog.data.subDomain;
  2188. }
  2189. if(!route.query.id) {
  2190. MessagePlugin.warning($t('请选择将要发布的方案'));
  2191. return;
  2192. }
  2193. const ret: any = await axios.post(`/api/domain/set`, {
  2194. id: route.query.id,
  2195. subDomain: publishDialog.data.subDomain,
  2196. domain: publishDialog.data.domain,
  2197. });
  2198. if (ret) {
  2199. if (ret.expired) {
  2200. const expired = new Date(ret.expired);
  2201. if (expired > new Date()) {
  2202. ret.isExpired = false;
  2203. } else if (expired > new Date('2023-01-17T08:00:00+08:00')) {
  2204. ret.isExpired = true;
  2205. } else {
  2206. ret.expired = undefined;
  2207. }
  2208. if (ret.expired) {
  2209. ret.expired = dayjs(ret.expired).format('YYYY-MM-DD HH:mm:ss');
  2210. }
  2211. }
  2212. publishDialog.data = ret;
  2213. makePublishQrcode();
  2214. }
  2215. };
  2216. const onCancelPublish = async () => {
  2217. const ret: any = await axios.post(`/api/domain/remove`, {
  2218. id: route.query.id,
  2219. });
  2220. onShowPublish();
  2221. }
  2222. const makePublishQrcode = async () => {
  2223. const qr: any = await QRCode.toDataURL(`http://${publishDialog.data.domain}`);
  2224. publishDialog.url = qr;
  2225. };
  2226. const onSuccessChargeCloud = () => {
  2227. publishChargeDialog.show = false;
  2228. onShowPublish();
  2229. };
  2230. const theme = computed(() => {
  2231. return localStorage.getItem('theme') || 'dark';
  2232. });
  2233. const fitFlag = ref(false);
  2234. const changeFit = () => {
  2235. fitFlag.value = !fitFlag.value;
  2236. if(fitFlag.value){
  2237. meta2d.canvas.showFit();
  2238. }else{
  2239. meta2d.store.data.pens.forEach((pen) => {
  2240. if (!selections.fit.children?.includes(pen.id)) {
  2241. meta2d.setValue(
  2242. { id: pen.id, visible: true },
  2243. { render: false, doEvent: false, history: false }
  2244. );
  2245. }
  2246. });
  2247. meta2d.canvas.hideFit();
  2248. meta2d.canvas.canvasImage.init();
  2249. meta2d.canvas.canvasImageBottom.init();
  2250. meta2d.render();
  2251. select();
  2252. }
  2253. }
  2254. const replaceDialog = reactive<any>({
  2255. show:false,
  2256. list:[],
  2257. current:1,
  2258. pageSize:15,
  2259. total:0,
  2260. collection:'v',
  2261. select:{}
  2262. });
  2263. const replaceList = reactive([
  2264. {
  2265. key:'v',
  2266. label:$t('大屏')
  2267. },
  2268. {
  2269. key:'3d',
  2270. label:'3D'
  2271. },
  2272. {
  2273. key:'2d',
  2274. label:'2D'
  2275. },
  2276. ]);
  2277. const replaceScene = ()=>{
  2278. replaceDialog.show = true;
  2279. sceneChange('v');
  2280. }
  2281. const sceneChange = async(e?:any) => {
  2282. let collection = e;
  2283. if(!collection){
  2284. collection = replaceDialog.collection;
  2285. }else{
  2286. replaceDialog.collection = e;
  2287. replaceDialog.current = 1;
  2288. }
  2289. const data = {
  2290. // template:false
  2291. };
  2292. // if(collection === '3d'){
  2293. // delete data.template;
  2294. // }
  2295. const config = {
  2296. params: {
  2297. current: replaceDialog.current,
  2298. pageSize: replaceDialog.pageSize,
  2299. },
  2300. };
  2301. //2.请求所有图纸/组件数据
  2302. const res: any = await getCollectionList(collection, data, config);
  2303. replaceDialog.list = res.list;
  2304. replaceDialog.total = res.total;
  2305. }
  2306. const pageChange = (e) => {
  2307. replaceDialog.current = e.current;
  2308. replaceDialog.pageSize = e.pageSize;
  2309. sceneChange();
  2310. }
  2311. const selectScene = (_item) => {
  2312. replaceDialog.select = _item;
  2313. replaceDialog.select.collection = replaceDialog.collection;
  2314. }
  2315. const onReplace = ()=>{
  2316. let id = meta2d.store.active[0].id;
  2317. let url =location.origin+ `/view`;
  2318. meta2d.setValue({
  2319. id:id,
  2320. iframe:`${url}/${replaceDialog.select.collection}/?id=${replaceDialog.select.id}`,
  2321. thumbImg:replaceDialog.select.image
  2322. });
  2323. replaceDialog.show = false;
  2324. meta2d.inactive();
  2325. setTimeout(()=>{
  2326. meta2d.active(meta2d.find(id))
  2327. },10)
  2328. }
  2329. </script>
  2330. <style lang="postcss" scoped>
  2331. .meta2d {
  2332. display: flex;
  2333. flex-direction: column;
  2334. background-color:#080b0f;
  2335. border-left: 1px solid var(--color-border);
  2336. .tools {
  2337. display: flex;
  2338. font-size: 12px;
  2339. background-color: var(--color-background);
  2340. height: 40px;
  2341. flex-shrink: 0;
  2342. padding: 0 12px;
  2343. /* z-index: 2; */
  2344. overflow-x: scroll;
  2345. overflow-y: hidden;
  2346. border-bottom: 1px solid var(--color-background-editor);
  2347. a {
  2348. display: flex;
  2349. align-items: center;
  2350. /* height: 100%; */
  2351. padding: 6px;
  2352. margin: 4px;
  2353. border-radius: 4px;
  2354. color: var(--color);
  2355. text-decoration: none;
  2356. &:hover{
  2357. background-color: var(--color-background-views-hover);
  2358. color: var(--color) !important;
  2359. }
  2360. /* .l-icon {
  2361. width: 16px;
  2362. height: 16px;
  2363. } */
  2364. /* &:hover {
  2365. color: var(--color-primary);
  2366. } */
  2367. svg{
  2368. width: 16px ;
  2369. height: 16px;
  2370. &:hover{
  2371. color: var(--color) !important;
  2372. }
  2373. }
  2374. font-size: 16px;
  2375. }
  2376. .a-1{
  2377. svg{
  2378. width: 16px;
  2379. height: 16px ;
  2380. }
  2381. }
  2382. .t-icon {
  2383. font-size: 16px;
  2384. }
  2385. .l-icon {
  2386. font-size: 18px;
  2387. width: 18px ;
  2388. height: 18px ;
  2389. }
  2390. }
  2391. .share-primary{
  2392. color: var(--color-primary) !important;
  2393. background-color:#4480F929;
  2394. }
  2395. #meta2d {
  2396. /* border-top: 1px solid var(--color-background-input); */
  2397. height: calc(100vh - 81px);
  2398. /* height: calc(100% - 40px); */
  2399. /* height: 100%; */
  2400. z-index: 1;
  2401. overflow: hidden;
  2402. :deep(.meta2d-map) {
  2403. background: var(--color-background);
  2404. }
  2405. }
  2406. }
  2407. .select-options{
  2408. .t-popup__content{
  2409. /* width: 240px !important; */
  2410. }
  2411. }
  2412. :deep(.t-dialog__ctx){
  2413. z-index:100;
  2414. .watermark-span{
  2415. color: var(--color-primary);
  2416. cursor: pointer;
  2417. &:hover{
  2418. color: var(--color-primary-hover);
  2419. }
  2420. }
  2421. }
  2422. :deep(.project-dialog){
  2423. .t-dialog__body{
  2424. .box-list{
  2425. flex-wrap: wrap;
  2426. padding:8px;
  2427. margin-bottom:12px;
  2428. background-color: var(--color-background-active);
  2429. overflow:scroll;
  2430. max-height:375px;
  2431. .box{
  2432. width:125px;
  2433. height:110px;
  2434. padding:8px;
  2435. .box-img{
  2436. width:100%;
  2437. height:70px;
  2438. }
  2439. /* .title{
  2440. text-align:center;
  2441. white-space: nowrap;
  2442. overflow: hidden;
  2443. text-overflow:ellipsis;
  2444. font-size:12px;
  2445. color: var(--td-text-color-secondary);
  2446. } */
  2447. &:hover{
  2448. border-radius: 4px;
  2449. border:1px solid var(--color-primary);
  2450. }
  2451. }
  2452. .item-title{
  2453. text-align:center;
  2454. white-space: nowrap;
  2455. overflow: hidden;
  2456. text-overflow:ellipsis;
  2457. font-size:12px;
  2458. color: var(--td-text-color-secondary);
  2459. }
  2460. .active{
  2461. border-radius: 4px;
  2462. border:1px solid var(--color-primary);
  2463. }
  2464. }
  2465. }
  2466. }
  2467. </style>