Header.vue 96 KB

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