View.vue 79 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600
  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('opened', openedListener);
  960. meta2d.on('undo', patchFlag);
  961. meta2d.on('redo', patchFlag);
  962. meta2d.on('add', patchFlag);
  963. meta2d.on('delete', patchFlag);
  964. meta2d.on('rotatePens', patchFlag);
  965. meta2d.on('translatePens', patchFlag);
  966. // 所有编辑栏所做修改
  967. meta2d.on('components-update-value', patchFlag);
  968. meta2d.on('contextmenu', onContextmenu);
  969. meta2d.on('click', canvasClick);
  970. timer = setInterval(autoSave, 60000);
  971. window.onbeforeunload = () => {
  972. autoSave();
  973. };
  974. });
  975. onUnmounted(()=>{
  976. meta2d.off('active', active);
  977. meta2d.off('inactive', inactive);
  978. meta2d.off('fit',fit);
  979. meta2d.off('scale', scaleSubscriber);
  980. meta2d.off('add', lineAdd);
  981. meta2d.off('opened', openedListener);
  982. meta2d.off('undo', patchFlag);
  983. meta2d.off('redo', patchFlag);
  984. meta2d.off('add', patchFlag);
  985. meta2d.off('delete', patchFlag);
  986. meta2d.off('rotatePens', patchFlag);
  987. meta2d.off('translatePens', patchFlag);
  988. // 所有编辑栏所做修改
  989. meta2d.off('components-update-value', patchFlag);
  990. meta2d.off('contextmenu', onContextmenu);
  991. meta2d.off('click', canvasClick);
  992. // meta2d.off('business-showPayDiagram',showPayDiagram);
  993. })
  994. const watcher = watch(
  995. () => route.query,
  996. async () => {
  997. open();
  998. }
  999. );
  1000. //TODO 打开图纸
  1001. const open = async (flag: boolean = false) => {
  1002. if(route.query.token||route.query['x-token']){
  1003. parseSearchToken();
  1004. // setCookie('token', route.query.token + '', {
  1005. // path: '/',
  1006. // domain: getDomain(),
  1007. // });
  1008. getUser();
  1009. const newQuery = { ...route.query };
  1010. delete newQuery.token;
  1011. delete newQuery['x-token'];
  1012. router.replace({
  1013. path: '/',
  1014. query: newQuery,
  1015. });
  1016. return;
  1017. }
  1018. // if(route.query.saveas){
  1019. // //id需要
  1020. // await autoSaveAS((route.query.id)as string);
  1021. // return;
  1022. // }
  1023. if (route.query.id) {
  1024. let ret: any;
  1025. if (route.query.c) {
  1026. ret = await getComponents(route.query.id + '');
  1027. } else {
  1028. ret = await getLe5leV(route.query.id + '',undefined , route.query.historyId as string);
  1029. }
  1030. if (ret) {
  1031. if (!(ret.data.pens && ret.data.pens.length)) {
  1032. //获取不到pen说明是parse svg
  1033. MessagePlugin.warning($t('解析的svg图元不允许编辑!'));
  1034. newFile();
  1035. return;
  1036. }
  1037. ret.data.id = ret.id || route.query.id;;
  1038. ret.data.folder = ret.folder;
  1039. ret.data.name = ret.name;
  1040. ret.data.image = ret.image;
  1041. ret.data.ownerId = ret.ownerId;
  1042. ret.data.ownerName = ret.ownerName;
  1043. ret.data.case = ret.case;
  1044. ret.data.isSystem = ret.system;
  1045. ret.data.isTemplate = ret.template;
  1046. if(!ret.data.background){
  1047. ret.data.background = '#1e2430';
  1048. }
  1049. if(!ret.data.color){
  1050. ret.data.color = '#bdc7db';
  1051. }
  1052. if(!ret.data.width){ret.data.width= 1920};
  1053. if(!ret.data.height){ret.data.height= 1080};
  1054. meta2d.open(ret.data);
  1055. if (!route.query.c) {
  1056. shared.value = ret.shared;
  1057. const qr: any = await QRCode.toDataURL(
  1058. `https://view2d${rootDomain}/?id=${route.query.id + '&tag=v'}`
  1059. );
  1060. qrcode.url = qr;
  1061. }
  1062. }
  1063. } else if (flag) {
  1064. const data: any =JSON.parse(await localforage.getItem(localStorageName));
  1065. if(!data){
  1066. meta2d.open({
  1067. name: $t('新建项目'),
  1068. pens: [],
  1069. background: '#1e2430',
  1070. color: '#bdc7db',
  1071. width:1920,
  1072. height:1080,
  1073. enableMock: true,
  1074. folder: route.query.folder,
  1075. tags: route.query.tags ? [route.query.tags] : null,
  1076. } as any);
  1077. }else{
  1078. if(!data.background){
  1079. data.background = '#1e2430';
  1080. }
  1081. if(!data.color){
  1082. data.color = '#bdc7db';
  1083. }
  1084. if(!data.width){data.width= 1920};
  1085. if(!data.height){data.height= 1080};
  1086. if (data) {
  1087. meta2d.open(data);
  1088. }
  1089. }
  1090. } else if (!sessionStorage.getItem('opening')) {
  1091. meta2d.open({
  1092. name: $t('新建项目'),
  1093. pens: [],
  1094. background: '#1e2430',
  1095. color: '#bdc7db',
  1096. width:1920,
  1097. height:1080,
  1098. enableMock: true,
  1099. folder: route.query.folder,
  1100. tags: route.query.tags ? [route.query.tags] : null,
  1101. } as any);
  1102. }
  1103. sessionStorage.removeItem('opening');
  1104. !meta2d.store.data.x && (meta2d.store.data.x = meta2d.store.options.x || 0);
  1105. !meta2d.store.data.y && (meta2d.store.data.y = meta2d.store.options.y || 0);
  1106. };
  1107. const openedListener = () => {
  1108. const {
  1109. locked,
  1110. scale: canvasScale,
  1111. fromArrow: canvasFromArrow,
  1112. toArrow: canvasToArrow,
  1113. } = meta2d.store.data;
  1114. isLock.value = locked || 0;
  1115. scale.value = Math.round(canvasScale * 100);
  1116. fromArrow.value = canvasFromArrow || '';
  1117. toArrow.value = canvasToArrow || '';
  1118. deal2DToV();
  1119. meta2d.centerView();
  1120. meta2d.canvas.hideFit();
  1121. fitFlag.value = false;
  1122. };
  1123. const deal2DToV = ()=>{
  1124. if(!meta2d.store.data.width||!meta2d.store.data.height){
  1125. let rect = meta2d.getRect();
  1126. if(!meta2d.store.data.pens.length){
  1127. return;
  1128. }
  1129. let scale = meta2d.store.data.scale;
  1130. if(!(meta2d.store.data as any).oldV&&Math.abs(rect.width/scale-1920)<5&&Math.abs(rect.height/scale-1080)<5){ //1920 1080
  1131. //大致估算范围是大屏默认范围
  1132. return;
  1133. }
  1134. let origin = meta2d.store.data.origin;
  1135. if(rect.width/scale > 1920 || rect.height/scale > 1080){
  1136. //超出大屏默认范围
  1137. meta2d.store.data.width = rect.width/scale;
  1138. meta2d.store.data.height = rect.height/scale;
  1139. }
  1140. meta2d.store.data.pens.forEach((pen)=>{
  1141. if(pen.locked){
  1142. pen.locked = 0;
  1143. }
  1144. });
  1145. let pens = meta2d.store.data.pens.filter((pen)=>!pen.parentId);
  1146. meta2d.canvas.opening = false;
  1147. meta2d.translatePens(pens,origin.x - rect.x,origin.y - rect.y);
  1148. meta2d.store.data.pens.forEach((pen)=>{
  1149. if(!pen.type){
  1150. meta2d.canvas.updateLines(pen);
  1151. }
  1152. });
  1153. meta2d.render(true);
  1154. }
  1155. }
  1156. const patchFlag = () => {
  1157. setDot();
  1158. };
  1159. onUnmounted(() => {
  1160. clearInterval(timer);
  1161. watcher();
  1162. if (meta2d) {
  1163. meta2d.destroy();
  1164. }
  1165. });
  1166. const inactive = () => {
  1167. if(fitFlag.value){
  1168. return;
  1169. }
  1170. select();
  1171. };
  1172. const active = (pens: Pen[]) => {
  1173. if(fitFlag.value){
  1174. return;
  1175. }
  1176. select(pens);
  1177. //格式刷处理
  1178. if (one.value || always.value) {
  1179. meta2d.formatPainter();
  1180. one.value = false;
  1181. }
  1182. };
  1183. const fit = (fit) => {
  1184. select(undefined, fit);
  1185. }
  1186. const one = ref(false);
  1187. const always = ref(false);
  1188. const oneFormat = () => {
  1189. if (one.value) {
  1190. one.value = false;
  1191. } else {
  1192. one.value = true;
  1193. meta2d.setFormatPainter();
  1194. }
  1195. if (always.value) {
  1196. always.value = false;
  1197. one.value = false;
  1198. }
  1199. };
  1200. const alwaysFormat = () => {
  1201. always.value = true;
  1202. };
  1203. const clearFormat = () => {
  1204. always.value = false;
  1205. one.value = false;
  1206. meta2d.clearFormatPainter();
  1207. };
  1208. const scale = ref(100);
  1209. const scaleSubscriber = (val: number) => {
  1210. scale.value = Math.round(val * 100);
  1211. };
  1212. const dataDialog = reactive<any>({
  1213. tab: 1,
  1214. });
  1215. const currentLineType = ref('curve');
  1216. const lineTypes = reactive([
  1217. { name: $t('曲线'), icon: '#l-curve2', value: 'curve' },
  1218. { name: $t('线段'), icon: '#l-polyline', value: 'polyline' },
  1219. { name: $t('直线'), icon: '#l-line', value: 'line' },
  1220. { name: $t('脑图曲线'), icon: '#l-mind', value: 'mind' },
  1221. ]);
  1222. const changeLineType = (value: string) => {
  1223. currentLineType.value = value;
  1224. if (meta2d) {
  1225. meta2d.store.options.drawingLineName = value;
  1226. meta2d.canvas.drawingLineName && (meta2d.canvas.drawingLineName = value);
  1227. meta2d.store.active?.forEach((pen) => {
  1228. meta2d.updateLineType(pen, value);
  1229. });
  1230. }
  1231. };
  1232. const fromArrow = ref('');
  1233. // const fromArrows = [
  1234. // { icon: '#l-line', value: '' },
  1235. // { icon: '#l-from-triangle', value: 'triangle' },
  1236. // { icon: '#l-from-diamond', value: 'diamond' },
  1237. // { icon: '#l-from-circle', value: 'circle' },
  1238. // { icon: '#l-from-lineDown', value: 'lineDown' },
  1239. // { icon: '#l-from-lineUp', value: 'lineUp' },
  1240. // { icon: '#l-from-triangleSolid', value: 'triangleSolid' },
  1241. // { icon: '#l-from-diamondSolid', value: 'diamondSolid' },
  1242. // { icon: '#l-from-circleSolid', value: 'circleSolid' },
  1243. // { icon: '#l-from-line', value: 'line' },
  1244. // ];
  1245. const toArrow = ref('');
  1246. // const toArrows = [
  1247. // { icon: '#l-line', value: '' },
  1248. // { icon: '#l-to-triangle', value: 'triangle' },
  1249. // { icon: '#l-to-diamond', value: 'diamond' },
  1250. // { icon: '#l-to-circle', value: 'circle' },
  1251. // { icon: '#l-to-lineDown', value: 'lineDown' },
  1252. // { icon: '#l-to-lineUp', value: 'lineUp' },
  1253. // { icon: '#l-to-triangleSolid', value: 'triangleSolid' },
  1254. // { icon: '#l-to-diamondSolid', value: 'diamondSolid' },
  1255. // { icon: '#l-to-circleSolid', value: 'circleSolid' },
  1256. // { icon: '#l-to-line', value: 'line' },
  1257. // ];
  1258. const changeFromArrow = (value: string) => {
  1259. fromArrow.value = value;
  1260. // 画布默认值
  1261. meta2d.store.data.fromArrow = value;
  1262. // 活动层的箭头都变化
  1263. if (meta2d.store.active) {
  1264. meta2d.store.active.forEach((pen: Pen) => {
  1265. if (pen.type === PenType.Line) {
  1266. pen.fromArrow = value;
  1267. meta2d.setValue(
  1268. {
  1269. id: pen.id,
  1270. fromArrow: pen.fromArrow,
  1271. },
  1272. {
  1273. render: false,
  1274. }
  1275. );
  1276. }
  1277. });
  1278. meta2d.render();
  1279. }
  1280. };
  1281. const changeToArrow = (value: string) => {
  1282. toArrow.value = value;
  1283. // 画布默认值
  1284. meta2d.store.data.toArrow = value;
  1285. // 活动层的箭头都变化
  1286. if (meta2d.store.active) {
  1287. meta2d.store.active.forEach((pen: Pen) => {
  1288. if (pen.type === PenType.Line) {
  1289. pen.toArrow = value;
  1290. meta2d.setValue(
  1291. {
  1292. id: pen.id,
  1293. toArrow: pen.toArrow,
  1294. },
  1295. {
  1296. render: false,
  1297. }
  1298. );
  1299. }
  1300. });
  1301. meta2d.render();
  1302. }
  1303. };
  1304. const oneD = ref<boolean>(false);
  1305. const alwaysD = ref<boolean>(false);
  1306. const oneDraw = () => {
  1307. if(meta2d.canvas.pencil){
  1308. //关掉铅笔
  1309. pencil.value = false;
  1310. meta2d.stopPencil();
  1311. }
  1312. if (oneD.value) {
  1313. oneD.value = false;
  1314. if (!alwaysD.value) {
  1315. meta2d.finishDrawLine();
  1316. meta2d.drawLine();
  1317. meta2d.store.options.disableAnchor = true;
  1318. }
  1319. } else {
  1320. oneD.value = true;
  1321. meta2d.drawLine(meta2d.store.options.drawingLineName);
  1322. meta2d.store.options.disableAnchor = false;
  1323. }
  1324. if (alwaysD.value) {
  1325. meta2d.finishDrawLine();
  1326. meta2d.drawLine();
  1327. oneD.value = false;
  1328. alwaysD.value = false;
  1329. meta2d.store.options.disableAnchor = true;
  1330. }
  1331. };
  1332. const alwaysDraw = () => {
  1333. if(meta2d.canvas.pencil){
  1334. //关掉铅笔
  1335. pencil.value = false;
  1336. meta2d.stopPencil();
  1337. }
  1338. alwaysD.value = true;
  1339. meta2d.drawLine(meta2d.store.options.drawingLineName);
  1340. meta2d.store.options.disableAnchor = false;
  1341. };
  1342. const pencil = ref(false);
  1343. const onPencil = () => {
  1344. // 开了铅笔需要关掉钢笔
  1345. if(meta2d.canvas.drawingLineName){
  1346. meta2d.finishDrawLine();
  1347. meta2d.drawLine();
  1348. oneD.value = false;
  1349. alwaysD.value = false;
  1350. }
  1351. if (!meta2d.canvas.pencil) {
  1352. meta2d.drawingPencil();
  1353. } else {
  1354. meta2d.stopPencil();
  1355. }
  1356. pencil.value = meta2d.canvas.pencil;
  1357. }
  1358. const lineAdd = (pens: Pen[]) => {
  1359. if (pens.length === 1 && pens[0].name === 'line') {
  1360. //连线类型
  1361. if (oneD.value && !alwaysD.value) {
  1362. if (meta2d.canvas.drawingLineName) {
  1363. oneD.value = false;
  1364. setTimeout(() => {
  1365. meta2d.finishDrawLine();
  1366. meta2d.drawLine();
  1367. meta2d.store.options.disableAnchor = true;
  1368. }, 100);
  1369. }
  1370. }
  1371. }
  1372. };
  1373. const onAddShape = (event: DragEvent | MouseEvent, name: string) => {
  1374. event.stopPropagation();
  1375. let data: any;
  1376. if (name === 'text') {
  1377. data = {
  1378. text: 'text',
  1379. width: 100,
  1380. height: 20,
  1381. name: 'text',
  1382. };
  1383. } else if (name === 'line') {
  1384. data = {
  1385. anchors: [
  1386. { id: '0', x: 1, y: 0 },
  1387. { id: '1', x: 0, y: 1 },
  1388. ],
  1389. width: 100,
  1390. height: 100,
  1391. name: 'line',
  1392. lineName: 'line',
  1393. type: 1,
  1394. };
  1395. }
  1396. if (!(event as DragEvent).dataTransfer) {
  1397. meta2d.canvas.addCaches = deepClone([data]);
  1398. } else {
  1399. (event as DragEvent).dataTransfer?.setData('Meta2d', JSON.stringify(data));
  1400. }
  1401. };
  1402. const isLock = ref(0);
  1403. function onLock(lock: number) {
  1404. isLock.value = lock;
  1405. meta2d.lock(lock);
  1406. meta2d.hideInput();
  1407. }
  1408. const canScale = ref(true);
  1409. function onCanScale(can: boolean) {
  1410. canScale.value = can;
  1411. meta2d.setOptions({
  1412. disableScale: !can,
  1413. });
  1414. }
  1415. const preview = async () => {
  1416. meta2d.stopAnimate();
  1417. // @ts-ignore
  1418. const data: Meta2dBackData = meta2d.data();
  1419. checkData(data);
  1420. if (dot && user && data.id&&data.ownerId=== user.id) {
  1421. // 有 id ,是修改后保存 是自己的图纸
  1422. await save(SaveType.Save);
  1423. }
  1424. if (!data.id) {
  1425. await localforage.setItem(localStorageName, JSON.stringify(data));
  1426. }
  1427. // router.push({
  1428. // path: '/preview',
  1429. // query: {
  1430. // r: Date.now() + '',
  1431. // id: data._id,
  1432. // },
  1433. // });
  1434. // let screenWidth = window.screen.width;
  1435. // let screenHeight = window.screen.height;
  1436. let width = meta2d.store.data.width||meta2d.store.options.width||1920;
  1437. let height = meta2d.store.data.height||meta2d.store.options.height||1080;
  1438. let minScle = Math.min(window.innerWidth/width,window.innerHeight/height);
  1439. let url = import.meta.env.BASE_URL.slice(0, -1) + `/preview?r=${Date.now() + ''}`;
  1440. if (data.id) {
  1441. url += `&id=${data.id}`;
  1442. }
  1443. if(route.query.c||data.component){
  1444. url += '&c=1';
  1445. }
  1446. window.open(
  1447. url,
  1448. '',
  1449. `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`
  1450. );
  1451. };
  1452. const contextmenu = reactive<any>({
  1453. visible: false,
  1454. type: '',
  1455. style: {},
  1456. });
  1457. const onContextmenu = ({ e, rect }: { e: any; rect: any }) => {
  1458. contextmenu.type = '';
  1459. contextmenu.style = {
  1460. left: e.clientX + 'px',
  1461. top: e.clientY + 'px',
  1462. };
  1463. if (
  1464. meta2d.store.hoverAnchor &&
  1465. meta2d.canvas.hoverType === HoverType.LineAnchor
  1466. ) {
  1467. contextmenu.type = 'anchor';
  1468. if (document.body.clientHeight - e.clientY < 128) {
  1469. contextmenu.style = {
  1470. left: e.clientX + 'px',
  1471. bottom: '4px',
  1472. };
  1473. }
  1474. } else {
  1475. contextmenu.type = 'pen';
  1476. if (document.body.clientHeight - e.clientY < 450) {
  1477. contextmenu.style = {
  1478. left: e.clientX + 'px',
  1479. bottom: '4px',
  1480. };
  1481. }
  1482. }
  1483. if (contextmenu.type) {
  1484. contextmenu.visible = true;
  1485. } else {
  1486. contextmenu.visible = false;
  1487. }
  1488. };
  1489. const canvasClick = () => {
  1490. contextmenu.visible = false;
  1491. };
  1492. const changeContextMenuVisible = (e: boolean) => {
  1493. contextmenu.visible = e;
  1494. };
  1495. const networkColumns = ref([
  1496. {
  1497. colKey: 'name',
  1498. title: $t('名称'),
  1499. ellipsis: true,
  1500. width: 160,
  1501. },
  1502. {
  1503. colKey: 'protocol',
  1504. title: $t('通信方式'),
  1505. width: 120,
  1506. },
  1507. {
  1508. colKey: 'url',
  1509. title: $t('URL地址'),
  1510. ellipsis: true,
  1511. },
  1512. { colKey: 'actions', title: $t('操作'), width: 100 },
  1513. ]);
  1514. const onShowDataDialog = async () => {
  1515. dataDialog.input = '';
  1516. dataDialog.networks = meta2d.store.data.networks || [];
  1517. // @ts-ignore
  1518. dataDialog.dataset = meta2d.store.data.dataset || {};
  1519. dataDialog.datasetId = dataDialog.dataset.id;
  1520. // @ts-ignore
  1521. dataDialog.enableMock = meta2d.store.data.enableMock;
  1522. dataDialog.networkInterval = meta2d.store.data.networkInterval;
  1523. dataDialog.networkList = [];
  1524. dataDialog.datasetList = [];
  1525. dataDialog.editNetwork = false;
  1526. dataDialog.save = true;
  1527. dataDialog.show = true;
  1528. if(!dataDialog.datasetType){
  1529. dataDialog.datasetType = 1;
  1530. }
  1531. await getNetworks();
  1532. await getDatasets();
  1533. // onSelDataset(true);
  1534. };
  1535. const onFinishDataDialog = () => {
  1536. dataDialog.show = false;
  1537. if (dataDialog.networkInterval) {
  1538. meta2d.store.data.networkInterval = dataDialog.networkInterval;
  1539. }
  1540. meta2d.connectNetwork();
  1541. };
  1542. const onChangeMock = () => {
  1543. // @ts-ignore
  1544. meta2d.store.data.enableMock = dataDialog.enableMock;
  1545. };
  1546. const networkIntervalChange = (e) =>{
  1547. meta2d.store.data.networkInterval = e;
  1548. // meta2d.closeNetwork();
  1549. meta2d.connectNetwork();
  1550. }
  1551. const onSelectNetWork = (item: any) => {
  1552. const network: any = dataDialog.networks.find(
  1553. (elem: any) => item.id === elem.id
  1554. );
  1555. if (!network) {
  1556. dataDialog.networks.push(item);
  1557. meta2d.store.data.networks = toRaw(dataDialog.networks);
  1558. meta2d.connectNetwork();
  1559. setDot(true);
  1560. }
  1561. dataDialog.popupVisible = false;
  1562. };
  1563. const onDelNetWork = async (item: any, i: number) => {
  1564. const ret: any = await axios.post(`/api/data/datasource/delete`, {
  1565. id: item.id || item._id,
  1566. });
  1567. if (ret) {
  1568. dataDialog.networkList.splice(i, 1);
  1569. }
  1570. };
  1571. const onInputNetwork = () => {
  1572. debounce(getNetworks, 300);
  1573. };
  1574. // 请求我的实时数据
  1575. const getNetworks = async () => {
  1576. const ret: any = await axios.post(
  1577. `/api/data/datasource/list`,
  1578. {
  1579. // q: {
  1580. name: dataDialog.input,
  1581. // },
  1582. type: 'subscribe',
  1583. projection: "id,data,name,type",
  1584. },
  1585. {
  1586. params: {
  1587. current: 1,
  1588. pageSize: 10,
  1589. },
  1590. }
  1591. );
  1592. if (ret?.list) {
  1593. const list = [];
  1594. for (const item of ret.list) {
  1595. item.id = item.id || item._id;
  1596. list.push(transformData(item,'toMetaNetwork'));
  1597. }
  1598. dataDialog.networkList = list;
  1599. }
  1600. };
  1601. const onInputDatasets = (name: string) => {
  1602. debounce(getDatasets, 300, name);
  1603. };
  1604. // 请求我的数据模型
  1605. const getDatasets = async (name?: string) => {
  1606. const body: any = {
  1607. type: 'dataset',
  1608. projection: "id,data,name,type",
  1609. };
  1610. if (name) {
  1611. body.name = name;
  1612. }
  1613. const ret: any = await axios.post(`/api/data/datasource/list`, body, {
  1614. params: {
  1615. current: 1,
  1616. pageSize: 10,
  1617. },
  1618. });
  1619. if (ret?.list) {
  1620. const list = [];
  1621. let found = false;
  1622. for (const item of ret.list) {
  1623. item.id = item.id || item._id;
  1624. list.push(transformData(item,'toMetaNetwork'));
  1625. if (dataDialog.dataset?.id === item.id) {
  1626. found = true;
  1627. }
  1628. }
  1629. if (dataDialog.dataset?.id && !found) {
  1630. list.push(dataDialog.dataset);
  1631. }
  1632. dataDialog.datasetList = list;
  1633. }
  1634. };
  1635. const addNetwork = () => {
  1636. dataDialog.network = {
  1637. name: '',
  1638. type: 'subscribe',
  1639. protocol: 'mqtt',
  1640. url: '',
  1641. options: {
  1642. clientId: '',
  1643. username: '',
  1644. password: '',
  1645. customClientId: false,
  1646. },
  1647. };
  1648. dataDialog.editNetwork = 1;
  1649. };
  1650. const editNetwork = (data: any, index: number) => {
  1651. dataDialog.networkBak = data;
  1652. dataDialog.network = JSON.parse(JSON.stringify(data));
  1653. dataDialog.editNetwork = 2;
  1654. dataDialog.editNetworkIndex = index;
  1655. };
  1656. const deleteNetwork = (index: number) => {
  1657. dataDialog.networks.splice(index, 1);
  1658. meta2d.store.data.networks = toRaw(dataDialog.networks);
  1659. meta2d.connectNetwork();
  1660. setDot(true);
  1661. };
  1662. const onOkNetwork = async () => {
  1663. const data = transformData(dataDialog.network,'toNetwork');
  1664. if (dataDialog.editNetwork === 1) {
  1665. if(!dataDialog.network.url) {
  1666. MessagePlugin.error($t('URL地址不能为空!'));
  1667. return;
  1668. }
  1669. if(!dataDialog.network.name) {
  1670. MessagePlugin.error($t('名称不能为空!'));
  1671. return;
  1672. }
  1673. if (dataDialog.save) {
  1674. const ret: any = await axios.post(
  1675. `/api/data/datasource/add`,
  1676. data
  1677. );
  1678. if (!ret) {
  1679. return;
  1680. }
  1681. ret.id = ret.id || ret._id;
  1682. dataDialog.network.id = ret.id;
  1683. }
  1684. dataDialog.networks.push(dataDialog.network);
  1685. dataDialog.networkList.push(dataDialog.network);
  1686. } else if (dataDialog.editNetwork === 2) {
  1687. if (dataDialog.save) {
  1688. const ret: any = await axios.post(
  1689. `/api/data/datasource/update`,
  1690. data
  1691. );
  1692. if (!ret) {
  1693. return;
  1694. }
  1695. }
  1696. //替换
  1697. let index = dataDialog.editNetworkIndex;
  1698. if (index !== undefined) {
  1699. dataDialog.networks.splice(index, 1, dataDialog.network);
  1700. dataDialog.networkList.splice(index, 1, dataDialog.network);
  1701. }
  1702. }
  1703. dataDialog.editNetwork = false;
  1704. meta2d.store.data.networks = toRaw(dataDialog.networks);
  1705. meta2d.connectNetwork();
  1706. setDot(true);
  1707. delete dataDialog.networkBak;
  1708. };
  1709. const datasetColumns = ref([
  1710. // {
  1711. // colKey: 'device',
  1712. // title: '设备',
  1713. // ellipsis: true,
  1714. // },
  1715. {
  1716. colKey: 'label',
  1717. title: $t('显示名称'),
  1718. ellipsis: true,
  1719. },
  1720. {
  1721. colKey: 'id',
  1722. title: $t('变量名'),
  1723. ellipsis: true,
  1724. },
  1725. {
  1726. colKey: 'type',
  1727. title: $t('类型'),
  1728. ellipsis: true,
  1729. },
  1730. {
  1731. colKey: 'mock',
  1732. title: $t('值范围'),
  1733. ellipsis: true,
  1734. },
  1735. {
  1736. colKey: 'actions',
  1737. title: $t('操作'),
  1738. width: 100,
  1739. },
  1740. ]);
  1741. const importDataset = async () => {
  1742. let columns: any = [
  1743. // {
  1744. // header: $t('设备'),
  1745. // key: 'device',
  1746. // },
  1747. {
  1748. header: $t('显示名称'),
  1749. key: 'label',
  1750. },
  1751. {
  1752. header: $t('变量名'),
  1753. key: 'id',
  1754. },
  1755. {
  1756. header: $t('类型'),
  1757. key: 'type',
  1758. },
  1759. {
  1760. header: $t('值范围'),
  1761. key: 'mock',
  1762. },
  1763. ];
  1764. const data: any = await importExcel(columns);
  1765. // dataDialog.dataset.devices = data;
  1766. mergeDataset(dataDialog.dataset, data);
  1767. // modelValue.devices = data;
  1768. // emit('update:modelValue', modelValue);
  1769. // emit('change', modelValue);
  1770. };
  1771. const getDatas = async () => {
  1772. if (!dataDialog.dataset.url) {
  1773. return;
  1774. }
  1775. const ret = await axios.get(dataDialog.dataset.url);
  1776. let flattenRet = flattenTree(ret);
  1777. if (flattenRet) {
  1778. // dataDialog.dataset.devices = flattenRet;
  1779. mergeDataset(dataDialog.dataset,flattenRet);
  1780. }
  1781. };
  1782. //展开树
  1783. const flattenTree = (root) =>{
  1784. if (!root) return []; // 空树返回空数组
  1785. const result = []; // 存储展开后的数组
  1786. // 递归遍历树
  1787. function dfs(node) {
  1788. result.push({
  1789. id: node.id,
  1790. label: node.label||node.name,
  1791. device: node.device||node.id,
  1792. type: node.type,
  1793. mock: node.mock,
  1794. // children: node.children,
  1795. }); // 将当前节点值添加到结果数组
  1796. // 遍历当前节点的子节点
  1797. if(node.children){
  1798. for (let child of node.children) {
  1799. dfs(child); // 递归调用DFS
  1800. }
  1801. }
  1802. }
  1803. root.forEach((item) => {
  1804. dfs(item);
  1805. });
  1806. // dfs(root); // 从根节点开始遍历
  1807. return result;
  1808. }
  1809. const addDataDialog = reactive<any>({});
  1810. const showAddData = (row?: any, index?: number) => {
  1811. if (row) {
  1812. addDataDialog.header = '编辑数据';
  1813. addDataDialog.data = JSON.parse(JSON.stringify(row));
  1814. addDataDialog.index = index;
  1815. } else {
  1816. addDataDialog.header = $t('添加数据');
  1817. addDataDialog.data = { type: 'string' };
  1818. }
  1819. addDataDialog.show = true;
  1820. };
  1821. const clearData = () => {
  1822. dataDialog.datasetId = undefined;
  1823. dataDialog.dataset.id = undefined;
  1824. dataDialog.dataset.name = undefined;
  1825. dataDialog.dataset.url = undefined;
  1826. dataDialog.dataset.devices = [];
  1827. setDot(true);
  1828. }
  1829. const closeDataDialog = () => {
  1830. (meta2d.store.data as any).dataset = dataDialog.dataset;
  1831. dataDialog.show = false;
  1832. meta2d.connectNetwork();
  1833. }
  1834. const onOkAddData = () => {
  1835. if (!addDataDialog.data.label) {
  1836. MessagePlugin.error($t('请填写名称'));
  1837. return;
  1838. }
  1839. if (!addDataDialog.data.id) {
  1840. MessagePlugin.error($t('请填写数据ID'));
  1841. return;
  1842. }
  1843. if (addDataDialog.header === $t('添加数据')) {
  1844. dataDialog.dataset.devices.push(addDataDialog.data);
  1845. } else {
  1846. dataDialog.dataset.devices[addDataDialog.index] = addDataDialog.data;
  1847. //更新所有绑定该id的pen label
  1848. let binds = meta2d.store.bind[addDataDialog.data.id];
  1849. if (binds) {
  1850. binds.forEach((item) => {
  1851. const pen: Pen = meta2d.findOne(item.id);
  1852. pen.realTimes &&
  1853. pen.realTimes.forEach((_realTime) => {
  1854. if (_realTime.key === item.key) {
  1855. _realTime.bind.label = addDataDialog.data.label;
  1856. }
  1857. });
  1858. });
  1859. }
  1860. }
  1861. addDataDialog.show = false;
  1862. };
  1863. const changeDataID = (value) => {
  1864. if (!value) {
  1865. MessagePlugin.error($t('变量名不能为空!'));
  1866. return;
  1867. }
  1868. let item = dataDialog.dataset.devices.filter((item) => item.id === value);
  1869. if (item && item.length) {
  1870. MessagePlugin.error($t('变量名重复!'));
  1871. return;
  1872. }
  1873. addDataDialog.data.id = value;
  1874. };
  1875. const changeDataLabel = (value) => {
  1876. if (!value) {
  1877. MessagePlugin.error($t('显示名称不能为空!'));
  1878. return;
  1879. }
  1880. let item = dataDialog.dataset.devices.filter((item) => item.label === value);
  1881. if (item && item.length) {
  1882. MessagePlugin.error($t('显示名称重复!'));
  1883. return;
  1884. }
  1885. addDataDialog.data.label = value;
  1886. };
  1887. const addDataset = () => {
  1888. dataDialog.dataset = {
  1889. name: '',
  1890. type: 'dataset',
  1891. devices:[],
  1892. mode: 'api',
  1893. url: '',
  1894. };
  1895. dataDialog.editDataset = 1;
  1896. };
  1897. const editDataset = () => {
  1898. dataDialog.datasetBak = dataDialog.dataset;
  1899. dataDialog.dataset = JSON.parse(JSON.stringify(dataDialog.dataset));
  1900. dataDialog.editDataset = 2;
  1901. };
  1902. const backDataset = () => {
  1903. if (dataDialog.editDataset === 1 && !dataDialog.dataset._id) {
  1904. dataDialog.dataset = {};
  1905. }
  1906. dataDialog.datasetBak && (dataDialog.dataset = dataDialog.datasetBak);
  1907. dataDialog.dataset && (dataDialog.datasetId = dataDialog.dataset.id);
  1908. dataDialog.editDataset = 0;
  1909. };
  1910. const onOkDataset = async (saveas = false) => {
  1911. // if (!dataDialog.dataset.name) {
  1912. // MessagePlugin.error('名称不能为空');
  1913. // return;
  1914. // }
  1915. if(!(dataDialog.dataset.devices&&dataDialog.dataset.devices.length)){
  1916. MessagePlugin.error($t('变量列表不能为空'));
  1917. return;
  1918. }
  1919. const dataset = JSON.parse(JSON.stringify(dataDialog.dataset));
  1920. let data = dataset;
  1921. data.type = 'dataset';
  1922. if(!data.name){
  1923. data.name = meta2d.store.data.name;
  1924. }
  1925. data = transformData(dataset,'toNetwork');
  1926. // 保存到我的数据源
  1927. if (saveas || !dataset.id) {
  1928. delete dataset.id;
  1929. delete dataset._id;
  1930. dataset.type = 'dataset';
  1931. const ret: any = await axios.post(`/api/data/datasource/add`, data);
  1932. if (!ret) {
  1933. return;
  1934. }
  1935. ret.id = ret.id || ret._id;
  1936. dataDialog.datasetId = ret.id;
  1937. dataset.id = ret.id;
  1938. dataDialog.dataset.id = ret.id;
  1939. dataDialog.datasetList.push(dataset);
  1940. MessagePlugin.success($t('保存新增成功!'));
  1941. } else {
  1942. const ret: any = await axios.post(`/api/data/datasource/update`, data);
  1943. if (!ret) {
  1944. return;
  1945. }
  1946. dataDialog.datasetList.forEach((item: any, index: number) => {
  1947. if (item.id === dataset.id || (item._id === dataset._id && dataset._id != undefined)) {
  1948. dataDialog.datasetList.splice(index, 1, dataset);
  1949. }
  1950. });
  1951. MessagePlugin.success($t('保存更新成功!'));
  1952. }
  1953. delete dataset.devices;
  1954. // @ts-ignore
  1955. // console.log("dataset",dataset);
  1956. // meta2d.store.data.dataset = dataset;
  1957. // setDot(true);
  1958. dataDialog.editDataset = false;
  1959. delete dataDialog.datesetBak;
  1960. };
  1961. const downloadAsExcel = () => {
  1962. if(!(dataDialog.dataset.devices&&dataDialog.dataset.devices.length)){
  1963. MessagePlugin.error($t('变量列表不能为空!'));
  1964. return;
  1965. }
  1966. const name = meta2d.store.data.name;
  1967. const columns:any[] = [{
  1968. key: 'label',
  1969. header: $t('显示名称'),
  1970. },
  1971. {
  1972. key: 'id',
  1973. header: $t('变量名'),
  1974. },
  1975. {
  1976. key: 'type',
  1977. header: $t('类型'),
  1978. },
  1979. {
  1980. key: 'mock',
  1981. header: $t('值范围'),
  1982. }];
  1983. saveAsExcel(name,columns,dataDialog.dataset.devices);
  1984. }
  1985. const downloadAsJson = () => {
  1986. if(!(dataDialog.dataset.devices&&dataDialog.dataset.devices.length)){
  1987. MessagePlugin.error($t('变量列表不能为空!'));
  1988. return;
  1989. }
  1990. import('file-saver').then(({ saveAs }) => {
  1991. saveAs(
  1992. new Blob(
  1993. [JSON.stringify(dataDialog.dataset)],
  1994. {
  1995. type: 'text/plain;charset=utf-8',
  1996. }
  1997. ),
  1998. `${dataDialog.dataset.name || $t('未命名')}.json`
  1999. );
  2000. });
  2001. }
  2002. const onDelDataset = async (item: any, i: number) => {
  2003. const ret: any = await axios.post(`/api/data/datasource/delete`, {
  2004. id: item.id,
  2005. });
  2006. if (
  2007. (meta2d.store.data as any).dataset &&
  2008. (meta2d.store.data as any).dataset.id === item.id
  2009. ) {
  2010. //@ts-ignore
  2011. meta2d.store.data.dataset = {};
  2012. dataDialog.dataset = {};
  2013. dataDialog.datasetId = undefined;
  2014. }
  2015. if (ret) {
  2016. dataDialog.datasetList.splice(i, 1);
  2017. }
  2018. };
  2019. const onSelDataset = async (init = false) => {
  2020. if (dataDialog.datasetId) {
  2021. const dataset = dataDialog.datasetList.find((item: any) => {
  2022. return item.id === dataDialog.datasetId;
  2023. });
  2024. if (!dataset) {
  2025. return;
  2026. }
  2027. if (dataset.url) {
  2028. const ret = await axios.get(dataset.url);
  2029. if (ret) {
  2030. dataset.devices = ret;
  2031. }
  2032. } else {
  2033. const ret = await axios.post(`/api/data/datasource/get`, {
  2034. id: dataset.id,
  2035. });
  2036. if (ret?.data) {
  2037. Object.assign(dataset,{...ret.data});
  2038. }
  2039. }
  2040. mergeDataset(dataDialog.dataset,dataset.devices);
  2041. // dataDialog.dataset = dataset;
  2042. if (!init) {
  2043. const d = JSON.parse(JSON.stringify(dataset));
  2044. delete d.devices;
  2045. // @ts-ignore
  2046. meta2d.store.data.dataset = d;
  2047. setDot(true);
  2048. }
  2049. }
  2050. };
  2051. const mergeDataset = (arr1:any,arr2:any[]) => {
  2052. if(!(arr2&&arr2.length)){
  2053. return;
  2054. }
  2055. if(!arr1.devices){
  2056. arr1.devices = [];
  2057. }
  2058. arr2.forEach((item)=>{
  2059. let index = arr1.devices.findIndex((elem)=>elem.id === item.id);
  2060. if(index>=0){
  2061. Object.assign(arr1.devices[index],item);
  2062. }else{
  2063. arr1.devices.push(item);
  2064. }
  2065. });
  2066. }
  2067. const share = async () => {
  2068. if (!(user && user.id)) {
  2069. MessagePlugin.warning($t('请先登录!'));
  2070. return false;
  2071. }
  2072. if (!route.query.id) {
  2073. MessagePlugin.error($t('请先保存!'));
  2074. return;
  2075. }
  2076. if(route.query.c){
  2077. MessagePlugin.error($t('组件不允许分享!'));
  2078. return;
  2079. }
  2080. shareVisible.value = true;
  2081. };
  2082. let qrTimer: any;
  2083. const onEnterQrcode = () => {
  2084. if (!qrcode.visible && !qrTimer) {
  2085. qrTimer = setTimeout(() => {
  2086. qrTimer = undefined;
  2087. qrcode.visible = true;
  2088. }, 300);
  2089. }
  2090. };
  2091. const onLeaveQrcode = () => {
  2092. if (qrTimer) {
  2093. clearTimeout(qrTimer);
  2094. qrTimer = undefined;
  2095. }
  2096. };
  2097. const onShowPublish = async () => {
  2098. // @ts-ignore
  2099. publishDialog.name = meta2d.store.data.name;
  2100. publishDialog.status = '';
  2101. publishDialog.tips = '';
  2102. publishDialog.id = route.query.id + '';
  2103. publishDialog.show = true;
  2104. publishDialog.data = {
  2105. detail:''
  2106. };
  2107. const ret: any = await axios.post(`/api/domain/get`, {
  2108. id: publishDialog.id,
  2109. });
  2110. if (ret) {
  2111. if (ret.expired) {
  2112. const expired = new Date(ret.expired);
  2113. if (expired > new Date()) {
  2114. ret.isExpired = false;
  2115. } else if (expired > new Date('2023-01-17T08:00:00+08:00')) {
  2116. ret.isExpired = true;
  2117. } else {
  2118. ret.expired = undefined;
  2119. }
  2120. if (ret.expired) {
  2121. ret.expired = dayjs(ret.expired).format('YYYY-MM-DD HH:mm:ss');
  2122. }
  2123. }
  2124. publishDialog.data = ret;
  2125. makePublishQrcode();
  2126. }
  2127. };
  2128. const refreshSubdomain = async () => {
  2129. // publishDialog.data.subDomain = s8();
  2130. onChangeSubdomain(s8());
  2131. };
  2132. const onChangeSubdomain = async (value:string) => {
  2133. if (!value) {
  2134. publishDialog.status = 'error';
  2135. publishDialog.tips = $t('请填写子域名');
  2136. }
  2137. publishDialog.data.subDomain = value + `.v${rootDomain}`;
  2138. const ret: any = await axios.post(`/api/domain/exists`, {
  2139. subDomain: publishDialog.data.subDomain,
  2140. });
  2141. if (ret && ret.id) {
  2142. publishDialog.status = 'error';
  2143. publishDialog.tips = $t('已经存在相同子域名');
  2144. } else {
  2145. publishDialog.status = '';
  2146. publishDialog.tips = '';
  2147. }
  2148. if (
  2149. !publishDialog.data.domain ||
  2150. publishDialog.data.domain.indexOf(`.v${rootDomain}`) >= 0
  2151. ) {
  2152. publishDialog.data.domain = publishDialog.data.subDomain;
  2153. }
  2154. makePublishQrcode();
  2155. };
  2156. const onPublish = async () => {
  2157. if (publishDialog.status) {
  2158. return;
  2159. }
  2160. if (!publishDialog.data.subDomain) {
  2161. publishDialog.status = 'error';
  2162. publishDialog.tips = $t('请填写子域名');
  2163. }
  2164. if (!publishDialog.data.domain) {
  2165. publishDialog.data.domain = publishDialog.data.subDomain;
  2166. }
  2167. if(!route.query.id) {
  2168. MessagePlugin.warning($t('请选择将要发布的方案'));
  2169. return;
  2170. }
  2171. const ret: any = await axios.post(`/api/domain/set`, {
  2172. id: route.query.id,
  2173. subDomain: publishDialog.data.subDomain,
  2174. domain: publishDialog.data.domain,
  2175. });
  2176. if (ret) {
  2177. if (ret.expired) {
  2178. const expired = new Date(ret.expired);
  2179. if (expired > new Date()) {
  2180. ret.isExpired = false;
  2181. } else if (expired > new Date('2023-01-17T08:00:00+08:00')) {
  2182. ret.isExpired = true;
  2183. } else {
  2184. ret.expired = undefined;
  2185. }
  2186. if (ret.expired) {
  2187. ret.expired = dayjs(ret.expired).format('YYYY-MM-DD HH:mm:ss');
  2188. }
  2189. }
  2190. publishDialog.data = ret;
  2191. makePublishQrcode();
  2192. }
  2193. };
  2194. const onCancelPublish = async () => {
  2195. const ret: any = await axios.post(`/api/domain/remove`, {
  2196. id: route.query.id,
  2197. });
  2198. onShowPublish();
  2199. }
  2200. const makePublishQrcode = async () => {
  2201. const qr: any = await QRCode.toDataURL(`http://${publishDialog.data.domain}`);
  2202. publishDialog.url = qr;
  2203. };
  2204. const onSuccessChargeCloud = () => {
  2205. publishChargeDialog.show = false;
  2206. onShowPublish();
  2207. };
  2208. const theme = computed(() => {
  2209. return localStorage.getItem('theme') || 'dark';
  2210. });
  2211. const fitFlag = ref(false);
  2212. const changeFit = () => {
  2213. fitFlag.value = !fitFlag.value;
  2214. if(fitFlag.value){
  2215. meta2d.canvas.showFit();
  2216. }else{
  2217. meta2d.store.data.pens.forEach((pen) => {
  2218. if (!selections.fit.children?.includes(pen.id)) {
  2219. meta2d.setValue(
  2220. { id: pen.id, visible: true },
  2221. { render: false, doEvent: false, history: false }
  2222. );
  2223. }
  2224. });
  2225. meta2d.canvas.hideFit();
  2226. meta2d.canvas.canvasImage.init();
  2227. meta2d.canvas.canvasImageBottom.init();
  2228. meta2d.render();
  2229. select();
  2230. }
  2231. }
  2232. const replaceDialog = reactive<any>({
  2233. show:false,
  2234. list:[],
  2235. current:1,
  2236. pageSize:15,
  2237. total:0,
  2238. collection:'v',
  2239. select:{}
  2240. });
  2241. const replaceList = reactive([
  2242. {
  2243. key:'v',
  2244. label:$t('大屏')
  2245. },
  2246. {
  2247. key:'3d',
  2248. label:'3D'
  2249. },
  2250. {
  2251. key:'2d',
  2252. label:'2D'
  2253. },
  2254. ]);
  2255. const replaceScene = ()=>{
  2256. replaceDialog.show = true;
  2257. sceneChange('v');
  2258. }
  2259. const sceneChange = async(e?:any) => {
  2260. let collection = e;
  2261. if(!collection){
  2262. collection = replaceDialog.collection;
  2263. }else{
  2264. replaceDialog.collection = e;
  2265. replaceDialog.current = 1;
  2266. }
  2267. const data = {
  2268. // template:false
  2269. };
  2270. // if(collection === '3d'){
  2271. // delete data.template;
  2272. // }
  2273. const config = {
  2274. params: {
  2275. current: replaceDialog.current,
  2276. pageSize: replaceDialog.pageSize,
  2277. },
  2278. };
  2279. //2.请求所有图纸/组件数据
  2280. const res: any = await getCollectionList(collection, data, config);
  2281. replaceDialog.list = res.list;
  2282. replaceDialog.total = res.total;
  2283. }
  2284. const pageChange = (e) => {
  2285. replaceDialog.current = e.current;
  2286. replaceDialog.pageSize = e.pageSize;
  2287. sceneChange();
  2288. }
  2289. const selectScene = (_item) => {
  2290. replaceDialog.select = _item;
  2291. replaceDialog.select.collection = replaceDialog.collection;
  2292. }
  2293. const onReplace = ()=>{
  2294. let id = meta2d.store.active[0].id;
  2295. let url =location.origin+ `/view`;
  2296. meta2d.setValue({
  2297. id:id,
  2298. iframe:`${url}/${replaceDialog.select.collection}/?id=${replaceDialog.select.id}`,
  2299. thumbImg:replaceDialog.select.image
  2300. });
  2301. replaceDialog.show = false;
  2302. meta2d.inactive();
  2303. setTimeout(()=>{
  2304. meta2d.active(meta2d.find(id))
  2305. },10)
  2306. }
  2307. </script>
  2308. <style lang="postcss" scoped>
  2309. .meta2d {
  2310. display: flex;
  2311. flex-direction: column;
  2312. background-color:#080b0f;
  2313. border-left: 1px solid var(--color-border);
  2314. .tools {
  2315. display: flex;
  2316. font-size: 12px;
  2317. background-color: var(--color-background);
  2318. height: 40px;
  2319. flex-shrink: 0;
  2320. padding: 0 12px;
  2321. /* z-index: 2; */
  2322. overflow-x: scroll;
  2323. overflow-y: hidden;
  2324. border-bottom: 1px solid var(--color-background-editor);
  2325. a {
  2326. display: flex;
  2327. align-items: center;
  2328. /* height: 100%; */
  2329. padding: 6px;
  2330. margin: 4px;
  2331. border-radius: 4px;
  2332. color: var(--color);
  2333. text-decoration: none;
  2334. &:hover{
  2335. background-color: var(--color-background-views-hover);
  2336. color: var(--color) !important;
  2337. }
  2338. /* .l-icon {
  2339. width: 16px;
  2340. height: 16px;
  2341. } */
  2342. /* &:hover {
  2343. color: var(--color-primary);
  2344. } */
  2345. svg{
  2346. width: 16px ;
  2347. height: 16px;
  2348. &:hover{
  2349. color: var(--color) !important;
  2350. }
  2351. }
  2352. font-size: 16px;
  2353. }
  2354. .a-1{
  2355. svg{
  2356. width: 16px;
  2357. height: 16px ;
  2358. }
  2359. }
  2360. .t-icon {
  2361. font-size: 16px;
  2362. }
  2363. .l-icon {
  2364. font-size: 18px;
  2365. width: 18px ;
  2366. height: 18px ;
  2367. }
  2368. }
  2369. .share-primary{
  2370. color: var(--color-primary) !important;
  2371. background-color:#4480F929;
  2372. }
  2373. #meta2d {
  2374. /* border-top: 1px solid var(--color-background-input); */
  2375. height: calc(100vh - 81px);
  2376. /* height: calc(100% - 40px); */
  2377. /* height: 100%; */
  2378. z-index: 1;
  2379. overflow: hidden;
  2380. :deep(.meta2d-map) {
  2381. background: var(--color-background);
  2382. }
  2383. }
  2384. }
  2385. .select-options{
  2386. .t-popup__content{
  2387. /* width: 240px !important; */
  2388. }
  2389. }
  2390. :deep(.t-dialog__ctx){
  2391. z-index:100;
  2392. .watermark-span{
  2393. color: var(--color-primary);
  2394. cursor: pointer;
  2395. &:hover{
  2396. color: var(--color-primary-hover);
  2397. }
  2398. }
  2399. }
  2400. :deep(.project-dialog){
  2401. .t-dialog__body{
  2402. .box-list{
  2403. flex-wrap: wrap;
  2404. padding:8px;
  2405. margin-bottom:12px;
  2406. background-color: var(--color-background-active);
  2407. overflow:scroll;
  2408. max-height:375px;
  2409. .box{
  2410. width:125px;
  2411. height:110px;
  2412. padding:8px;
  2413. .box-img{
  2414. width:100%;
  2415. height:70px;
  2416. }
  2417. /* .title{
  2418. text-align:center;
  2419. white-space: nowrap;
  2420. overflow: hidden;
  2421. text-overflow:ellipsis;
  2422. font-size:12px;
  2423. color: var(--td-text-color-secondary);
  2424. } */
  2425. &:hover{
  2426. border-radius: 4px;
  2427. border:1px solid var(--color-primary);
  2428. }
  2429. }
  2430. .item-title{
  2431. text-align:center;
  2432. white-space: nowrap;
  2433. overflow: hidden;
  2434. text-overflow:ellipsis;
  2435. font-size:12px;
  2436. color: var(--td-text-color-secondary);
  2437. }
  2438. .active{
  2439. border-radius: 4px;
  2440. border:1px solid var(--color-primary);
  2441. }
  2442. }
  2443. }
  2444. }
  2445. </style>