Header.vue 73 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663
  1. <template>
  2. <div class="app-header">
  3. <a class="logo" :href="enterprise.home" target="_blank">
  4. <img src="/favicon.ico" />
  5. <span> {{ enterprise.name }}</span>
  6. </a>
  7. <t-dropdown
  8. :minColumnWidth="200"
  9. :maxHeight="560"
  10. :delay2="[10, 150]"
  11. overlayClassName="header-dropdown"
  12. trigger1="click"
  13. >
  14. <a> 文件 </a>
  15. <t-dropdown-menu>
  16. <t-dropdown-item @click="newFile">
  17. <a>新建文件</a>
  18. </t-dropdown-item>
  19. <t-dropdown-item @click="load(true)">
  20. <a>打开文件</a>
  21. </t-dropdown-item>
  22. <t-dropdown-item divider="true" @click="load">
  23. <a>导入文件</a>
  24. </t-dropdown-item>
  25. <t-dropdown-item>
  26. <a @click="save()">保存</a>
  27. </t-dropdown-item>
  28. <t-dropdown-item>
  29. <a @click="save(SaveType.SaveAs, '', undefined, 1)">另保存</a>
  30. </t-dropdown-item>
  31. <t-dropdown-item divider="true">
  32. <a @click="downloadJson">下载JSON文件</a>
  33. </t-dropdown-item>
  34. <t-dropdown-item>
  35. <a @click="downloadZip">
  36. <div class="flex">
  37. 导出为ZIP文件 <span class="flex-grow"></span>
  38. <span><label>企</label></span>
  39. </div>
  40. </a>
  41. </t-dropdown-item>
  42. <t-dropdown-item>
  43. <a @click="downloadHtml">
  44. <div class="flex">
  45. 下载离线部署包 <span class="flex-grow"></span>
  46. <span><label>企</label></span>
  47. </div>
  48. </a>
  49. </t-dropdown-item>
  50. <t-dropdown-item>
  51. <a @click="downloadVue3">
  52. <div class="flex">
  53. 下载Vue3组件包 <span class="flex-grow"></span>
  54. <span><label>企</label></span>
  55. </div>
  56. </a>
  57. </t-dropdown-item>
  58. <t-dropdown-item>
  59. <a @click="downloadVue2">
  60. <div class="flex">
  61. 下载Vue2组件包 <span class="flex-grow"></span>
  62. <span><label>企</label></span>
  63. </div>
  64. </a>
  65. </t-dropdown-item>
  66. <t-dropdown-item divider="true">
  67. <a @click="downloadReact">
  68. <div class="flex">
  69. 下载React组件包 <span class="flex-grow"></span>
  70. <span><label>企</label></span>
  71. </div>
  72. </a>
  73. </t-dropdown-item>
  74. <t-dropdown-item>
  75. <a @click="downloadPng">下载为PNG</a>
  76. </t-dropdown-item>
  77. <t-dropdown-item divider="true">
  78. <a @click="downloadSvg">下载为SVG</a>
  79. </t-dropdown-item>
  80. <t-dropdown-item>
  81. <a @click="switchTheme('light')">明亮主题</a>
  82. </t-dropdown-item>
  83. <t-dropdown-item>
  84. <a @click="switchTheme('dark')">暗黑主题</a>
  85. </t-dropdown-item>
  86. </t-dropdown-menu>
  87. </t-dropdown>
  88. <t-dropdown
  89. :minColumnWidth="180"
  90. :maxHeight="500"
  91. :delay2="[10, 150]"
  92. overlayClassName="header-dropdown"
  93. >
  94. <a> 编辑 </a>
  95. <t-dropdown-menu>
  96. <t-dropdown-item>
  97. <a @click="onUndo">
  98. <div class="flex">
  99. 撤销 <span class="flex-grow"></span> Ctrl + Z
  100. </div>
  101. </a>
  102. </t-dropdown-item>
  103. <t-dropdown-item divider="true">
  104. <a @click="onRedo">
  105. <div class="flex">
  106. 恢复 <span class="flex-grow"></span> Ctrl + Y
  107. </div>
  108. </a>
  109. </t-dropdown-item>
  110. <t-dropdown-item>
  111. <a @click="onCut">
  112. <div class="flex">
  113. 剪切 <span class="flex-grow"></span> Ctrl + X
  114. </div>
  115. </a>
  116. </t-dropdown-item>
  117. <t-dropdown-item>
  118. <a @click="onCopy">
  119. <div class="flex">
  120. 复制 <span class="flex-grow"></span> Ctrl + C
  121. </div>
  122. </a>
  123. </t-dropdown-item>
  124. <t-dropdown-item divider="true">
  125. <a @click="onPaste">
  126. <div class="flex">
  127. 粘贴 <span class="flex-grow"></span> Ctrl + V
  128. </div>
  129. </a>
  130. </t-dropdown-item>
  131. <t-dropdown-item>
  132. <a @click="onAll">
  133. <div class="flex">
  134. 全选 <span class="flex-grow"></span> Ctrl + A
  135. </div>
  136. </a>
  137. </t-dropdown-item>
  138. <t-dropdown-item>
  139. <a @click="onDelete">
  140. <div class="flex">删除 <span class="flex-grow"></span> DELETE</div>
  141. </a>
  142. </t-dropdown-item>
  143. </t-dropdown-menu>
  144. </t-dropdown>
  145. <t-dropdown
  146. :minColumnWidth="180"
  147. :maxHeight="500"
  148. :delay2="[10, 150]"
  149. overlayClassName="header-dropdown"
  150. >
  151. <a> 工具 </a>
  152. <t-dropdown-menu>
  153. <t-dropdown-item>
  154. <a @click="onScaleWindow">窗口大小</a>
  155. </t-dropdown-item>
  156. <t-dropdown-item>
  157. <a @click="onScaleUp">放大</a>
  158. </t-dropdown-item>
  159. <t-dropdown-item>
  160. <a @click="onScaleDown">缩小</a>
  161. </t-dropdown-item>
  162. <t-dropdown-item divider="true">
  163. <a @click="onScaleFull">100%视图</a>
  164. </t-dropdown-item>
  165. <t-dropdown-item>
  166. <a @click="showMap">
  167. <div class="flex middle">
  168. 鹰眼地图 <span class="flex-grow"></span>
  169. <!-- <t-icon v-show="map" name="check" /> -->
  170. <check-icon v-show="map" />
  171. </div>
  172. </a>
  173. </t-dropdown-item>
  174. <t-dropdown-item divider="true">
  175. <a @click="showMagnifier">
  176. <div class="flex middle">
  177. 放大镜 <span class="flex-grow"></span>
  178. <!-- <t-icon v-show="magnifier" name="check" /> -->
  179. <check-icon v-show="magnifier" />
  180. </div>
  181. </a>
  182. </t-dropdown-item>
  183. <t-dropdown-item>
  184. <a @click="onAutoAnchor">
  185. <div class="flex middle">
  186. 自动锚点 <span class="flex-grow"></span>
  187. <!-- <t-icon v-show="autoAnchor" name="check" /> -->
  188. <check-icon v-show="autoAnchor" />
  189. </div>
  190. </a>
  191. </t-dropdown-item>
  192. <t-dropdown-item divider="true">
  193. <a @click="onDisableAnchor">
  194. <div class="flex middle">
  195. 显示锚点 <span class="flex-grow"></span>
  196. <!-- <t-icon v-show="showAnchor" name="check" /> -->
  197. <check-icon v-show="showAnchor" />
  198. </div>
  199. </a>
  200. </t-dropdown-item>
  201. <t-dropdown-item>
  202. <a @click="onToggleAnchor">
  203. <div
  204. class="flex"
  205. :style="{
  206. color: showAnchor ? '' : '#4f5b75',
  207. }"
  208. >
  209. 添加/删除锚点 <span class="flex-grow"></span> A
  210. </div>
  211. </a>
  212. </t-dropdown-item>
  213. </t-dropdown-menu>
  214. </t-dropdown>
  215. <t-dropdown
  216. :minColumnWidth="180"
  217. :maxHeight="500"
  218. :delay2="[10, 150]"
  219. overlayClassName="header-dropdown"
  220. >
  221. <a> 帮助 </a>
  222. <t-dropdown-menu>
  223. <t-dropdown-item
  224. v-for="item in enterprise.helps"
  225. :divider="item.divider"
  226. >
  227. <a :href="item.url" target="_blank">{{ item.name }}</a>
  228. </t-dropdown-item>
  229. </t-dropdown-menu>
  230. </t-dropdown>
  231. <div style="width: 148px; flex-shrink: 0"></div>
  232. <input v-model="data.name" @input="onInputName" />
  233. <a :href="enterprise.account" target="_blank">
  234. <!-- <t-icon name="home" /> -->
  235. <home-icon />
  236. 账户中心
  237. </a>
  238. <a :href="enterprise['v']" target="_blank" class="active">
  239. <!-- <t-icon name="desktop" /> -->
  240. <desktop-icon />
  241. 大屏可视化
  242. </a>
  243. <a :href="enterprise['3d']" target="_blank">
  244. <!-- <t-icon name="control-platform" /> -->
  245. <control-platform-icon />
  246. 3D可视化
  247. </a>
  248. <a :href="enterprise['2d']" target="_blank">
  249. <!-- <t-icon name="app" /> -->
  250. <app-icon />
  251. 2D可视化
  252. </a>
  253. <t-dropdown
  254. v-if="user.id"
  255. :minColumnWidth="200"
  256. :maxHeight="500"
  257. :delay2="[10, 150]"
  258. overlayClassName="custom-dropdown header"
  259. >
  260. <a style="margin-left: 32px; margin-right: 12px">
  261. <t-avatar
  262. size="small"
  263. :image="user.avatarUrl ? user.avatarUrl : baseUrl + 'img/avatar.png'"
  264. />
  265. </a>
  266. <t-dropdown-menu>
  267. <t-dropdown-item divider="true">
  268. <a :href="enterprise.account">
  269. {{ user.username }}
  270. <label
  271. class="ml-16 vip-label"
  272. :style="{
  273. color: user.limit > 1 ? '#ff4000' : '#D5C781',
  274. background: user.limit > 1 ? '#ff400030' : '#D5C78133',
  275. }"
  276. >VIP</label
  277. >
  278. </a>
  279. </t-dropdown-item>
  280. <t-dropdown-item divider="true">
  281. <a :href="`${enterprise.account}/v`" target="_blank"> 我的大屏 </a>
  282. </t-dropdown-item>
  283. <t-dropdown-item>
  284. <a :href="`${enterprise.account}/account/teams`" target="_blank">
  285. 我的团队
  286. </a>
  287. </t-dropdown-item>
  288. <t-dropdown-item>
  289. <a :href="`${enterprise.account}/account/info`" target="_blank">
  290. 账号信息
  291. </a>
  292. </t-dropdown-item>
  293. <t-dropdown-item divider="true">
  294. <a :href="`${enterprise.account}/account/security`" target="_blank">
  295. 安全设置
  296. </a>
  297. </t-dropdown-item>
  298. <t-dropdown-item>
  299. <a @click="logout">退出</a>
  300. </t-dropdown-item>
  301. </t-dropdown-menu>
  302. </t-dropdown>
  303. <div class="flex middle" v-else>
  304. <a class="button primary solid" style="width: 80px" :href="login()">
  305. 登录
  306. </a>
  307. </div>
  308. </div>
  309. <t-dialog
  310. v-if="payListDialog.show"
  311. v-model:visible="payListDialog.show"
  312. class="pay-dialog"
  313. :close-on-overlay-click="false"
  314. :top="95"
  315. :width="700"
  316. :cancel-btn="{
  317. content: '下载试用',
  318. variant: 'outline',
  319. style: {
  320. width: '100px',
  321. color:'#707B8F',
  322. marginRight:'8px'
  323. }
  324. }"
  325. confirm-btn="去支付"
  326. @cancel="downloadTrial"
  327. @close="payListDialog.show = false"
  328. @confirm="prePay"
  329. >
  330. <template #header>
  331. <div>
  332. <span style="vertical-align: middle">{{ payListDialog.title }}</span>
  333. <!-- <t-tooltip content="这是Tooltip内容"> -->
  334. <!-- @vue-ignore -->
  335. <a
  336. :href="payListDialog.href"
  337. target="_blank"
  338. class="hover"
  339. >
  340. <HelpCircleIcon class="hover" style="margin-left:12px;" />
  341. </a>
  342. <!-- </t-tooltip> -->
  343. </div>
  344. </template>
  345. <div class="pay-box">
  346. <div class="pay-title">{{ payListDialog.title }}</div>
  347. <div class="pay-price">
  348. <p>¥</p>
  349. <p>{{ data.deploy.price }}</p>
  350. </div>
  351. </div>
  352. <div class="pay-box pay-diagram">
  353. <div class="pay-up">
  354. <div class="pay-title">
  355. <t-checkbox v-model="data.payDiagram.checked"> 企业图形库
  356. </t-checkbox>
  357. <ChevronDownIcon @click="data.payDiagram.expend=false" v-if="data.payDiagram.expend" />
  358. <ChevronRightIcon @click="data.payDiagram.expend=true" v-else />
  359. </div>
  360. <div class="pay-price">
  361. <p>¥</p>
  362. <p>{{ data.payDiagram.price }}</p>
  363. </div>
  364. </div>
  365. <div v-if="data.payDiagram.expend" class="pay-down">
  366. <div v-for="item in data.payDiagram.list">
  367. <img v-if="item.img" :src="item.img" />
  368. <div v-else-if="item.svg" v-html="item.svg" ></div>
  369. <svg v-else class="l-icon" aria-hidden="true">
  370. <use :xlink:href="'#' + iotPensMap[item.name]?.icon"></use>
  371. </svg>
  372. </div>
  373. </div>
  374. </div>
  375. <div class="pay-footer">
  376. 合计
  377. <div>
  378. <p>¥</p>
  379. <p>{{ data.deploy.price+(data.payDiagram.checked?data.payDiagram.price:0) }}</p>
  380. </div>
  381. </div>
  382. </t-dialog>
  383. <t-dialog
  384. v-if="downloadZipDialog.show"
  385. v-model:visible="downloadZipDialog.show"
  386. class="pay-dialog"
  387. :close-on-overlay-click="false"
  388. :top="95"
  389. :width="700"
  390. :cancel-btn="{
  391. content: '直接下载',
  392. variant: 'outline',
  393. style: {
  394. width: '100px',
  395. color:'#707B8F',
  396. marginRight:'8px'
  397. }
  398. }"
  399. :confirm-btn="downloadZipDialog.checked?'去支付':null"
  400. @close="downloadZipDialog.show = false"
  401. @confirm="prePayDownloadZip"
  402. @cancel="doDownloadZip"
  403. >
  404. <template #header>
  405. <div>
  406. <span style="vertical-align: middle">导出为Zip文件</span>
  407. <t-tooltip content="这是Tooltip内容">
  408. <HelpCircleIcon style="margin-left:12px;" />
  409. </t-tooltip>
  410. </div>
  411. </template>
  412. <div class="pay-box pay-diagram">
  413. Zip包仅包含数据文件和图片文件,不包含js等依赖库。
  414. <div class="title desc">- 注意</div>Zip包用于平台(已包含js等依赖库)的快捷导入导出项目,无法作为独立部署包使用。
  415. <p v-if="downloadZipDialog.hasJs">
  416. <p class="title desc">- 当前图纸包含js企业图形依赖库。</p>
  417. 项目中打开如果没有js企业图形依赖库,对应的图元将无法显示。
  418. 推荐下载为离线部署包(包含js企业图形依赖库)。
  419. </p>
  420. </div>
  421. <div class="pay-box pay-diagram">
  422. <div class="pay-up">
  423. <div class="pay-title">
  424. <t-checkbox v-model="downloadZipDialog.checked"> 企业图形库
  425. </t-checkbox>
  426. <ChevronDownIcon @click="downloadZipDialog.expend=false" v-if="downloadZipDialog.expend" />
  427. <ChevronRightIcon @click="downloadZipDialog.expend=true" v-else />
  428. </div>
  429. <div class="pay-price">
  430. <p>¥</p>
  431. <p>{{ downloadZipDialog.price }}</p>
  432. </div>
  433. </div>
  434. <div v-if="downloadZipDialog.expend" class="pay-down">
  435. <div v-for="item in downloadZipDialog.list">
  436. <img :src="item" />
  437. </div>
  438. </div>
  439. </div>
  440. <div class="pay-footer">
  441. 合计
  442. <div>
  443. <p>¥</p>
  444. <p>{{downloadZipDialog.checked? downloadZipDialog.price:0 }}</p>
  445. </div>
  446. </div>
  447. </t-dialog>
  448. <t-dialog
  449. v-if="wechatPayDialog.show"
  450. v-model:visible="wechatPayDialog.show"
  451. class="pay-dialog"
  452. header="乐吾乐收银台"
  453. :close-on-overlay-click="false"
  454. :top="95"
  455. :width="700"
  456. confirm-btn="支付完成"
  457. :cancel-btn="null"
  458. @close="finishPay"
  459. @confirm="finishPay"
  460. >
  461. <Pay
  462. :order="data.order"
  463. :alipay-url="data.order.alipayUrl"
  464. :code-url="data.order.codeUrl"
  465. @success="onSuccess"
  466. />
  467. </t-dialog>
  468. </template>
  469. <script lang="ts" setup>
  470. import {
  471. reactive,
  472. ref,
  473. onBeforeMount,
  474. onUnmounted,
  475. nextTick,
  476. computed,
  477. } from 'vue';
  478. import { useRouter, useRoute } from 'vue-router';
  479. import { useUser } from '@/services/user';
  480. import { MessagePlugin } from 'tdesign-vue-next';
  481. import {
  482. Meta2dBackData,
  483. dealwithFormatbeforeOpen,
  484. gotoAccount,
  485. checkData,
  486. } from '@/services/utils';
  487. import { readFile } from '@/services/file';
  488. import { compareVersion, baseVer, upgrade } from '@/services/upgrade';
  489. import { parseSvg } from '@meta2d/svg';
  490. import { Pen, getGlobalColor, isShowChild } from '@meta2d/core';
  491. import { cdn, upCdn } from '@/services/api';
  492. import JSZip from 'jszip';
  493. import axios from 'axios';
  494. import { switchTheme } from '@/services/theme';
  495. import { noLoginTip } from '@/services/utils';
  496. import {
  497. save,
  498. blank,
  499. newFile,
  500. SaveType,
  501. onScaleFull,
  502. onScaleWindow,
  503. showMagnifier,
  504. showMap,
  505. drawPen,
  506. map,
  507. magnifier,
  508. useDot,
  509. delAttrs,
  510. useAssets,
  511. } from '@/services/common';
  512. import { useEnterprise } from '@/services/enterprise';
  513. import {
  514. CheckIcon,
  515. HomeIcon,
  516. DesktopIcon,
  517. ControlPlatformIcon,
  518. AppIcon,
  519. ChevronRightIcon,
  520. ChevronDownIcon,
  521. HelpCircleIcon
  522. } from 'tdesign-icons-vue-next';
  523. import {
  524. getDownloadList,
  525. getPayList,
  526. getComponentPurchased,
  527. get2dComponentJs,
  528. getTemPngs,
  529. getGoods,
  530. // preFrameDownload,
  531. zipBkImg,
  532. zipImages,
  533. Frame,
  534. img_cdn,
  535. img_upCdn,
  536. getDeployGoods,
  537. getFrameDownloadList
  538. } from '@/services/download';
  539. import { formComponents } from '@/services/defaults';
  540. import Pay from './Pay.vue';
  541. import {getNetJsDiagram} from '@/services/material';
  542. const { enterprise } = useEnterprise();
  543. const router = useRouter();
  544. const route = useRoute();
  545. const baseUrl = import.meta.env.BASE_URL || '/';
  546. // const { assets, getAssets } = useAssets();
  547. const { user, signout } = useUser();
  548. const { setDot } = useDot();
  549. const data = reactive<any>({
  550. name: '空白文件',
  551. order: {
  552. codeUrl: '',
  553. id: '', //订单id
  554. },
  555. goods: [], //所有商品类型
  556. purchasedList: [], //已经购买的列表
  557. deploy:{
  558. price:400,
  559. },
  560. payDiagram: {
  561. price: 400,
  562. checked:true,
  563. expend:false,
  564. list:[]
  565. },
  566. payGoods:{},
  567. });
  568. onBeforeMount(async () => {
  569. // getAssets();
  570. // getNetJsDiagram();
  571. });
  572. const logout = () => {
  573. signout();
  574. meta2d.emit('logout');
  575. };
  576. const onInputName = () => {
  577. (meta2d.store.data as Meta2dBackData).name = data.name;
  578. setDot();
  579. };
  580. const initMeta2dName = () => {
  581. data.name = (meta2d.store.data as Meta2dBackData).name || '';
  582. };
  583. let downloadList = new Set<any>();
  584. let iframeNum = 0;
  585. let compareNum = 0;
  586. const prePayList = reactive({
  587. pngs: new Set<string>(),
  588. jsPens: new Set<string>(),
  589. iotPens: new Set<string>(),
  590. svgPens: new Set<string>(),
  591. });
  592. let payListNum = 0;
  593. let comparePayListNum = 0;
  594. // let purchasedList = []; //已购买列表
  595. const iotPensMap = {};
  596. let downloadType: Frame = null;
  597. // const payPrice = ref(0);
  598. const getIotPensMap = () => {
  599. formComponents.forEach((item) => {
  600. item.list.forEach((_item) => {
  601. iotPensMap[_item.data.name] = { name: _item.name, icon: _item.icon };
  602. });
  603. });
  604. };
  605. nextTick(() => {
  606. meta2d.on('opened', initMeta2dName);
  607. window.addEventListener('message', dealWithMessage);
  608. getIotPensMap();
  609. });
  610. const dealWithMessage = async (e) => {
  611. if (
  612. typeof e.data !== 'string' ||
  613. !e.data ||
  614. e.data.startsWith('setImmediate')
  615. ) {
  616. return;
  617. }
  618. try {
  619. let data = JSON.parse(e.data);
  620. if (typeof data === 'object') {
  621. if (data.type) {
  622. if (data.name === 'download') {
  623. let list = data.data;
  624. let folderName =downloadType===Frame.vue3?'meta2d-vue3':downloadType===Frame.vue2?'meta2d-vue2': 'meta2d-react';
  625. list.forEach((item) => {
  626. if(item.path.startsWith('/meta3d/')){
  627. item.path = `/${folderName}/public/${item.path}`;
  628. }
  629. });
  630. downloadList = new Set([...downloadList, ...list]);
  631. compareNum += 1;
  632. if (compareNum >= iframeNum) {
  633. saveDownload();
  634. }
  635. } else if (data.name === 'payList') {
  636. prePayList.pngs = new Set([...prePayList.pngs, ...data.data.pngs]);
  637. prePayList.jsPens = new Set([
  638. ...prePayList.jsPens,
  639. ...data.data.jsPens,
  640. ]);
  641. prePayList.iotPens = new Set([
  642. ...prePayList.iotPens,
  643. ...data.data.iotPens,
  644. ]);
  645. prePayList.svgPens = new Set([
  646. ...prePayList.svgPens,
  647. ...data.data.svgPens,
  648. ]);
  649. comparePayListNum += 1;
  650. if (comparePayListNum >= payListNum) {
  651. await showPayListDialog();
  652. }
  653. }
  654. } else {
  655. meta2d.emit(data.name);
  656. }
  657. } else {
  658. meta2d.emit(data);
  659. }
  660. } catch (e) {
  661. console.info(e);
  662. }
  663. };
  664. onUnmounted(() => {
  665. meta2d.off('opened', initMeta2dName);
  666. window.removeEventListener('message', dealWithMessage);
  667. });
  668. const login = () => {
  669. return `${enterprise['account']}?cb=${encodeURIComponent(location.href)}`;
  670. };
  671. function load(isNew = false) {
  672. const input = document.createElement('input');
  673. input.type = 'file';
  674. input.onchange = (event) => {
  675. const elem = event.target as HTMLInputElement;
  676. if (elem.files && elem.files[0]) {
  677. // 路由跳转 可能在 openFile 后执行
  678. if (elem.files[0].name.endsWith('.json')) {
  679. blank();
  680. openJson(elem.files[0]);
  681. if (isNew) {
  682. router.push({
  683. path: '/',
  684. query: {
  685. r: Date.now() + '',
  686. },
  687. });
  688. }
  689. } else if (elem.files[0].name.endsWith('.svg')) {
  690. MessagePlugin.info(
  691. '可二次编辑但转换存在损失,若作为图片使用,请使用右侧属性面板的上传图片功能'
  692. );
  693. openSvg(elem.files[0]);
  694. } else if (elem.files[0].name.endsWith('.zip')) {
  695. blank();
  696. router.push({
  697. path: '/',
  698. query: {
  699. r: Date.now() + '',
  700. },
  701. });
  702. setTimeout(() => {
  703. openZip(elem.files[0]);
  704. }, 500);
  705. } else {
  706. MessagePlugin.info('打开文件只支持 json,svg,zip 格式');
  707. }
  708. }
  709. };
  710. input.click();
  711. }
  712. const openJson = async (file: File) => {
  713. const text = await readFile(file);
  714. try {
  715. let data: Meta2dBackData = JSON.parse(text);
  716. if (!data.name) {
  717. data.name = file.name.replace('.json', '');
  718. }
  719. if (!data.version || compareVersion(data.version, baseVer) === -1) {
  720. // 如果版本号不存在或者版本号 version < 1.0.0
  721. data = upgrade(data, baseVer);
  722. }
  723. dealwithFormatbeforeOpen(data);
  724. for (const k of delAttrs) {
  725. delete (data as any)[k];
  726. }
  727. meta2d.open(data);
  728. } catch (e) {
  729. console.error(e);
  730. }
  731. };
  732. const openSvg = async (file: File) => {
  733. const text = await readFile(file);
  734. const pens: Pen[] = parseSvg(text);
  735. meta2d.canvas.addCaches = pens;
  736. MessagePlugin.info('svg转换成功,请点击画布决定放置位置');
  737. };
  738. const openZip = async (file: File) => {
  739. if (!(user && user.id)) {
  740. MessagePlugin.warning(noLoginTip);
  741. return;
  742. }
  743. // if (!user.isVip) {
  744. // gotoAccount();
  745. // return;
  746. // }
  747. if (!user.vip) {
  748. MessagePlugin.info('需要开通普通会员~');
  749. gotoAccount();
  750. return;
  751. }
  752. const { default: JSZip } = await import('jszip');
  753. const zip = new JSZip();
  754. await zip.loadAsync(file);
  755. let dataStr = '';
  756. for (const key in zip.files) {
  757. if (zip.files[key].dir) {
  758. continue;
  759. }
  760. if (key.endsWith('.json')) {
  761. // 认为只有一个 json 文件
  762. // dataStr = await zip.file(key).async('string');
  763. break;
  764. }
  765. }
  766. if (!dataStr) {
  767. return false;
  768. }
  769. for (const key in zip.files) {
  770. if (zip.files[key].dir) {
  771. continue;
  772. }
  773. // let _png = key.indexOf('/png');
  774. // let _img = key.indexOf('/img');
  775. // let _image = key.indexOf('/image');
  776. // let _file = key.indexOf('/file');
  777. let _keyLower = key.toLowerCase();
  778. // if (!key.endsWith('.json') && (_png !== -1 || _img !== -1 || _image !== -1 || _file !== -1)) {
  779. if (
  780. _keyLower.endsWith('.png') ||
  781. _keyLower.endsWith('.svg') ||
  782. _keyLower.endsWith('.gif') ||
  783. _keyLower.endsWith('.jpg') ||
  784. _keyLower.endsWith('.jpeg')
  785. ) {
  786. let filename = key.substr(key.lastIndexOf('/') + 1);
  787. const extPos = filename.lastIndexOf('.');
  788. let ext = '';
  789. if (extPos > 0) {
  790. ext = filename.substr(extPos);
  791. }
  792. filename = filename.substring(0, extPos > 8 ? 8 : extPos);
  793. // 上传文件
  794. const result: any = {};
  795. // await upload(
  796. // // await zip.file(key).async('blob'),
  797. // true,
  798. // filename + ext,
  799. // "/2D/默认"
  800. // );
  801. let _key = key;
  802. // if (_png) {
  803. // _key = key.substring(_png);
  804. // } else if (_image) {
  805. // _key = key.substring(_png);
  806. // } else if (_img) {
  807. // _key = key.substring(_img);
  808. // } else if (_file) {
  809. // _key = key.substring(_file);
  810. // }
  811. if (result) {
  812. if (dataStr.replaceAll) {
  813. //'le5le.meta2d'
  814. dataStr = dataStr.replaceAll(_key.slice(12), result.url);
  815. } else {
  816. while (dataStr.includes(_key)) {
  817. dataStr = dataStr.replace(_key.slice(12), result.url);
  818. // 正则 gm 在特殊情况下报错,例如如下场景
  819. /**
  820. *    
  821. const data = '{"image":"/image/materials/IoT-Chemical(化学)/Air stripper 2(汽提塔2).svg"}';
  822. const key = '/image/materials/IoT-Chemical(化学)/Air stripper 2(汽提塔2).svg';
  823. data.replace(key, '123');
  824. data.replaceAll(key, '123')
  825. data.replace(new RegExp(key, 'gm'), '123');
  826. data.replace(new RegExp(key, 'g'), '123');
  827. */
  828. }
  829. }
  830. }
  831. }
  832. }
  833. try {
  834. let data: Meta2dBackData = JSON.parse(dataStr);
  835. if (data) {
  836. if (!data.name) {
  837. data.name = file.name.replace('.zip', '');
  838. }
  839. if (!data.version || compareVersion(data.version, baseVer) === -1) {
  840. // 如果版本号不存在或者版本号 version < 1.0.0
  841. data = upgrade(data, baseVer);
  842. }
  843. dealwithFormatbeforeOpen(data);
  844. const delAttrs = [
  845. 'userId',
  846. 'shared',
  847. 'team',
  848. 'owner',
  849. 'username',
  850. 'editor',
  851. 'editorId',
  852. 'editorName',
  853. 'createdAt',
  854. 'folder',
  855. 'image',
  856. 'id',
  857. '_id',
  858. 'view',
  859. 'updatedAt',
  860. 'star',
  861. 'recommend',
  862. ];
  863. for (const k of delAttrs) {
  864. delete (data as any)[k];
  865. }
  866. meta2d.open(data);
  867. }
  868. } catch (e) {
  869. return false;
  870. }
  871. };
  872. const downloadJson = () => {
  873. const data: Meta2dBackData = meta2d.data();
  874. if (data._id) delete data._id;
  875. if (data.id) delete data.id;
  876. checkData(data);
  877. import('file-saver').then(({ saveAs }) => {
  878. saveAs(
  879. new Blob(
  880. [JSON.stringify(data).replaceAll(cdn, '').replaceAll(upCdn, '')],
  881. {
  882. type: 'text/plain;charset=utf-8',
  883. }
  884. ),
  885. `${data.name || 'le5le.meta2d'}.json`
  886. );
  887. });
  888. };
  889. const downloadZip = async () => {
  890. if (!(user && user.id)) {
  891. MessagePlugin.warning(noLoginTip);
  892. return;
  893. }
  894. // if (!user.isVip) {
  895. // // gotoAccount();
  896. // return;
  897. // }
  898. // if (!user.vip) {
  899. // MessagePlugin.info('需要开通普通会员~');
  900. // gotoAccount();
  901. // return;
  902. // }
  903. if(!meta2d.store.data.pens.length){
  904. MessagePlugin.info('画布没有画笔!');
  905. return;
  906. }
  907. preDownloadZip();
  908. return;
  909. MessagePlugin.info('正在下载打包中,可能需要几分钟,请耐心等待...');
  910. const [{ default: JSZip }, { saveAs }] = await Promise.all([
  911. import('jszip'),
  912. import('file-saver'),
  913. ]);
  914. const zip: any = new JSZip();
  915. const data: Meta2dBackData = meta2d.data();
  916. let _fileName =
  917. (data.name && data.name.replace(/\//g, '_').replace(/:/g, '_')) ||
  918. 'le5le.meta2d';
  919. const _zip = zip.folder(`${_fileName}`);
  920. if (data._id) delete data._id;
  921. if (data.id) delete data.id;
  922. checkData(data);
  923. _zip.file(
  924. `${_fileName}.json`,
  925. JSON.stringify(data).replaceAll(cdn, '').replaceAll(upCdn, '')
  926. );
  927. await zipBkImg(_zip);
  928. await zipImages(_zip, meta2d.store.data.pens);
  929. const blob = await zip.generateAsync({ type: 'blob' });
  930. saveAs(blob, `${_fileName}.zip`);
  931. };
  932. const preDownloadZip =async () =>{
  933. const meta2dData = meta2d.data();
  934. let payList = getPayList(meta2dData);
  935. let purchased =await getComponentPurchased({
  936. pngs: payList.pngs,
  937. jsPens: [],
  938. iotPens: [],
  939. svgPens: [],
  940. });
  941. downloadZipDialog.checked = true;
  942. console.log("payList",payList);
  943. if(payList.jsPens.length||payList.iotPens.length||payList.svgPens.length){
  944. downloadZipDialog.hasJs = true;
  945. }else{
  946. downloadZipDialog.hasJs = false;
  947. }
  948. let names = purchased.map((item) => item.name);
  949. data.goods = await getGoods();
  950. let list = payList.pngs.filter((item) => !names.includes(item));
  951. if(!list.length){
  952. doDownloadZip();
  953. }else{
  954. let unitPrice = data.goods.find((item)=>item.type==='图片图元').unitPrice;
  955. downloadZipDialog.price = unitPrice*list.length;
  956. downloadZipDialog.show = true;
  957. downloadZipDialog.list = list;
  958. }
  959. }
  960. const prePayDownloadZip = async ()=>{
  961. if(downloadZipDialog.checked){
  962. const res: any = await axios.post('/api/order/deployment/submit', {
  963. goods:{},
  964. '2ds':downloadZipDialog.list.map((item)=>{return { type: '图片图元', name: item}}),
  965. });
  966. wechatPayDialog.show = true;
  967. wechatPayDialog.isZip = true;
  968. data.order = res;
  969. }else {
  970. doDownloadZip();
  971. }
  972. }
  973. const doDownloadZip = async ()=>{
  974. downloadZipDialog.show = false;
  975. MessagePlugin.info('正在下载打包中,可能需要几分钟,请耐心等待...');
  976. const [{ default: JSZip }, { saveAs }] = await Promise.all([
  977. import('jszip'),
  978. import('file-saver'),
  979. ]);
  980. const zip: any = new JSZip();
  981. const data: Meta2dBackData = meta2d.data();
  982. let _fileName =
  983. (data.name && data.name.replace(/\//g, '_').replace(/:/g, '_')) ||
  984. 'le5le.meta2d';
  985. const _zip = zip.folder(`${_fileName}`);
  986. if (data._id) delete data._id;
  987. if (data.id) delete data.id;
  988. checkData(data);
  989. _zip.file(
  990. `${_fileName}.json`,
  991. JSON.stringify(data).replaceAll(cdn, '').replaceAll(upCdn, '')
  992. );
  993. await zipBkImg(_zip);
  994. await zipImages(_zip, meta2d.store.data.pens);
  995. const blob = await zip.generateAsync({ type: 'blob' });
  996. saveAs(blob, `${_fileName}.zip`);
  997. }
  998. // const zip3D = (name: string) => {
  999. // const pen_3d = meta2d.store.data.pens.filter(
  1000. // (pen) =>
  1001. // pen.name === 'iframe' &&
  1002. // (pen.tags.includes('meta3d') || pen.iframe.indexOf('3d') !== -1)
  1003. // );
  1004. // if (pen_3d && pen_3d.length) {
  1005. // //存在3d场景
  1006. // pen_3d.forEach((pen) => {
  1007. // //发送消息
  1008. // let params = queryURLParams(pen.iframe.split('?')[1]);
  1009. // (
  1010. // pen.calculative.singleton.div.children[0] as HTMLIFrameElement
  1011. // ).contentWindow.postMessage(
  1012. // JSON.stringify({
  1013. // type: 1,
  1014. // name,
  1015. // id: params.id,
  1016. // }),
  1017. // '*'
  1018. // );
  1019. // });
  1020. // }
  1021. // };
  1022. // const zip2D = (name: string) => {
  1023. // const pen_2d = meta2d.store.data.pens.filter(
  1024. // (pen) =>
  1025. // pen.name === 'iframe' &&
  1026. // (pen.iframe.indexOf('2d.le5le.com') !== -1 ||
  1027. // pen.iframe.indexOf('/2d/') !== -1 ||
  1028. // pen.iframe.indexOf('v.le5le.com') !== -1 ||
  1029. // pen.iframe.indexOf('/v/') !== -1)
  1030. // );
  1031. // if (pen_2d && pen_2d.length) {
  1032. // //存在3d场景
  1033. // pen_2d.forEach((pen) => {
  1034. // //发送消息
  1035. // // let params = queryURLParams(pen.iframe.split('?')[1]);
  1036. // (
  1037. // pen.calculative.singleton.div.children[0] as HTMLIFrameElement
  1038. // ).contentWindow.postMessage(
  1039. // JSON.stringify({
  1040. // name,
  1041. // type: 1,
  1042. // }),
  1043. // '*'
  1044. // );
  1045. // });
  1046. // }
  1047. // }
  1048. function queryURLParams(value?: string) {
  1049. let url = value || window.location.href.split('?')[1];
  1050. const urlSearchParams = new URLSearchParams(url);
  1051. const params = Object.fromEntries(urlSearchParams.entries());
  1052. return params;
  1053. }
  1054. const downloadHtml = async () => {
  1055. if (!(user && user.id)) {
  1056. MessagePlugin.warning(noLoginTip);
  1057. return;
  1058. }
  1059. downloadType = Frame.html;
  1060. await preGetPayList();
  1061. };
  1062. const preGetPayList = async () => {
  1063. //图形库需要购买
  1064. const meta2dData = meta2d.data();
  1065. if(!meta2dData.pens.length){
  1066. MessagePlugin.info('画布没有画笔!');
  1067. return;
  1068. }
  1069. let list = getPayList(meta2dData);
  1070. prePayList.pngs = new Set(list.pngs);
  1071. prePayList.jsPens = new Set(list.jsPens);
  1072. prePayList.iotPens = new Set(list.iotPens);
  1073. prePayList.svgPens = new Set(list.svgPens);
  1074. downloadList = new Set();
  1075. //向iframe发送消息
  1076. payListNum = 0;
  1077. comparePayListNum = 0;
  1078. const pen_pay = meta2dData.pens.filter(
  1079. (pen) =>
  1080. pen.name === 'iframe' &&
  1081. (pen.iframe.indexOf('2d.le5le.com') !== -1 ||
  1082. pen.iframe.indexOf('/2d') !== -1 || pen.iframe.indexOf('data=2d') !== -1 ||
  1083. pen.iframe.indexOf('v.le5le.com') !== -1 ||
  1084. pen.iframe.indexOf('/view/v') !== -1 ||pen.iframe.indexOf('data=v') !== -1 ||
  1085. pen.iframe.indexOf('/preview') !== -1)
  1086. );
  1087. if (pen_pay && pen_pay.length) {
  1088. pen_pay.forEach((pen) => {
  1089. //发送消息
  1090. (
  1091. meta2d.store.pens[pen.id].calculative.singleton.div
  1092. .children[0] as HTMLIFrameElement
  1093. ).contentWindow.postMessage(
  1094. JSON.stringify({
  1095. name: 'prePayList',
  1096. type: 1,
  1097. }),
  1098. '*'
  1099. );
  1100. payListNum += 1;
  1101. });
  1102. }
  1103. if (payListNum === 0) {
  1104. await showPayListDialog();
  1105. }
  1106. };
  1107. const showPayListDialog = async () => {
  1108. //下载离线部署包
  1109. const deploys =await getDeployGoods();
  1110. const pen_3d = meta2d.store.data.pens.filter(
  1111. (pen) =>
  1112. pen.name === 'iframe' &&
  1113. (pen.iframe.indexOf('3d.le5le.com') !== -1 ||
  1114. pen.iframe.indexOf('/3d') !== -1)
  1115. );
  1116. const pen_2d = meta2d.store.data.pens.filter(
  1117. (pen) =>
  1118. pen.name === 'iframe' &&
  1119. (pen.iframe.indexOf('2d.le5le.com') !== -1 ||
  1120. pen.iframe.indexOf('/2d') !== -1||pen.iframe.indexOf('v.le5le.com') !== -1 ||
  1121. pen.iframe.indexOf('/view/v') !== -1||pen.iframe.indexOf('data=v') !== -1)
  1122. );
  1123. let price = 0;
  1124. data.payDiagram.checked = true;
  1125. data.payDiagram.expend = false;
  1126. data.payGoods ={}
  1127. deploys.forEach((item) => {
  1128. if(item.name==="3D离线部署下载"){
  1129. price+=item.price*pen_3d.length;
  1130. if(pen_3d.length){
  1131. data.payGoods[item.id]=pen_3d.length;
  1132. }
  1133. }else if(item.name==="2D离线部署下载"){
  1134. price+=item.price*(pen_2d.length+1);
  1135. data.payGoods[item.id]=pen_2d.length+1;
  1136. }
  1137. });
  1138. data.deploy.price = price;
  1139. //图形库
  1140. data.goods = await getGoods();
  1141. data.purchasedList = await getComponentPurchased(prePayList);
  1142. data.payDiagram.list =[];
  1143. data.goods.forEach((goods)=>{
  1144. let purchased = data.purchasedList?.filter(
  1145. (_item) => _item.type === goods.type
  1146. );
  1147. let names = purchased.map((item) => item.name);
  1148. let list = [];
  1149. if(goods.type==='图片图元'){
  1150. list = [...prePayList.pngs];
  1151. }else if(goods.type==='JS线性图元'){
  1152. list = [...prePayList.jsPens];
  1153. }else if(goods.type==='SVG线性图元'){
  1154. list = [...prePayList.svgPens];
  1155. }else if(goods.type==='控件'){
  1156. list = [...prePayList.iotPens];
  1157. }
  1158. let num =0;
  1159. if (goods.type==='SVG线性图元'&&purchased.length === 1 && !purchased[0].name) {
  1160. //说明已经购买全部
  1161. }else{
  1162. list.forEach((item)=>{
  1163. if(!names.includes(item)){
  1164. if(goods.type==='控件'){
  1165. data.payDiagram.list.push({
  1166. name:item
  1167. });
  1168. }else if(goods.type==='JS线性图元'){
  1169. data.payDiagram.list.push({
  1170. svg:globalThis.jsPensMap?globalThis.jsPensMap[item]:item
  1171. });
  1172. }else{
  1173. data.payDiagram.list.push({
  1174. img:item
  1175. });
  1176. }
  1177. num+=1;
  1178. }
  1179. })};
  1180. goods.num = num;
  1181. })
  1182. price = 0;
  1183. data.goods.forEach((item, index) => {
  1184. price += item.num * item.unitPrice;
  1185. });
  1186. console.log("goods",data.goods)
  1187. data.payDiagram.price = price;
  1188. // data.goods.forEach((item, index) => {
  1189. // item.checked = true;
  1190. // let purchased = data.purchasedList?.filter(
  1191. // (_item) => _item.type === item.type
  1192. // );
  1193. // if (index === 0) {
  1194. // item.total = [...prePayList.pngs].length;
  1195. // item.unPurchased = item.total - purchased.length;
  1196. // } else if (index === 1) {
  1197. // item.total = [...prePayList.iotPens].length;
  1198. // item.unPurchased = item.total - purchased.length;
  1199. // } else if (index === 3) {
  1200. // item.total = [...prePayList.jsPens].length;
  1201. // item.unPurchased = item.total - purchased.length;
  1202. // } else if (index === 2) {
  1203. // if (purchased.length === 1 && !purchased[0].name) {
  1204. // //说明已经购买全部 //TODO
  1205. // item.total = item.count;
  1206. // item.unPurchased = 0;
  1207. // } else {
  1208. // //需要购买全部
  1209. // if ([...prePayList.svgPens].includes('*')) {
  1210. // item.total = item.count;
  1211. // item.unPurchased = item.total;
  1212. // } else {
  1213. // item.total = [...prePayList.svgPens].length;
  1214. // item.unPurchased = item.total - purchased.length;
  1215. // }
  1216. // }
  1217. // }
  1218. // });
  1219. payListDialog.show = true;
  1220. switch (downloadType) {
  1221. case Frame.html:
  1222. payListDialog.title = '下载离线部署包';
  1223. break;
  1224. case Frame.vue2:
  1225. payListDialog.title = '下载vue2组件包';
  1226. break;
  1227. case Frame.vue3:
  1228. payListDialog.title = '下载vue3组件包';
  1229. break;
  1230. case Frame.react:
  1231. payListDialog.title = '下载react组件包';
  1232. break;
  1233. }
  1234. // let price = 0;
  1235. // if (price === 0) {
  1236. // skipPay(); //如果计算价格为0,直接下载
  1237. // } else {
  1238. // payListDialog.show = true;
  1239. // }
  1240. };
  1241. const preDownload = () => {
  1242. iframeNum = 0;
  1243. compareNum = 0;
  1244. const meta2dData:any = meta2d.data();
  1245. meta2dData.userId = user.id;
  1246. const pen_3d = meta2dData.pens.filter(
  1247. (pen) =>
  1248. pen.name === 'iframe' &&
  1249. (pen.iframe.indexOf('3d.le5le.com') !== -1 ||
  1250. pen.iframe.indexOf('/3d') !== -1)
  1251. );
  1252. if (pen_3d && pen_3d.length) {
  1253. //存在3d场景
  1254. if (pen_3d.length === 1) {
  1255. let params = queryURLParams(pen_3d[0].iframe.split('?')[1]);
  1256. meta2d.store.pens[
  1257. pen_3d[0].id
  1258. ].calculative.singleton.div.children[0].contentWindow.postMessage(
  1259. JSON.stringify({
  1260. name: 'deploy',
  1261. // id: params.id,
  1262. type: 1, //用于区分是系统消息
  1263. path: `3d`,
  1264. }),
  1265. '*'
  1266. );
  1267. pen_3d[0].iframe = '/view?data=3d';
  1268. } else {
  1269. pen_3d.forEach((pen) => {
  1270. //发送消息
  1271. let params = queryURLParams(pen.iframe.split('?')[1]);
  1272. (
  1273. meta2d.store.pens[pen.id].calculative.singleton.div
  1274. .children[0] as HTMLIFrameElement
  1275. ).contentWindow.postMessage(
  1276. JSON.stringify({
  1277. name: 'deploy',
  1278. // id: params.id,
  1279. type: 1,
  1280. path: `3d-${params.id}`,
  1281. }),
  1282. '*'
  1283. );
  1284. pen.iframe = `/view?data=3d-${params.id}`;
  1285. });
  1286. }
  1287. iframeNum += pen_3d.length;
  1288. }
  1289. const pen_2d = meta2dData.pens.filter(
  1290. (pen) =>
  1291. pen.name === 'iframe' &&
  1292. (pen.iframe.indexOf('2d.le5le.com') !== -1 ||
  1293. pen.iframe.indexOf('/2d') !== -1)
  1294. );
  1295. if (pen_2d && pen_2d.length) {
  1296. //存在3d场景
  1297. if (pen_2d.length === 1) {
  1298. let params = queryURLParams(pen_2d[0].iframe.split('?')[1]);
  1299. meta2d.store.pens[
  1300. pen_2d[0].id
  1301. ].calculative.singleton.div.children[0].contentWindow.postMessage(
  1302. JSON.stringify({
  1303. name: 'downloadHtml',
  1304. id: params.id,
  1305. type: 1,
  1306. path: `2d`,
  1307. }),
  1308. '*'
  1309. );
  1310. pen_2d[0].iframe = '/view?data=2d';
  1311. } else {
  1312. pen_2d.forEach((pen) => {
  1313. //发送消息
  1314. let params = queryURLParams(pen.iframe.split('?')[1]);
  1315. (
  1316. meta2d.store.pens[pen.id].calculative.singleton.div
  1317. .children[0] as HTMLIFrameElement
  1318. ).contentWindow.postMessage(
  1319. JSON.stringify({
  1320. name: 'downloadHtml',
  1321. // id: params.id,
  1322. type: 1,
  1323. path: `2d-${params.id}`,
  1324. }),
  1325. '*'
  1326. );
  1327. pen.iframe = `/view?data=2d-${params.id}`;
  1328. });
  1329. }
  1330. iframeNum += pen_2d.length;
  1331. }
  1332. const pen_v = meta2dData.pens.filter(
  1333. (pen) =>
  1334. pen.name === 'iframe' &&
  1335. (pen.iframe.indexOf('v.le5le.com') !== -1 ||
  1336. pen.iframe.indexOf('/view/v') !== -1||pen.iframe.indexOf('data=v') !== -1)
  1337. );
  1338. if (pen_v && pen_v.length) {
  1339. //存在3d场景
  1340. pen_v.forEach((pen) => {
  1341. //发送消息
  1342. let params = queryURLParams(pen.iframe.split('?')[1]);
  1343. (
  1344. meta2d.store.pens[pen.id].calculative.singleton.div
  1345. .children[0] as HTMLIFrameElement
  1346. ).contentWindow.postMessage(
  1347. JSON.stringify({
  1348. name: 'downloadHtml',
  1349. // id: params.id,
  1350. type: 1,
  1351. path: `v-${params.id}`,
  1352. }),
  1353. '*'
  1354. );
  1355. pen.iframe = `/view?data=v-${params.id}`;
  1356. });
  1357. iframeNum += pen_v.length;
  1358. }
  1359. downloadList = getDownloadList(meta2dData);
  1360. if (iframeNum === 0) {
  1361. //如果没有嵌入场景
  1362. saveDownload();
  1363. } else {
  1364. setTimeout(() => {
  1365. if (compareNum < iframeNum) {
  1366. //message阻塞/报错的情况
  1367. saveDownload();
  1368. }
  1369. }, 10000);
  1370. }
  1371. };
  1372. const preFrameDownload = async () => {
  1373. iframeNum = 0;
  1374. compareNum = 0;
  1375. const meta2dData:any = meta2d.data();
  1376. meta2dData.userId = user.id;
  1377. const pen_3d = meta2dData.pens.filter(
  1378. (pen) =>
  1379. pen.name === 'iframe' &&
  1380. (pen.iframe.indexOf('3d.le5le.com') !== -1 ||
  1381. pen.iframe.indexOf('/3d') !== -1)
  1382. );
  1383. let name_3d = (downloadType===Frame.vue3?'toVue3':downloadType===Frame.vue2?'toVue2':'toReact');
  1384. let flag_3d = false; //标记是否存在3d场景
  1385. if (pen_3d && pen_3d.length) {
  1386. //存在3d场景
  1387. if (pen_3d.length === 1) {
  1388. let params = queryURLParams(pen_3d[0].iframe.split('?')[1]);
  1389. meta2d.store.pens[
  1390. pen_3d[0].id
  1391. ].calculative.singleton.div.children[0].contentWindow.postMessage(
  1392. JSON.stringify({
  1393. name: name_3d,
  1394. type: 1, //用于区分是系统消息
  1395. path: `3d`,
  1396. }),
  1397. '*'
  1398. );
  1399. pen_3d[0].iframe = '/3d?id=3d';
  1400. } else {
  1401. pen_3d.forEach((pen) => {
  1402. //发送消息
  1403. let params = queryURLParams(pen.iframe.split('?')[1]);
  1404. (
  1405. meta2d.store.pens[pen.id].calculative.singleton.div
  1406. .children[0] as HTMLIFrameElement
  1407. ).contentWindow.postMessage(
  1408. JSON.stringify({
  1409. name:name_3d,
  1410. // id: params.id,
  1411. type: 1,
  1412. path: `3d-${params.id}`,
  1413. }),
  1414. '*'
  1415. );
  1416. pen.iframe = `/3d?id=3d-${params.id}`;
  1417. });
  1418. }
  1419. iframeNum += pen_3d.length;
  1420. flag_3d = true;
  1421. }
  1422. const pen_2d = meta2dData.pens.filter(
  1423. (pen) =>
  1424. pen.name === 'iframe' &&
  1425. (pen.iframe.indexOf('2d.le5le.com') !== -1 ||
  1426. pen.iframe.indexOf('/2d') !== -1)
  1427. );
  1428. let name_2d = (downloadType===Frame.vue3?'downloadVue3':downloadType===Frame.vue2?'downloadVue2':'downloadReact');
  1429. if (pen_2d && pen_2d.length) {
  1430. //存在3d场景
  1431. if (pen_2d.length === 1) {
  1432. let params = queryURLParams(pen_2d[0].iframe.split('?')[1]);
  1433. meta2d.store.pens[
  1434. pen_2d[0].id
  1435. ].calculative.singleton.div.children[0].contentWindow.postMessage(
  1436. JSON.stringify({
  1437. name: name_2d,
  1438. id: params.id,
  1439. type: 1,
  1440. path: `2d`,
  1441. }),
  1442. '*'
  1443. );
  1444. pen_2d[0].iframe = '/2d?id=2d';
  1445. } else {
  1446. pen_2d.forEach((pen) => {
  1447. //发送消息
  1448. let params = queryURLParams(pen.iframe.split('?')[1]);
  1449. (
  1450. meta2d.store.pens[pen.id].calculative.singleton.div
  1451. .children[0] as HTMLIFrameElement
  1452. ).contentWindow.postMessage(
  1453. JSON.stringify({
  1454. name:name_2d,
  1455. // id: params.id,
  1456. type: 1,
  1457. path: `2d-${params.id}`,
  1458. }),
  1459. '*'
  1460. );
  1461. pen.iframe = `/2d?id=2d-${params.id}`;
  1462. });
  1463. }
  1464. iframeNum += pen_2d.length;
  1465. }
  1466. const pen_v = meta2dData.pens.filter(
  1467. (pen) =>
  1468. pen.name === 'iframe' &&
  1469. (pen.iframe.indexOf('v.le5le.com') !== -1 ||
  1470. pen.iframe.indexOf('/view/v') !== -1||pen.iframe.indexOf('data=v') !== -1||pen.iframe.indexOf('/preview') !== -1)
  1471. );
  1472. if (pen_v && pen_v.length) {
  1473. //存在大屏场景
  1474. pen_v.forEach((pen) => {
  1475. //发送消息
  1476. let params = queryURLParams(pen.iframe.split('?')[1]);
  1477. (
  1478. meta2d.store.pens[pen.id].calculative.singleton.div
  1479. .children[0] as HTMLIFrameElement
  1480. ).contentWindow.postMessage(
  1481. JSON.stringify({
  1482. name: name_2d,
  1483. // id: params.id,
  1484. type: 1,
  1485. path: `v-${params.id}`,
  1486. }),
  1487. '*'
  1488. );
  1489. pen.iframe = `/2d?id=v-${params.id}`;
  1490. });
  1491. iframeNum += pen_v.length;
  1492. }
  1493. downloadList = getFrameDownloadList(meta2dData,undefined,downloadType,flag_3d);
  1494. if (iframeNum === 0) {
  1495. //如果没有嵌入场景
  1496. console.log(2);
  1497. saveDownload();
  1498. } else {
  1499. setTimeout(() => {
  1500. if (compareNum < iframeNum) {
  1501. //message阻塞/报错的情况
  1502. console.log("1")
  1503. saveDownload();
  1504. }
  1505. }, 10000);
  1506. }
  1507. }
  1508. const saveDownload = async () => {
  1509. const list = [...downloadList];
  1510. console.log("list",list);
  1511. //控件
  1512. let jsPath= '';
  1513. switch (downloadType) {
  1514. case Frame.html:
  1515. jsPath = '/view/js/2d-components.js';
  1516. break;
  1517. case Frame.vue2:
  1518. jsPath = '/meta2d-vue2/public/js/2d-components.js';
  1519. break;
  1520. case Frame.vue3:
  1521. jsPath = '/meta2d-vue3/public/js/2d-components.js';
  1522. break;
  1523. case Frame.react:
  1524. jsPath = '/meta2d-react/public/js/2d-components.js';
  1525. break;
  1526. }
  1527. const js = await get2dComponentJs([...prePayList.iotPens]);
  1528. list.push({
  1529. data: js,
  1530. path:jsPath,
  1531. });
  1532. ///png图形库
  1533. const pngs = await getTemPngs([...prePayList.pngs]);
  1534. list.forEach((item) => {
  1535. if(item.url){
  1536. let url =item.url.replace(img_cdn, '').replace(img_upCdn, '')
  1537. if (pngs[url]) {
  1538. item.url = pngs[url];
  1539. }
  1540. }
  1541. });
  1542. //js线性图元 由对应页面处理
  1543. //SVG线性图元
  1544. if ([...prePayList.svgPens].length) {
  1545. let purchased = data.purchasedList?.filter(
  1546. (_item) => _item.type === 'SVG线性图元'
  1547. );
  1548. if (purchased.length === 1 && !purchased[0].name) {
  1549. //已经购买全部
  1550. list.forEach((item) => {
  1551. if (item.data && item.path.indexOf('/projects/v') !== 1) {
  1552. //清空所有svgpath
  1553. let meta2dData = JSON.parse(item.data);
  1554. for (let key of Object.keys(meta2dData.paths)) {
  1555. let path = meta2dData.paths[key];
  1556. if (
  1557. path.indexOf('-1.18Zm4-1') !== -1 ||
  1558. path.indexOf('-1.19Zm4-1') !== -1 ||
  1559. path.indexOf('2.85ZM') !== -1 ||
  1560. path.indexOf('-1-2.39.3') !== -1
  1561. ) {
  1562. meta2dData.paths[key] = '';
  1563. }
  1564. }
  1565. item.data = JSON.stringify(meta2dData);
  1566. }
  1567. });
  1568. } else {
  1569. let svgnames = purchased.map(i=>i.name);
  1570. list.forEach((item) => {
  1571. if (
  1572. item.data &&
  1573. item.path.indexOf('/projects/v') !== -1 &&
  1574. item.path.indexOf('/projects/v/png/') === -1
  1575. ) {
  1576. //2d 图纸数据
  1577. let meta2dData = JSON.parse(item.data);
  1578. meta2dData.pens.forEach((pen) => {
  1579. if (pen.name === 'svgPath' && pen.svgUrl) {
  1580. if (svgnames.includes(pen.svgUrl.replace(img_cdn, ''))) {
  1581. pen.pathId = null;
  1582. }
  1583. }
  1584. });
  1585. item.data = JSON.stringify(meta2dData);
  1586. }
  1587. });
  1588. }
  1589. }
  1590. //开始下载list
  1591. const [{ default: JSZip }, { saveAs }] = await Promise.all([
  1592. import('jszip'),
  1593. import('file-saver'),
  1594. ]);
  1595. const zip = new JSZip();
  1596. await Promise.all(
  1597. list.map(async (item: any) => {
  1598. if (item.url) {
  1599. //接口请求
  1600. const res: Blob = await axios.get(item.url.startsWith('/')?(cdn+item.url):item.url, {
  1601. responseType: 'blob',
  1602. });
  1603. zip.file(item.path, res, { createFolders: true });
  1604. } else if (item.data) {
  1605. //直接写数据
  1606. zip.file(item.path, item.data, { createFolders: true });
  1607. }
  1608. })
  1609. );
  1610. let _fileName =
  1611. (meta2d.store.data.name &&
  1612. meta2d.store.data.name.replace(/\//g, '_').replace(/:/g, '_')) ||
  1613. 'le5le.meta2d';
  1614. const blob = await zip.generateAsync({ type: 'blob' });
  1615. saveAs(blob, `${_fileName}.zip`);
  1616. };
  1617. // const _downloadHtml = async () => {
  1618. // if (!(user && user.id)) {
  1619. // MessagePlugin.warning(noLoginTip);
  1620. // return;
  1621. // }
  1622. // // if (!user.isVip) {
  1623. // // gotoAccount();
  1624. // // return;
  1625. // // }
  1626. // if (user.vipDesc !== '超级会员' && user.vipDesc !== '旗舰会员') {
  1627. // MessagePlugin.info('需要开通超级会员~');
  1628. // gotoAccount();
  1629. // return;
  1630. // }
  1631. // frameFlag = -1;
  1632. // MessagePlugin.info('正在下载打包中,可能需要几分钟,请耐心等待...');
  1633. // const data: Meta2dBackData = meta2d.data();
  1634. // if (data._id) delete data._id;
  1635. // if (data.id) delete data.id;
  1636. // if (data.image) delete data.image;
  1637. // checkData(data);
  1638. // const [{ default: JSZip }, { saveAs }] = await Promise.all([
  1639. // import('jszip'),
  1640. // import('file-saver'),
  1641. // ]);
  1642. // const zip = new JSZip();
  1643. // let _fileName =
  1644. // (data.name && data.name.replace(/\//g, '_').replace(/:/g, '_')) ||
  1645. // 'le5le.meta2d';
  1646. // //处理cdn图片地址
  1647. // const _zip: any = zip.folder(`${_fileName}`);
  1648. // _zip.file(
  1649. // 'data.json',
  1650. // JSON.stringify(data).replaceAll(cdn, '').replaceAll(upCdn, '')
  1651. // );
  1652. // await Promise.all([
  1653. // zipBkImg(_zip),
  1654. // zipImages(_zip, meta2d.store.data.pens),
  1655. // zipFiles(_zip),
  1656. // ]);
  1657. // const blob = await zip.generateAsync({ type: 'blob' });
  1658. // saveAs(blob, `${_fileName}.zip`);
  1659. // };
  1660. // async function zipBkImg(zip: JSZip) {
  1661. // let img = meta2d.store.data.bkImage;
  1662. // if (img) {
  1663. // if (img.startsWith('/') || img.startsWith(cdn) || img.startsWith(upCdn)) {
  1664. // const pngs = await getTemPngs([img.replace(cdn, '').replace(upCdn, '')]);
  1665. // await zipImage(zip, img, pngs[img.replace(cdn, '').replace(upCdn, '')]);
  1666. // }
  1667. // }
  1668. // }
  1669. // enum Frame {
  1670. // vue2,
  1671. // vue3,
  1672. // react,
  1673. // html
  1674. // }
  1675. const downloadVue3 = async () => {
  1676. downloadAsFrame(Frame.vue3);
  1677. };
  1678. const downloadVue2 = async () => {
  1679. downloadAsFrame(Frame.vue2);
  1680. };
  1681. const downloadReact = async () => {
  1682. downloadAsFrame(Frame.react);
  1683. };
  1684. async function downloadAsFrame(type: Frame) {
  1685. if (!(user && user.id)) {
  1686. MessagePlugin.warning(noLoginTip);
  1687. return;
  1688. }
  1689. // if (user.vipDesc !== '旗舰会员') {
  1690. // MessagePlugin.info('需要开通旗舰会员~');
  1691. // gotoAccount();
  1692. // return;
  1693. // }
  1694. downloadType = type;
  1695. await preGetPayList();
  1696. }
  1697. // const preFrameDownload = async (type: Frame) => {
  1698. // frameFlag = type;
  1699. // MessagePlugin.info('正在下载打包中,可能需要几分钟,请耐心等待...');
  1700. // zip3D(
  1701. // type === Frame.vue3 ? 'toVue3' : type === Frame.vue2 ? 'toVue2' : 'toReact'
  1702. // );
  1703. // zip2D(
  1704. // type === Frame.vue3 ? 'downloadVue3' : type === Frame.vue2 ? 'downloadVue2' : 'downloadReact'
  1705. // );
  1706. // const data: any = meta2d.data();
  1707. // if (data._id) delete data._id;
  1708. // if (data.id) delete data.id;
  1709. // if (data.image) delete data.image;
  1710. // data.userId = user.id;
  1711. // checkData(data);
  1712. // const [{ default: JSZip }, { saveAs }] = await Promise.all([
  1713. // import('jszip'),
  1714. // import('file-saver'),
  1715. // ]);
  1716. // const zip = new JSZip();
  1717. // let _fileName =
  1718. // (data.name && data.name.replace(/\//g, '_').replace(/:/g, '_')) ||
  1719. // 'le5le.meta2d';
  1720. // //处理付费svg
  1721. // if (Object.keys(data.paths).length >= 3) {
  1722. // //简单判断有无svg图元
  1723. // const res: any = await axios.post('/api/paid/2d/component', {
  1724. // type: 'SVG线性图元',
  1725. // });
  1726. // if (res.list.length === 1 && !res.list[0].name) {
  1727. // //已经购买全部
  1728. // for (let key of Object.keys(data.paths)) {
  1729. // let path = data.paths[key];
  1730. // if (
  1731. // path.indexOf('-1.18Zm4-1') !== -1 ||
  1732. // path.indexOf('-1.19Zm4-1') !== -1 ||
  1733. // path.indexOf('2.85ZM') !== -1 ||
  1734. // path.indexOf('-1-2.39.3') !== -1
  1735. // ) {
  1736. // data.paths[key] = '';
  1737. // }
  1738. // }
  1739. // } else {
  1740. // //购买部分
  1741. // let purchasedList = res.list.map((i) => i.name);
  1742. // data.pens.forEach((pen) => {
  1743. // if (pen.name === 'svgPath' && pen.svgUrl) {
  1744. // if (purchasedList.includes(pen.svgUrl)) {
  1745. // pen.pathId = null;
  1746. // }
  1747. // }
  1748. // });
  1749. // }
  1750. // }
  1751. // const _zip: any = zip.folder(`${_fileName}`);
  1752. // _zip.file(
  1753. // `${type === Frame.vue3
  1754. // ? 'meta2d-vue3'
  1755. // : type === Frame.vue2
  1756. // ? 'meta2d-vue2'
  1757. // : 'meta2d-react'
  1758. // }/public/json/data.json`,
  1759. // JSON.stringify(data).replaceAll(cdn, '').replaceAll(upCdn, '')
  1760. // );
  1761. // await Promise.all([
  1762. // zipJs(_zip),
  1763. // zipBkImg(_zip),
  1764. // zipImages(_zip, meta2d.store.data.pens),
  1765. // type === Frame.vue3
  1766. // ? zipVue3Files(_zip)
  1767. // : type === Frame.vue2
  1768. // ? zipVue2Files(_zip)
  1769. // : zipReactFiles(_zip),
  1770. // zipIotPens(_zip),
  1771. // ]);
  1772. // const blob = await zip.generateAsync({ type: 'blob' });
  1773. // saveAs(blob, `${_fileName}.zip`);
  1774. // frameFlag = -1;
  1775. // }
  1776. // async function zipIotPens(zip: JSZip) {
  1777. // //处理控件
  1778. // const js = await get2dComponentJs();
  1779. // zip.file(`${frameFlag === Frame.vue3
  1780. // ? 'meta2d-vue3'
  1781. // : frameFlag === Frame.vue2
  1782. // ? 'meta2d-vue2'
  1783. // : 'meta2d-react'
  1784. // }/public/js/2d-components.js`, js, { createFolders: true });
  1785. // const res: Blob = await axios.get('/view/js/r.js', {
  1786. // responseType: 'blob',
  1787. // });
  1788. // zip.file(`${frameFlag === Frame.vue3
  1789. // ? 'meta2d-vue3'
  1790. // : frameFlag === Frame.vue2
  1791. // ? 'meta2d-vue2'
  1792. // : 'meta2d-react'
  1793. // }/public/js/r.js`, res, { createFolders: true });
  1794. // }
  1795. // async function zipJs(zip: JSZip) {
  1796. // const files = ['/view/js/marked.min.js', '/view/js/lcjs.iife.js'];
  1797. // await Promise.all(
  1798. // files.map(async (filePath) => {
  1799. // const res: Blob = await axios.get(filePath, {
  1800. // responseType: 'blob',
  1801. // });
  1802. // zip.file(
  1803. // `${frameFlag === Frame.vue3
  1804. // ? 'meta2d-vue3'
  1805. // : frameFlag === Frame.vue2
  1806. // ? 'meta2d-vue2'
  1807. // : 'meta2d-react'
  1808. // }/public` + filePath.replace('/view', ''),
  1809. // res,
  1810. // { createFolders: true }
  1811. // );
  1812. // })
  1813. // );
  1814. // }
  1815. // async function _zipVue3Files(zip: JSZip) {
  1816. // const files = [
  1817. // '/view/js/marked.min.js',
  1818. // '/view/js/lcjs.iife.js',
  1819. // '/view/vue3/Meta2d.vue',
  1820. // '/view/index.html',
  1821. // '/view/js/meta2d.js',
  1822. // '/view/使用说明.md',
  1823. // ] as const;
  1824. // // 文件同时加载
  1825. // await Promise.all(files.map((filePath) => zipFile(zip, filePath)));
  1826. // }
  1827. //新
  1828. // async function zipVue3Files(zip: JSZip) {
  1829. // const files = [
  1830. // '/view/meta2d-vue3/src/components/Meta2d.vue',
  1831. // '/view/meta2d-vue3/src/App.vue',
  1832. // '/view/meta2d-vue3/src/main.js',
  1833. // '/view/meta2d-vue3/src/style.css',
  1834. // '/view/meta2d-vue3/index.html',
  1835. // '/view/meta2d-vue3/package.json',
  1836. // '/view/meta2d-vue3/README.md',
  1837. // '/view/meta2d-vue3/vite.config.js',
  1838. // ] as const;
  1839. // // 文件同时加载
  1840. // await Promise.all(files.map((filePath) => zipFile(zip, filePath)));
  1841. // }
  1842. // async function _zipVue2Files(zip: JSZip) {
  1843. // const files = [
  1844. // '/view/js/marked.min.js',
  1845. // '/view/js/lcjs.iife.js',
  1846. // '/view/vue2/Meta2d.vue',
  1847. // '/view/index.html',
  1848. // '/view/js/meta2d.js',
  1849. // '/view/使用说明.md',
  1850. // ] as const;
  1851. // // 文件同时加载
  1852. // await Promise.all(files.map((filePath) => zipFile(zip, filePath)));
  1853. // }
  1854. // async function zipVue2Files(zip: JSZip) {
  1855. // const files = [
  1856. // '/view/meta2d-vue2/src/components/Meta2d.vue',
  1857. // '/view/meta2d-vue2/src/App.vue',
  1858. // '/view/meta2d-vue2/src/main.js',
  1859. // // '/view/meta2d-vue2/src/style.css',
  1860. // '/view/meta2d-vue2/public/index.html',
  1861. // '/view/meta2d-vue2/package.json',
  1862. // '/view/meta2d-vue2/README.md',
  1863. // // '/view/meta2d-vue3/vite.config.js',
  1864. // ] as const;
  1865. // // 文件同时加载
  1866. // await Promise.all(files.map((filePath) => zipFile(zip, filePath)));
  1867. // }
  1868. // async function _zipReactFiles(zip: JSZip) {
  1869. // const files = [
  1870. // '/view/js/marked.min.js',
  1871. // '/view/js/lcjs.iife.js',
  1872. // '/view/react/Meta2d.jsx',
  1873. // '/view/react/Meta2d.css',
  1874. // '/view/index.html',
  1875. // '/view/js/meta2d.js',
  1876. // '/view/使用说明.md',
  1877. // ] as const;
  1878. // // 文件同时加载
  1879. // await Promise.all(files.map((filePath) => zipFile(zip, filePath)));
  1880. // }
  1881. // async function zipReactFiles(zip: JSZip) {
  1882. // const files = [
  1883. // '/view/meta2d-react/src/index.css',
  1884. // '/view/meta2d-react/src/index.js',
  1885. // '/view/meta2d-react/src/Meta2d.css',
  1886. // '/view/meta2d-react/src/Meta2d.jsx',
  1887. // '/view/meta2d-react/package.json',
  1888. // '/view/meta2d-react/README.md',
  1889. // '/view/meta2d-react/public/index.html',
  1890. // ] as const;
  1891. // // 文件同时加载
  1892. // await Promise.all(files.map((filePath) => zipFile(zip, filePath)));
  1893. // }
  1894. // async function zipFiles(zip: JSZip) {
  1895. // const files = [
  1896. // '/view/js/marked.min.js',
  1897. // '/view/js/lcjs.iife.js',
  1898. // '/view/js/index.js',
  1899. // '/view/js/meta2d.js',
  1900. // '/view/index.html',
  1901. // '/view/index.css',
  1902. // '/view/favicon.ico',
  1903. // '/view/使用说明.pdf',
  1904. // ] as const;
  1905. // // 文件同时加载
  1906. // await Promise.all(files.map((filePath) => zipFile(zip, filePath)));
  1907. // }
  1908. // async function zipFile(zip: JSZip, filePath: string) {
  1909. // const res: Blob = await axios.get(
  1910. // (cdn ? cdn + '/v' : import.meta.env.BASE_URL.slice(0, -1)) + filePath,
  1911. // {
  1912. // responseType: 'blob',
  1913. // }
  1914. // );
  1915. // zip.file(filePath.replace('/view', ''), res, { createFolders: true });
  1916. // }
  1917. // /**
  1918. // * 图片放到 zip 里
  1919. // * @param pens 可以是非具有 calculative 的 pen
  1920. // */
  1921. // async function zipImages(zip: JSZip, pens: Pen[]) {
  1922. // if (!pens) {
  1923. // return;
  1924. // }
  1925. // // 不止 image 上有图片, strokeImage ,backgroundImage 也有图片
  1926. // const imageKeys = [
  1927. // {
  1928. // string: 'image',
  1929. // },
  1930. // { string: 'strokeImage' },
  1931. // { string: 'backgroundImage' },
  1932. // ] as const;
  1933. // const images: string[] = [];
  1934. // for (const pen of pens) {
  1935. // for (const i of imageKeys) {
  1936. // const image = pen[i.string];
  1937. // if (image) {
  1938. // // HTMLImageElement 无法精确控制图片格式
  1939. // if (
  1940. // image.startsWith('/') ||
  1941. // image.startsWith(cdn) ||
  1942. // image.startsWith(upCdn)
  1943. // ) {
  1944. // // 只考虑相对路径下的 image ,绝对路径图片无需下载
  1945. // if (!images.includes(image)) {
  1946. // images.push(image);
  1947. // }
  1948. // }
  1949. // }
  1950. // }
  1951. // // 无需递归遍历子节点,现在所有的节点都在外层
  1952. // }
  1953. // //付费pngs
  1954. // const pngs = await getTemPngs(images.map(i => i.replace(cdn, '').replace(upCdn, '')));
  1955. // await Promise.all(images.map((image) => zipImage(zip, image, pngs[image.replace(cdn, '').replace(upCdn, '')])));
  1956. // }
  1957. // async function zipImage(zip: JSZip, image: string, temImage?: string) {
  1958. // const res: Blob = await axios.get(temImage || image, {
  1959. // responseType: 'blob',
  1960. // // params: {
  1961. // // isZip: true,
  1962. // // },
  1963. // });
  1964. // zip.file(
  1965. // (frameFlag === -1
  1966. // ? ''
  1967. // : `${frameFlag === Frame.vue3
  1968. // ? 'meta2d-vue3'
  1969. // : frameFlag === Frame.vue2
  1970. // ? 'meta2d-vue2'
  1971. // : 'meta2d-react'
  1972. // }/public`) + (cdn ? image.replace(cdn, '').replace(upCdn, '') : image),
  1973. // res,
  1974. // {
  1975. // createFolders: true,
  1976. // }
  1977. // );
  1978. // }
  1979. const downloadImageTips =
  1980. '无法下载,宽度不合法,画布可能没有画笔/画布大小超出浏览器最大限制';
  1981. const downloadPng = () => {
  1982. if (!meta2d.store.data.pens.length) {
  1983. MessagePlugin.warning(downloadImageTips);
  1984. return;
  1985. }
  1986. try {
  1987. meta2d.downloadPng();
  1988. } catch (e) {
  1989. MessagePlugin.warning(downloadImageTips);
  1990. }
  1991. };
  1992. async function getIconDefs(url: string) {
  1993. let res: any = await axios.get(url);
  1994. let str = res.match(/@font-face([\s\S]*?)\}/)[1];
  1995. str = `@font-face ${str} }`;
  1996. return str;
  1997. }
  1998. const downloadSvg = async () => {
  1999. // await import('@/assets/canvas2svg');
  2000. for (const pen of meta2d.store.data.pens) {
  2001. if (pen.calculative.img) {
  2002. //重新生成绘制图片
  2003. pen.onRenderPenRaw?.(pen);
  2004. }
  2005. }
  2006. if (!C2S) {
  2007. MessagePlugin.error('请先加载乐吾乐官网下的canvas2svg.js');
  2008. return;
  2009. }
  2010. const rect: any = meta2d.getRect();
  2011. if (!isFinite(rect.width)) {
  2012. MessagePlugin.error(downloadImageTips);
  2013. return;
  2014. }
  2015. rect.x -= 10;
  2016. rect.y -= 10;
  2017. const ctx = new C2S(rect.width + 20, rect.height + 20);
  2018. ctx.textBaseline = 'middle';
  2019. ctx.strokeStyle = getGlobalColor(meta2d.store);
  2020. for (const pen of meta2d.store.data.pens) {
  2021. // 不使用 calculative.inView 的原因是,如果 pen 在 view 之外,那么它的 calculative.inView 为 false,但是它的绘制还是需要的
  2022. if (!isShowChild(pen, meta2d.store) || pen.visible == false) {
  2023. continue;
  2024. }
  2025. meta2d.renderPenRaw(ctx, pen, rect);
  2026. }
  2027. let mySerializedSVG = ctx.getSerializedSvg();
  2028. let icon_pens = meta2d.store.data.pens.filter(
  2029. (item) => item.iconFamily && item.icon
  2030. );
  2031. if (icon_pens && icon_pens.length > 0) {
  2032. let iconList = [
  2033. '/icon/国家电网/iconfont.css',
  2034. '/icon/电气工程/iconfont.css',
  2035. '/icon/通用图标/iconfont.css',
  2036. ];
  2037. let defsList: any = await Promise.all(
  2038. iconList.map((item) => getIconDefs(item))
  2039. );
  2040. mySerializedSVG = mySerializedSVG.replace(
  2041. '<defs/>',
  2042. `<defs>
  2043. <style type="text/css">
  2044. ${defsList.join('\n')}
  2045. </style>
  2046. {{bk}}
  2047. </defs>
  2048. {{bkRect}}`
  2049. );
  2050. }
  2051. /* mySerializedSVG = mySerializedSVG.replace(
  2052. '<defs/>',
  2053. `<defs>
  2054. <style type="text/css">
  2055. @font-face {
  2056. font-family: 'ticon';
  2057. src: url('icon/通用图标/iconfont.ttf') format('truetype');
  2058. }
  2059. </style>
  2060. {{bk}}
  2061. </defs>
  2062. {{bkRect}}`
  2063. );
  2064. */
  2065. if (meta2d.store.data.background) {
  2066. mySerializedSVG = mySerializedSVG.replace('{{bk}}', '');
  2067. mySerializedSVG = mySerializedSVG.replace(
  2068. '{{bkRect}}',
  2069. `<rect x="0" y="0" width="100%" height="100%" fill="${meta2d.store.data.background}"></rect>`
  2070. );
  2071. } else {
  2072. mySerializedSVG = mySerializedSVG.replace('{{bk}}', '');
  2073. mySerializedSVG = mySerializedSVG.replace('{{bkRect}}', '');
  2074. }
  2075. mySerializedSVG = mySerializedSVG.replace(/--le5le--/g, '&#x');
  2076. const urlObject: any = (window as any).URL || window;
  2077. const export_blob = new Blob([mySerializedSVG]);
  2078. const url = urlObject.createObjectURL(export_blob);
  2079. const a = document.createElement('a');
  2080. a.setAttribute(
  2081. 'download',
  2082. `${(meta2d.store.data as Meta2dBackData).name || 'le5le.meta2d'}.svg`
  2083. );
  2084. a.setAttribute('href', url);
  2085. const evt = document.createEvent('MouseEvents');
  2086. evt.initEvent('click', true, true);
  2087. a.dispatchEvent(evt);
  2088. };
  2089. const onUndo = () => {
  2090. meta2d.undo();
  2091. };
  2092. const onRedo = () => {
  2093. meta2d.redo();
  2094. };
  2095. const onCut = () => {
  2096. meta2d.cut();
  2097. };
  2098. const onCopy = () => {
  2099. meta2d.copy();
  2100. };
  2101. const onPaste = () => {
  2102. meta2d.paste();
  2103. };
  2104. const onAll = () => {
  2105. meta2d.activeAll();
  2106. };
  2107. const onDelete = () => {
  2108. meta2d.delete();
  2109. };
  2110. const onToggleAnchor = () => {
  2111. //取消连线状态
  2112. // meta2d.store.options.disableAnchor = false;
  2113. if (!meta2d.store.options.disableAnchor) {
  2114. meta2d.canvas.drawingLineName && drawPen();
  2115. meta2d.toggleAnchorMode();
  2116. }
  2117. };
  2118. const onAddAnchorHand = () => {
  2119. meta2d.addAnchorHand();
  2120. };
  2121. const onRemoveAnchorHand = () => {
  2122. meta2d.removeAnchorHand();
  2123. };
  2124. const onToggleAnchorHand = () => {
  2125. meta2d.toggleAnchorHand();
  2126. };
  2127. const onScaleUp = () => {
  2128. const _scale = meta2d.store.data.scale + 0.1;
  2129. meta2d.scale(_scale);
  2130. };
  2131. const onScaleDown = () => {
  2132. const _scale = meta2d.store.data.scale - 0.1;
  2133. meta2d.scale(_scale);
  2134. };
  2135. const autoAnchor = ref(true);
  2136. const onAutoAnchor = () => {
  2137. meta2d.store.options.autoAnchor = !meta2d.store.options.autoAnchor;
  2138. autoAnchor.value = meta2d.store.options.autoAnchor;
  2139. };
  2140. const showAnchor = ref(false);
  2141. const onDisableAnchor = () => {
  2142. meta2d.store.options.disableAnchor = !meta2d.store.options.disableAnchor;
  2143. changeDisableAnchor();
  2144. };
  2145. const changeDisableAnchor = () => {
  2146. const { disableAnchor, autoAnchor } = meta2d.store.options;
  2147. showAnchor.value = !disableAnchor || false;
  2148. if (disableAnchor && autoAnchor) {
  2149. // 禁用瞄点开了,需要关闭自动瞄点
  2150. onAutoAnchor();
  2151. }
  2152. };
  2153. const payListDialog = reactive({
  2154. show: false,
  2155. title:'',
  2156. href:''
  2157. });
  2158. const downloadZipDialog = reactive({
  2159. show: false,
  2160. checked:true,
  2161. expend:false,
  2162. price:0,
  2163. list:[],
  2164. hasJs:false,
  2165. });
  2166. const prePay = async () => {
  2167. let list = [];
  2168. if(data.payDiagram.checked){
  2169. prePayList.pngs.forEach((item) => {
  2170. list.push({
  2171. type: '图片图元',
  2172. name: item,
  2173. });
  2174. });
  2175. prePayList.jsPens.forEach((item) => {
  2176. list.push({
  2177. type: 'JS线性图元',
  2178. name: item,
  2179. });
  2180. });
  2181. prePayList.iotPens.forEach((item) => {
  2182. list.push({
  2183. type: '控件',
  2184. name: item,
  2185. });
  2186. });
  2187. if ([...prePayList.svgPens].includes('*')) {
  2188. list.push({
  2189. type: 'SVG线性图元',
  2190. });
  2191. } else {
  2192. prePayList.svgPens.forEach((item) => {
  2193. list.push({
  2194. type: 'SVG线性图元',
  2195. name: item,
  2196. });
  2197. });
  2198. }
  2199. }
  2200. const res: any = await axios.post('/api/order/deployment/submit', {
  2201. goods:data.payGoods,
  2202. '2ds':list,
  2203. });
  2204. wechatPayDialog.show = true;
  2205. data.order = res;
  2206. };
  2207. const downloadTrial = () => {
  2208. MessagePlugin.info('正在下载打包中,可能需要几分钟,请耐心等待...');
  2209. //下载试用版
  2210. }
  2211. const skipPay = () => {
  2212. //跳过支付,直接下载
  2213. MessagePlugin.info('正在下载打包中,可能需要几分钟,请耐心等待...');
  2214. if (downloadType === Frame.html) {
  2215. preDownload();
  2216. } else {
  2217. preFrameDownload();
  2218. }
  2219. };
  2220. const finishPay = async () => {
  2221. let id = data.order.id;
  2222. const result: { state: number } = await axios.post('/api/order/pay/state', {
  2223. id,
  2224. });
  2225. if (result && result.state) {
  2226. MessagePlugin.success('支付成功');
  2227. wechatPayDialog.show = false;
  2228. if(wechatPayDialog.isZip){
  2229. // downloadZipDialog.show = false;
  2230. wechatPayDialog.isZip = false;
  2231. doDownloadZip();
  2232. }else{
  2233. payListDialog.show = false;
  2234. MessagePlugin.info('正在下载打包中,可能需要几分钟,请耐心等待...');
  2235. if (downloadType === Frame.html) {
  2236. preDownload();
  2237. } else {
  2238. preFrameDownload();
  2239. }
  2240. }
  2241. } else {
  2242. MessagePlugin.error('支付失败');
  2243. // wechatPayDialog.show = false;
  2244. }
  2245. };
  2246. const finalPrice = computed(() => {
  2247. let total = 0;
  2248. let price = 0;
  2249. data.goods.forEach((item, index) => {
  2250. if (item.checked) {
  2251. total += item.unPurchased;
  2252. price += item.unPurchased * item.unitPrice;
  2253. }
  2254. });
  2255. return {
  2256. total,
  2257. price,
  2258. };
  2259. });
  2260. const wechatPayDialog = reactive({
  2261. show: false,
  2262. isZip:false
  2263. });
  2264. const emit = defineEmits(['success']);
  2265. const onSuccess = (success: boolean) => {
  2266. emit('success', success);
  2267. };
  2268. </script>
  2269. <style lang="postcss" scoped>
  2270. .app-header {
  2271. display: flex;
  2272. height: 40px;
  2273. background-color: var(--color-background);
  2274. position: relative;
  2275. z-index: 2;
  2276. .logo {
  2277. display: flex;
  2278. padding: 0 16px;
  2279. align-items: center;
  2280. font-size: 14px;
  2281. font-weight: 500;
  2282. img {
  2283. height: 20px;
  2284. margin-right: 6px;
  2285. }
  2286. }
  2287. a {
  2288. display: flex;
  2289. padding: 0 8px;
  2290. margin: 0 8px;
  2291. align-items: center;
  2292. color: var(--color);
  2293. text-decoration: none;
  2294. white-space: nowrap;
  2295. &:hover {
  2296. color: var(--color-primary);
  2297. }
  2298. svg {
  2299. font-size: 15px;
  2300. margin: 2px 4px 0 0;
  2301. }
  2302. &.active {
  2303. background-color: var(--color-primary);
  2304. color: #ffffff;
  2305. }
  2306. }
  2307. input {
  2308. font-size: var(--font-size);
  2309. flex-grow: 1;
  2310. background: none;
  2311. outline: none;
  2312. border: none;
  2313. text-align: center;
  2314. color: var(--color-title);
  2315. }
  2316. }
  2317. .pay-box{
  2318. background: rgba(175,202,255,0.04);
  2319. border-radius: 4px;
  2320. margin-bottom:24px;
  2321. padding:20px 24px;
  2322. position:relative;
  2323. display:flex;
  2324. .pay-up{
  2325. display:flex;
  2326. }
  2327. :deep(.t-checkbox__label){
  2328. font-size: 16px;
  2329. color: #6e7b91;
  2330. margin-left:16px;
  2331. }
  2332. .pay-title{
  2333. font-size: 16px;
  2334. color: #6e7b91;
  2335. .t-icon{
  2336. margin-top:-5px;
  2337. margin-left:12px;
  2338. }
  2339. :deep(.t-checkbox__input){
  2340. background:#fff0;
  2341. }
  2342. :deep(.t-is-checked){
  2343. .t-checkbox__input{
  2344. background:var(--color-primary);
  2345. }
  2346. }
  2347. }
  2348. .pay-price{
  2349. position:absolute;
  2350. right:24px;
  2351. color:#4480F9;
  2352. display:flex;
  2353. p:nth-child(2){
  2354. font-size: 20px;
  2355. }
  2356. }
  2357. .pay-down{
  2358. margin-top:16px;
  2359. display:flex;
  2360. flex-wrap:wrap;
  2361. /* justify-content:space-between; */
  2362. /* padding-top:24px; */
  2363. max-height: 200px;
  2364. overflow-y: scroll;
  2365. &>div{
  2366. width: 48px;
  2367. height: 48px;
  2368. background: #1c283b;
  2369. border-radius: 4px;
  2370. margin-right:2.5px;
  2371. margin-bottom:2.5px;
  2372. &:nth-child(12n){
  2373. margin-right: 0px;
  2374. }
  2375. img{
  2376. margin:4px;
  2377. width:40px;
  2378. height:40px;
  2379. }
  2380. .l-icon{
  2381. /* width: 80px; */
  2382. /* height: 80px; */
  2383. /* margin:8px; */
  2384. font-size:24px;
  2385. margin:12px;
  2386. }
  2387. &>div{
  2388. margin: 8px 12px;
  2389. }
  2390. }
  2391. }
  2392. }
  2393. .pay-footer{
  2394. display:flex;
  2395. margin-bottom: -48px;
  2396. margin-left:24px;
  2397. font-size: 14px;
  2398. &>div{
  2399. color:#4480F9;
  2400. display:flex;
  2401. p:nth-child(2){
  2402. font-size: 24px;
  2403. font-weight: 800;
  2404. margin-top:-3px;
  2405. }
  2406. p:nth-child(1){
  2407. margin:0px 4px;
  2408. }
  2409. }
  2410. }
  2411. .pay-diagram{
  2412. flex-direction:column;
  2413. }
  2414. /* .pay-dialog {
  2415. background-color: red;
  2416. } */
  2417. /* .pay-body {
  2418. height: 300px;
  2419. overflow-y: scroll;
  2420. margin-bottom: 30px;
  2421. .t-collapse {
  2422. border: 0px;
  2423. :deep(.t-collapse-panel__wrapper .t-collapse-panel__header) {
  2424. border-bottom: 0px;
  2425. }
  2426. :deep(.t-collapse-panel__wrapper .t-collapse-panel__body) {
  2427. background: #fff0;
  2428. border-bottom: 0px;
  2429. .t-collapse-panel__content {
  2430. padding: 0;
  2431. color: #c1c8d7;
  2432. }
  2433. }
  2434. }
  2435. } */
  2436. /* .pay-line {
  2437. display: flex;
  2438. height: 54px;
  2439. background-color: #afcaff0a;
  2440. margin-top: 1px;
  2441. div {
  2442. width: 30%;
  2443. text-align: center;
  2444. line-height: 54px;
  2445. :deep(.t-image) {
  2446. width: 40px;
  2447. height: 40px;
  2448. margin-top: 7px;
  2449. }
  2450. :deep(.pay-svg) {
  2451. .t-image {
  2452. background: #fff;
  2453. }
  2454. }
  2455. .l-icon {
  2456. width: 40px;
  2457. height: 40px;
  2458. margin-top: 7px;
  2459. width: 30%;
  2460. }
  2461. }
  2462. .pay-p{
  2463. overflow:hidden;
  2464. text-overflow:ellipsis;
  2465. white-space:nowrap;
  2466. }
  2467. & > div:first-child {
  2468. width: 40%;
  2469. display: flex;
  2470. }
  2471. } */
  2472. /* .pay-tip {
  2473. height: 54px;
  2474. width: 100%;
  2475. position: relative;
  2476. p {
  2477. position: absolute;
  2478. right: 16px;
  2479. color: var(--color-desc);
  2480. }
  2481. }
  2482. .pay-footer {
  2483. margin-bottom: -42px;
  2484. position: relative;
  2485. .pay-price {
  2486. position: absolute;
  2487. right: 215px;
  2488. margin-left: 50px;
  2489. align-items: flex-end;
  2490. line-height: 10px;
  2491. p{
  2492. vertical-align: bottom;
  2493. line-height: normal;
  2494. }
  2495. p:nth-child(2) {
  2496. font-size: 32px;
  2497. font-weight: Semibold;
  2498. color: #4480f9;
  2499. line-height: 20px;
  2500. }
  2501. p:nth-child(1) {
  2502. font-size: 14px;
  2503. color: #4480f9;
  2504. }
  2505. }
  2506. } */
  2507. /* .pay-title {
  2508. margin: 18px 0px 12px 18px;
  2509. } */
  2510. </style>