You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

Images.vue 37 kB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067
  1. <template>
  2. <div>
  3. <div class="header-wrapper">
  4. <div class="ui container">
  5. <el-row class="image_text">
  6. <h1>云脑镜像</h1>
  7. </el-row>
  8. </div>
  9. </div>
  10. <div class="ui container" id="header">
  11. <el-tabs v-model="activeName" @tab-click="handleClick">
  12. <el-tab-pane label="公开镜像" name="first" v-loading="loadingPublic">
  13. <template v-if="tableDataPublic.length !== 0">
  14. <el-row style="align-items: center; display: flex">
  15. <el-col :span="12">
  16. <div>
  17. <el-checkbox v-model="checked">仅显示平台推荐</el-checkbox>
  18. </div>
  19. </el-col>
  20. <el-col :span="4"
  21. ><div style="visibility: hidden">TODO</div></el-col
  22. >
  23. <el-col :span="8">
  24. <div>
  25. <el-input
  26. placeholder="搜镜像Tag/描述/标签..."
  27. v-model="search"
  28. class="input-with-select"
  29. @keyup.enter.native="searchName()"
  30. >
  31. <el-button
  32. id="success"
  33. slot="append"
  34. icon="el-icon-search"
  35. @click="searchName()"
  36. >搜索</el-button
  37. >
  38. </el-input>
  39. </div>
  40. </el-col>
  41. </el-row>
  42. <el-row style="margin-top: 15px">
  43. <el-table
  44. :data="tableDataPublic"
  45. style="width: 100%"
  46. :header-cell-style="tableHeaderStyle"
  47. >
  48. <el-table-column
  49. label="镜像Tag"
  50. min-width="19%"
  51. align="left"
  52. prop="tag"
  53. >
  54. <template slot-scope="scope">
  55. <div style="display: flex; align-items: center">
  56. <a class="text-over image_title" :title="scope.row.tag">{{
  57. scope.row.tag
  58. }}</a>
  59. <img
  60. v-if="scope.row.type == 5"
  61. src="/img/jian.svg"
  62. style="margin-left: 0.5rem"
  63. />
  64. </div>
  65. </template>
  66. </el-table-column>
  67. <el-table-column
  68. label="镜像描述"
  69. min-width="28%"
  70. align="left"
  71. prop="description"
  72. >
  73. <template slot-scope="scope">
  74. <div class="image_desc" :title="scope.row.description">
  75. {{ scope.row.description }}
  76. </div>
  77. <div v-if="!!scope.row.topics">
  78. <span
  79. v-for="(topic, index) in scope.row.topics"
  80. class="ui repo-topic label topic"
  81. style="cursor: default"
  82. >{{ topic }}</span
  83. >
  84. </div>
  85. </template>
  86. </el-table-column>
  87. <el-table-column
  88. prop="cloudbrainType"
  89. label="可用集群"
  90. min-width="10%"
  91. align="center"
  92. >
  93. <template slot-scope="scope">
  94. {{ scope.row.cloudbrainType | transformType }}
  95. </template>
  96. </el-table-column>
  97. <el-table-column
  98. prop="creator"
  99. label="创建者"
  100. min-width="8%"
  101. align="center"
  102. >
  103. <template slot-scope="scope">
  104. <a
  105. v-if="scope.row.userName || scope.row.relAvatarLink"
  106. :href="'/' + scope.row.userName"
  107. :title="scope.row.userName"
  108. >
  109. <img
  110. :src="scope.row.relAvatarLink"
  111. class="ui avatar image"
  112. />
  113. </a>
  114. <a v-else
  115. ><img
  116. class="ui avatar image"
  117. title="Ghost"
  118. src="/user/avatar/ghost/-1"
  119. /></a>
  120. </template>
  121. </el-table-column>
  122. <el-table-column
  123. prop="updatedUnix"
  124. label="创建时间"
  125. align="center"
  126. min-width="14%"
  127. >
  128. <template slot-scope="scope">
  129. {{ scope.row.updatedUnix | transformTimestamp }}
  130. </template>
  131. </el-table-column>
  132. <el-table-column align="center" min-width="21%" label="操作">
  133. <template slot-scope="scope">
  134. <div
  135. style="
  136. display: flex;
  137. justify-content: flex-end;
  138. align-items: center;
  139. "
  140. >
  141. <div
  142. style="
  143. display: flex;
  144. align-items: center;
  145. cursor: pointer;
  146. padding: 0 1rem;
  147. "
  148. @click="
  149. imageStar(
  150. scope.$index,
  151. scope.row.id,
  152. scope.row.isStar
  153. )
  154. "
  155. >
  156. <svg
  157. width="1.4em"
  158. height="1.4em"
  159. viewBox="0 0 32 32"
  160. class="heart-stroke"
  161. :class="{ stars_active: scope.row.isStar }"
  162. >
  163. <path
  164. d="M4.4 6.54c-1.761 1.643-2.6 3.793-2.36 6.056.24 2.263 1.507 4.521 3.663 6.534a29110.9 29110.9 0 0010.296 9.633l10.297-9.633c2.157-2.013 3.424-4.273 3.664-6.536.24-2.264-.599-4.412-2.36-6.056-1.73-1.613-3.84-2.29-6.097-1.955-1.689.25-3.454 1.078-5.105 2.394l-.4.319-.398-.319c-1.649-1.316-3.414-2.143-5.105-2.394a7.612 7.612 0 00-1.113-.081c-1.838 0-3.541.694-4.983 2.038z"
  165. ></path>
  166. </svg>
  167. <span style="line-height: 2; margin-left: 0.3rem">{{
  168. scope.row.numStars
  169. }}</span>
  170. </div>
  171. <span
  172. style="padding: 0 1rem; color: #0366d6; cursor: pointer"
  173. @click="copyUrl(scope.row.place)"
  174. >复制地址</span
  175. >
  176. </div>
  177. </template>
  178. </el-table-column>
  179. </el-table>
  180. </el-row>
  181. <div
  182. class="ui container"
  183. style="margin-top: 50px; text-align: center"
  184. >
  185. <el-pagination
  186. background
  187. @size-change="handleSizeChangePublic"
  188. @current-change="handleCurrentChangePublic"
  189. :current-page="currentPagePublic"
  190. :page-size="pageSizePublic"
  191. :page-sizes="[5, 10, 15]"
  192. layout="total, sizes, prev, pager, next, jumper"
  193. :total="totalNumPublic"
  194. >
  195. </el-pagination>
  196. </div>
  197. </template>
  198. <template v-else>
  199. <el-row style="align-items: center; display: flex">
  200. <el-col :span="12">
  201. <div>
  202. <el-checkbox v-model="checked">仅显示平台推荐</el-checkbox>
  203. </div>
  204. </el-col>
  205. <el-col :span="4"
  206. ><div style="visibility: hidden">TODO</div></el-col
  207. >
  208. <el-col :span="8">
  209. <div>
  210. <el-input
  211. placeholder="搜镜像Tag/描述/标签..."
  212. v-model="search"
  213. class="input-with-select"
  214. @keyup.enter.native="searchName()"
  215. >
  216. <el-button
  217. id="success"
  218. slot="append"
  219. icon="el-icon-search"
  220. @click="searchName()"
  221. >搜索</el-button
  222. >
  223. </el-input>
  224. </div>
  225. </el-col>
  226. </el-row>
  227. <el-empty :image-size="200"></el-empty>
  228. </template>
  229. </el-tab-pane>
  230. <el-tab-pane label="我的镜像" name="second" v-loading="loadingCustom">
  231. <template v-if="tableDataCustom.length !== 0">
  232. <el-row style="align-items: center; display: flex">
  233. <el-col :span="12">
  234. <div style="visibility: hidden">TODO</div>
  235. </el-col>
  236. <el-col :span="4"
  237. ><div style="visibility: hidden">TODO</div></el-col
  238. >
  239. <el-col :span="8">
  240. <div>
  241. <el-input
  242. placeholder="搜镜像Tag/描述/标签..."
  243. v-model="search"
  244. class="input-with-select"
  245. @keyup.enter.native="searchName()"
  246. >
  247. <el-button
  248. id="success"
  249. slot="append"
  250. icon="el-icon-search"
  251. @click="searchName()"
  252. >搜索</el-button
  253. >
  254. </el-input>
  255. </div>
  256. </el-col>
  257. </el-row>
  258. <el-row style="margin-top: 15px">
  259. <el-table
  260. :data="tableDataCustom"
  261. style="width: 100%"
  262. :header-cell-style="tableHeaderStyle"
  263. >
  264. <el-table-column
  265. label="镜像Tag"
  266. min-width="19%"
  267. align="left"
  268. prop="tag"
  269. >
  270. <template slot-scope="scope">
  271. <div style="display: flex; align-items: center">
  272. <a class="text-over image_title" :title="scope.row.tag">{{
  273. scope.row.tag
  274. }}</a
  275. >&nbsp;&nbsp;&nbsp;
  276. <i
  277. class="ri-lock-2-line"
  278. style="color: #fa8c16"
  279. v-if="scope.row.isPrivate"
  280. ></i>
  281. <img
  282. v-if="scope.row.type == 5"
  283. src="/img/jian.svg"
  284. style="margin-left: 0.5rem"
  285. />
  286. </div>
  287. </template>
  288. </el-table-column>
  289. <el-table-column
  290. label="镜像描述"
  291. min-width="27%"
  292. align="left"
  293. prop="description"
  294. >
  295. <template slot-scope="scope">
  296. <div class="image_desc" :title="scope.row.description">
  297. {{ scope.row.description }}
  298. </div>
  299. <div v-if="!!scope.row.topics">
  300. <span
  301. v-for="(topic, index) in scope.row.topics"
  302. class="ui repo-topic label topic"
  303. style="cursor: default"
  304. >{{ topic }}</span
  305. >
  306. </div>
  307. </template>
  308. </el-table-column>
  309. <el-table-column
  310. prop="cloudbrainType"
  311. label="可用集群"
  312. min-width="9%"
  313. align="center"
  314. >
  315. <template slot-scope="scope">
  316. {{ scope.row.cloudbrainType | transformType }}
  317. </template>
  318. </el-table-column>
  319. <el-table-column
  320. prop="isPrivate"
  321. label="状态"
  322. min-width="10%"
  323. align="center"
  324. >
  325. <template slot-scope="scope">
  326. <div
  327. style="
  328. display: flex;
  329. align-items: center;
  330. justify-content: center;
  331. "
  332. >
  333. <span
  334. v-if="scope.row.isPrivate"
  335. style="color: rgb(250, 140, 22)"
  336. >私有</span
  337. >
  338. <span v-else style="color: rgb(19, 194, 141)">公开</span>
  339. <el-tooltip
  340. v-if="scope.row.status === 0"
  341. class="item"
  342. effect="dark"
  343. content="镜像提交中..."
  344. placement="top"
  345. >
  346. <i class="CREATING" style="margin-left: 0.3rem"></i>
  347. </el-tooltip>
  348. <el-tooltip
  349. v-if="scope.row.status === 2"
  350. class="item"
  351. effect="dark"
  352. content="检测提交镜像是否大小超过20G!"
  353. placement="top"
  354. >
  355. <i class="FAILED" style="margin-left: 0.3rem"></i>
  356. </el-tooltip>
  357. <el-tooltip
  358. v-if="scope.row.status === 1"
  359. class="item"
  360. effect="dark"
  361. content="镜像提交成功"
  362. placement="top"
  363. >
  364. <i class="SUCCEEDED" style="margin-left: 0.3rem"></i>
  365. </el-tooltip>
  366. </div>
  367. </template>
  368. </el-table-column>
  369. <el-table-column
  370. prop="updatedUnix"
  371. label="创建时间"
  372. align="center"
  373. min-width="14%"
  374. >
  375. <template slot-scope="scope">
  376. {{ scope.row.updatedUnix | transformTimestamp }}
  377. </template>
  378. </el-table-column>
  379. <el-table-column align="center" min-width="21%" label="操作">
  380. <template slot-scope="scope">
  381. <div
  382. style="
  383. display: flex;
  384. justify-content: flex-end;
  385. align-items: center;
  386. "
  387. >
  388. <div
  389. style="
  390. display: flex;
  391. align-items: center;
  392. cursor: default;
  393. padding: 0 1rem;
  394. "
  395. >
  396. <svg
  397. width="1.4em"
  398. height="1.4em"
  399. viewBox="0 0 32 32"
  400. class="heart-stroke"
  401. >
  402. <path
  403. d="M4.4 6.54c-1.761 1.643-2.6 3.793-2.36 6.056.24 2.263 1.507 4.521 3.663 6.534a29110.9 29110.9 0 0010.296 9.633l10.297-9.633c2.157-2.013 3.424-4.273 3.664-6.536.24-2.264-.599-4.412-2.36-6.056-1.73-1.613-3.84-2.29-6.097-1.955-1.689.25-3.454 1.078-5.105 2.394l-.4.319-.398-.319c-1.649-1.316-3.414-2.143-5.105-2.394a7.612 7.612 0 00-1.113-.081c-1.838 0-3.541.694-4.983 2.038z"
  404. ></path>
  405. </svg>
  406. <span style="line-height: 2; margin-left: 0.3rem">{{
  407. scope.row.numStars
  408. }}</span>
  409. </div>
  410. <span
  411. style="padding: 0 1rem; color: #0366d6; cursor: pointer"
  412. @click="copyUrl(scope.row.place)"
  413. >复制地址</span
  414. >
  415. <div style="padding-left: 1rem; cursor: pointer">
  416. <el-dropdown size="medium">
  417. <span class="el-dropdown-link">
  418. 更多<i
  419. class="el-icon-arrow-down el-icon--right"
  420. ></i>
  421. </span>
  422. <el-dropdown-menu slot="dropdown">
  423. <el-dropdown-item
  424. @click.native="eidtImage(scope.row.id)"
  425. >编辑</el-dropdown-item
  426. >
  427. <el-dropdown-item
  428. style="color: red"
  429. @click.native="deleteImage(scope.row.id)"
  430. >删除</el-dropdown-item
  431. >
  432. </el-dropdown-menu>
  433. </el-dropdown>
  434. </div>
  435. </div>
  436. </template>
  437. </el-table-column>
  438. </el-table>
  439. </el-row>
  440. <div
  441. class="ui container"
  442. style="margin-top: 50px; text-align: center"
  443. >
  444. <el-pagination
  445. background
  446. @size-change="handleSizeChangeCustom"
  447. @current-change="handleCurrentChangeCustom"
  448. :current-page="currentPageCustom"
  449. :page-size="pageSizeCustom"
  450. :page-sizes="[5, 10, 15]"
  451. layout="total, sizes, prev, pager, next, jumper"
  452. :total="totalNumCustom"
  453. >
  454. </el-pagination>
  455. </div>
  456. </template>
  457. <template v-else>
  458. <el-row style="align-items: center; display: flex">
  459. <el-col :span="12">
  460. <div style="visibility: hidden">TODO</div>
  461. </el-col>
  462. <el-col :span="4"
  463. ><div style="visibility: hidden">TODO</div></el-col
  464. >
  465. <el-col :span="8">
  466. <div>
  467. <el-input
  468. placeholder="搜镜像Tag/描述/标签..."
  469. v-model="search"
  470. class="input-with-select"
  471. @keyup.enter.native="searchName()"
  472. >
  473. <el-button
  474. id="success"
  475. slot="append"
  476. icon="el-icon-search"
  477. @click="searchName()"
  478. >搜索</el-button
  479. >
  480. </el-input>
  481. </div>
  482. </el-col>
  483. </el-row>
  484. <el-empty :image-size="200"></el-empty>
  485. </template>
  486. </el-tab-pane>
  487. <el-tab-pane label="我收藏的镜像" name="third">
  488. <template v-if="tableDataStar.length !== 0">
  489. <el-row style="align-items: center; display: flex">
  490. <el-col :span="12">
  491. <div style="visibility: hidden">TODO</div>
  492. </el-col>
  493. <el-col :span="4"
  494. ><div style="visibility: hidden">TODO</div></el-col
  495. >
  496. <el-col :span="8">
  497. <div>
  498. <el-input
  499. placeholder="搜镜像Tag/描述/标签..."
  500. v-model="search"
  501. class="input-with-select"
  502. @keyup.enter.native="searchName()"
  503. >
  504. <el-button
  505. id="success"
  506. slot="append"
  507. icon="el-icon-search"
  508. @click="searchName()"
  509. >搜索</el-button
  510. >
  511. </el-input>
  512. </div>
  513. </el-col>
  514. </el-row>
  515. <el-row style="margin-top: 15px">
  516. <el-table
  517. :data="tableDataStar"
  518. style="width: 100%"
  519. :header-cell-style="tableHeaderStyle"
  520. >
  521. <el-table-column
  522. label="镜像Tag"
  523. min-width="19%"
  524. align="left"
  525. prop="tag"
  526. >
  527. <template slot-scope="scope">
  528. <div style="display: flex; align-items: center">
  529. <a class="text-over image_title" :title="scope.row.tag">{{
  530. scope.row.tag
  531. }}</a>
  532. <img
  533. v-if="scope.row.type == 5"
  534. src="/img/jian.svg"
  535. style="margin-left: 0.5rem"
  536. />
  537. </div>
  538. </template>
  539. </el-table-column>
  540. <el-table-column
  541. label="镜像描述"
  542. min-width="28%"
  543. align="left"
  544. prop="description"
  545. >
  546. <template slot-scope="scope">
  547. <div class="image_desc" :title="scope.row.description">
  548. {{ scope.row.description }}
  549. </div>
  550. <div v-if="!!scope.row.topics">
  551. <span
  552. v-for="(topic, index) in scope.row.topics"
  553. class="ui repo-topic label topic"
  554. style="cursor: default"
  555. >{{ topic }}</span
  556. >
  557. </div>
  558. </template>
  559. </el-table-column>
  560. <el-table-column
  561. prop="cloudbrainType"
  562. label="可用集群"
  563. min-width="10%"
  564. align="center"
  565. >
  566. <template slot-scope="scope">
  567. {{ scope.row.cloudbrainType | transformType }}
  568. </template>
  569. </el-table-column>
  570. <el-table-column
  571. prop="creator"
  572. label="创建者"
  573. min-width="8%"
  574. align="center"
  575. >
  576. <template slot-scope="scope">
  577. <a
  578. v-if="scope.row.userName || scope.row.relAvatarLink"
  579. :href="'/' + scope.row.userName"
  580. :title="scope.row.userName"
  581. >
  582. <img
  583. :src="scope.row.relAvatarLink"
  584. class="ui avatar image"
  585. />
  586. </a>
  587. <a v-else
  588. ><img
  589. class="ui avatar image"
  590. title="Ghost"
  591. src="/user/avatar/ghost/-1"
  592. /></a>
  593. </template>
  594. </el-table-column>
  595. <el-table-column
  596. prop="updatedUnix"
  597. label="创建时间"
  598. align="center"
  599. min-width="14%"
  600. >
  601. <template slot-scope="scope">
  602. {{ scope.row.updatedUnix | transformTimestamp }}
  603. </template>
  604. </el-table-column>
  605. <el-table-column align="center" min-width="21%" label="操作">
  606. <template slot-scope="scope">
  607. <div
  608. style="
  609. display: flex;
  610. justify-content: flex-end;
  611. align-items: center;
  612. "
  613. >
  614. <div
  615. style="
  616. display: flex;
  617. align-items: center;
  618. cursor: pointer;
  619. padding: 0 1rem;
  620. "
  621. @click="imageUnstar(scope.row.id)"
  622. >
  623. <svg
  624. width="1.4em"
  625. height="1.4em"
  626. viewBox="0 0 32 32"
  627. class="heart-stroke stars_active"
  628. >
  629. <path
  630. d="M4.4 6.54c-1.761 1.643-2.6 3.793-2.36 6.056.24 2.263 1.507 4.521 3.663 6.534a29110.9 29110.9 0 0010.296 9.633l10.297-9.633c2.157-2.013 3.424-4.273 3.664-6.536.24-2.264-.599-4.412-2.36-6.056-1.73-1.613-3.84-2.29-6.097-1.955-1.689.25-3.454 1.078-5.105 2.394l-.4.319-.398-.319c-1.649-1.316-3.414-2.143-5.105-2.394a7.612 7.612 0 00-1.113-.081c-1.838 0-3.541.694-4.983 2.038z"
  631. ></path>
  632. </svg>
  633. <span style="line-height: 2; margin-left: 0.3rem">{{
  634. scope.row.numStars
  635. }}</span>
  636. </div>
  637. <span
  638. style="padding: 0 1rem; color: #0366d6; cursor: pointer"
  639. @click="copyUrl(scope.row.place)"
  640. >复制地址</span
  641. >
  642. </div>
  643. </template>
  644. </el-table-column>
  645. </el-table>
  646. </el-row>
  647. <div
  648. class="ui container"
  649. style="margin-top: 50px; text-align: center"
  650. >
  651. <el-pagination
  652. background
  653. @size-change="handleSizeChangeStar"
  654. @current-change="handleCurrentChangeStar"
  655. :current-page="currentPageStar"
  656. :page-size="pageSizeStar"
  657. :page-sizes="[5, 10, 15]"
  658. layout="total, sizes, prev, pager, next, jumper"
  659. :total="totalNumStar"
  660. >
  661. </el-pagination>
  662. </div>
  663. </template>
  664. <template v-else>
  665. <el-row style="align-items: center; display: flex">
  666. <el-col :span="12">
  667. <div style="visibility: hidden">TODO</div>
  668. </el-col>
  669. <el-col :span="4"
  670. ><div style="visibility: hidden">TODO</div></el-col
  671. >
  672. <el-col :span="8">
  673. <div>
  674. <el-input
  675. placeholder="搜镜像Tag/描述/标签..."
  676. v-model="search"
  677. class="input-with-select"
  678. @keyup.enter.native="searchName()"
  679. >
  680. <el-button
  681. id="success"
  682. slot="append"
  683. icon="el-icon-search"
  684. @click="searchName()"
  685. >搜索</el-button
  686. >
  687. </el-input>
  688. </div>
  689. </el-col>
  690. </el-row>
  691. <el-empty :image-size="200"></el-empty>
  692. </template>
  693. </el-tab-pane>
  694. </el-tabs>
  695. </div>
  696. </div>
  697. </template>
  698. <script>
  699. const { _AppSubUrl, _StaticUrlPrefix, csrf } = window.config;
  700. export default {
  701. components: {},
  702. data() {
  703. return {
  704. activeName: "first",
  705. search: "",
  706. checked: false,
  707. currentPagePublic: 1,
  708. pageSizePublic: 10,
  709. totalNumPublic: 0,
  710. paramsPublic: { page: 1, pageSize: 10, q: "", recommend: false },
  711. tableDataPublic: [],
  712. loadingPublic: false,
  713. currentPageCustom: 1,
  714. pageSizeCustom: 10,
  715. totalNumCustom: 0,
  716. paramsCustom: { page: 1, pageSize: 10, q: "" },
  717. tableDataCustom: [],
  718. starCustom: [],
  719. loadingCustom: false,
  720. refreshCustomTimer: null,
  721. currentPageStar: 1,
  722. pageSizeStar: 10,
  723. totalNumStar: 0,
  724. paramsStar: { page: 1, pageSize: 10, q: "" },
  725. tableDataStar: [],
  726. loadingStar: false,
  727. };
  728. },
  729. methods: {
  730. handleClick(tab, event) {
  731. this.search = "";
  732. this.stopImageListCustomRefresh();
  733. if (tab.name == "first") {
  734. this.paramsPublic.q = "";
  735. this.getImageListPublic();
  736. }
  737. if (tab.name == "second") {
  738. this.getImageListCustom();
  739. }
  740. if (tab.name == "third") {
  741. this.getImageListStar();
  742. }
  743. },
  744. tableHeaderStyle({ row, column, rowIndex, columnIndex }) {
  745. if (rowIndex === 0) {
  746. return "background:#f5f5f6;color:#606266";
  747. }
  748. },
  749. handleSizeChangePublic(val) {
  750. this.paramsPublic.pageSize = val;
  751. this.getImageListPublic();
  752. },
  753. handleCurrentChangePublic(val) {
  754. this.currentPagePublic = val;
  755. this.paramsPublic.page = val;
  756. this.getImageListPublic();
  757. },
  758. handleSizeChangeCustom(val) {
  759. this.paramsCustom.pageSize = val;
  760. this.getImageListCustom();
  761. },
  762. handleCurrentChangeCustom(val) {
  763. this.paramsCustom.page = val;
  764. this.getImageListCustom();
  765. },
  766. handleSizeChangeStar(val) {
  767. this.paramsStar.pageSize = val;
  768. this.getImageListStar();
  769. },
  770. handleCurrentChangeStar(val) {
  771. this.paramsStar.page = val;
  772. this.getImageListStar();
  773. },
  774. getImageListPublic() {
  775. this.loadingPublic = true;
  776. this.$axios
  777. .get("/explore/images/public", {
  778. params: this.paramsPublic,
  779. })
  780. .then((res) => {
  781. this.totalNumPublic = res.data.count;
  782. this.tableDataPublic = res.data.images;
  783. this.loadingPublic = false;
  784. });
  785. },
  786. getImageListCustom() {
  787. this.loadingCustom = true;
  788. this.$axios
  789. .get("/explore/images/custom", {
  790. params: this.paramsCustom,
  791. })
  792. .then((res) => {
  793. this.totalNumCustom = res.data.count;
  794. this.tableDataCustom = res.data.images;
  795. this.tableDataCustom.forEach((element) => {
  796. this.starCustom.push({ id: element.id });
  797. });
  798. this.loadingCustom = false;
  799. this.getImageListCustomRefresh();
  800. });
  801. },
  802. getImageListCustomRefresh() {
  803. this.stopImageListCustomRefresh();
  804. this.refreshCustomTimer = setInterval(() => {
  805. this.tableDataCustom.forEach((item) => {
  806. if (item.status === 0) {
  807. this.$axios.get(`/image/${item.id}`, {}).then((res) => {
  808. const newData = res.data;
  809. this.tableDataCustom.forEach((it) => {
  810. if (it.id === newData.id) {
  811. it.status = newData.status;
  812. }
  813. });
  814. });
  815. }
  816. });
  817. }, 5000);
  818. },
  819. stopImageListCustomRefresh() {
  820. this.refreshCustomTimer && clearInterval(this.refreshCustomTimer);
  821. },
  822. getImageListStar() {
  823. this.loadingStar = true;
  824. this.$axios
  825. .get("/explore/images/star", {
  826. params: this.paramsStar,
  827. })
  828. .then((res) => {
  829. this.totalNumStar = res.data.count;
  830. this.tableDataStar = res.data.images;
  831. this.loadingStar = false;
  832. });
  833. },
  834. deleteImage(id) {
  835. let flag = 1;
  836. let _this = this;
  837. $(".ui.basic.modal.images")
  838. .modal({
  839. onDeny: function () {
  840. flag = false;
  841. },
  842. onApprove: function () {
  843. _this.$axios.delete("/image/" + id).then((res) => {
  844. _this.getImageListCustom();
  845. });
  846. flag = true;
  847. },
  848. onHidden: function () {
  849. if (flag == false) {
  850. $(".alert")
  851. .html("您已取消操作")
  852. .removeClass("alert-success")
  853. .addClass("alert-danger")
  854. .show()
  855. .delay(1500)
  856. .fadeOut();
  857. } else {
  858. $(".alert")
  859. .html("删除成功")
  860. .removeClass("alert-danger")
  861. .addClass("alert-success")
  862. .show()
  863. .delay(1500)
  864. .fadeOut();
  865. }
  866. },
  867. })
  868. .modal("show");
  869. },
  870. eidtImage(id) {
  871. location.href = `/image/${id}/imageSquare`;
  872. },
  873. imageStar(index, id, isStar) {
  874. if (isStar) {
  875. this.$axios.put(`/image/${id}/action/unstar`).then((res) => {
  876. if (res.data.Code == 0) {
  877. this.tableDataPublic[index].numStars =
  878. this.tableDataPublic[index].numStars - 1;
  879. this.tableDataPublic[index].isStar = false;
  880. } else {
  881. console.log(res.data.Message);
  882. }
  883. });
  884. } else {
  885. this.$axios.put(`/image/${id}/action/star`).then((res) => {
  886. if (res.data.Code == 0) {
  887. this.tableDataPublic[index].numStars =
  888. this.tableDataPublic[index].numStars + 1;
  889. this.tableDataPublic[index].isStar = true;
  890. } else {
  891. console.log(res.data.Message);
  892. }
  893. });
  894. }
  895. },
  896. imageUnstar(id) {
  897. this.$axios.put(`/image/${id}/action/unstar`).then((res) => {
  898. if (res.data.Code == 0) {
  899. this.getImageListStar();
  900. } else {
  901. console.log(res.data.Message);
  902. }
  903. });
  904. },
  905. copyUrl(url) {
  906. const cInput = document.createElement("input");
  907. cInput.value = url;
  908. document.body.appendChild(cInput);
  909. cInput.select();
  910. document.execCommand("Copy");
  911. cInput.remove();
  912. $("body").toast({
  913. message: "复制成功!",
  914. showProgress: "bottom",
  915. showIcon: "check circle",
  916. class: "info",
  917. position: "top right",
  918. });
  919. },
  920. searchName() {
  921. if (this.activeName == "first") {
  922. this.paramsPublic.q = this.search;
  923. this.paramsPublic.page = 1;
  924. this.getImageListPublic();
  925. }
  926. if (this.activeName == "second") {
  927. this.paramsCustom.q = this.search;
  928. this.paramsCustom.page = 1;
  929. this.getImageListCustom();
  930. }
  931. if (this.activeName == "third") {
  932. this.paramsStar.q = this.search;
  933. this.paramsStar.page = 1;
  934. this.getImageListStar();
  935. }
  936. },
  937. },
  938. filters: {
  939. transformType(val) {
  940. if (val == 0 || val == 2) {
  941. return "GPU";
  942. }
  943. },
  944. transformPravite(val) {
  945. if (val) {
  946. return "私有";
  947. } else {
  948. return "公开";
  949. }
  950. },
  951. transformTimestamp(timestamp) {
  952. const date = new Date(parseInt(timestamp) * 1000);
  953. const Y = date.getFullYear() + "-";
  954. const M =
  955. (date.getMonth() + 1 < 10
  956. ? "0" + (date.getMonth() + 1)
  957. : date.getMonth() + 1) + "-";
  958. const D =
  959. (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " ";
  960. const h =
  961. (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":";
  962. const m =
  963. (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) +
  964. ":";
  965. const s =
  966. date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds(); // 秒
  967. const dateString = Y + M + D + h + m + s;
  968. return dateString;
  969. },
  970. },
  971. watch: {
  972. checked(val) {
  973. this.paramsPublic.page = 1;
  974. this.paramsPublic.recommend = val;
  975. this.currentPagePublic = 1;
  976. this.getImageListPublic();
  977. },
  978. },
  979. mounted() {},
  980. created() {
  981. const params = new URLSearchParams(location.search);
  982. if (params.has("type") && params.get("type") == "myimage") {
  983. this.activeName = "second";
  984. this.getImageListCustom();
  985. } else {
  986. this.getImageListPublic();
  987. }
  988. },
  989. beforeDestroy() {
  990. this.stopImageListCustomRefresh();
  991. },
  992. };
  993. </script>
  994. <style scoped>
  995. .header-wrapper {
  996. background-color: #f5f5f6;
  997. padding-top: 15px;
  998. }
  999. .image_text {
  1000. padding: 25px 0 55px 0;
  1001. }
  1002. #header {
  1003. position: relative;
  1004. top: -40px;
  1005. }
  1006. .el-dropdown-menu__item--divided {
  1007. border-top: 1px solid blue;
  1008. }
  1009. .el-table thead {
  1010. background-color: #f5f5f6;
  1011. }
  1012. /deep/ .el-tabs__item:hover {
  1013. color: #000;
  1014. font-weight: 500;
  1015. }
  1016. /deep/ .el-tabs__item.is-active {
  1017. color: #000;
  1018. font-weight: 500;
  1019. }
  1020. /deep/ .el-tabs__active-bar {
  1021. background-color: #000;
  1022. }
  1023. #success {
  1024. background-color: #5bb973;
  1025. color: white;
  1026. }
  1027. .text-over {
  1028. overflow: hidden;
  1029. text-overflow: ellipsis;
  1030. vertical-align: middle;
  1031. white-space: nowrap;
  1032. }
  1033. .image_title {
  1034. display: inline-block;
  1035. cursor: default;
  1036. color: rgb(66, 98, 144);
  1037. }
  1038. .image_desc {
  1039. -webkit-line-clamp: 2;
  1040. -webkit-box-orient: vertical;
  1041. display: -webkit-box;
  1042. text-overflow: ellipsis;
  1043. overflow: hidden;
  1044. }
  1045. .heart-stroke {
  1046. stroke: #fa8c16;
  1047. stroke-width: 2;
  1048. fill: #fff;
  1049. }
  1050. .stars_active {
  1051. fill: #fa8c16 !important;
  1052. stroke: #fa8c16 !important;
  1053. }
  1054. </style>