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 19 kB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  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="公共镜像(云脑1)" name="first" v-loading="loading">
  13. <div class="ui sixteen wide column">
  14. <div class="ui two column stackable grid">
  15. <div class="column">
  16. <el-input placeholder="请输入镜像名称关健词" v-model="search" class="input-with-select" @keyup.enter.native="searchName()">
  17. <el-button id="success" slot="append" icon="el-icon-search" @click="searchName()">搜索</el-button>
  18. </el-input>
  19. </div>
  20. <!-- <div class="column right aligned">
  21. <el-dropdown>
  22. <span class="el-dropdown-link">
  23. 排序<i class="el-icon-caret-bottom"></i>
  24. </span>
  25. <el-dropdown-menu slot="dropdown">
  26. <el-dropdown-item>最早创建</el-dropdown-item>
  27. <el-dropdown-item>最新创建</el-dropdown-item>
  28. <el-dropdown-item divided>按镜像字母顺序排序</el-dropdown-item>
  29. <el-dropdown-item>按镜像字母逆序排序</el-dropdown-item>
  30. </el-dropdown-menu>
  31. </el-dropdown>
  32. </div> -->
  33. </div>
  34. </div>
  35. <el-row style="margin-top:15px;">
  36. <el-table
  37. :data="tableData"
  38. style="width: 100%"
  39. :header-cell-style="tableHeaderStyle"
  40. :default-sort="{prop:'createtime',order:'descending'}">
  41. <el-table-column
  42. label="镜像名称"
  43. width="350"
  44. align="left"
  45. prop="name"
  46. sortable
  47. >
  48. <template slot-scope="scope">
  49. <a class="text-over" style="cursor:default;color:#426290" :title="scope.row.name">{{ scope.row.name }}</a>
  50. </template>
  51. </el-table-column>
  52. <el-table-column
  53. label="文件路径/镜像描述"
  54. width="450"
  55. align="left"
  56. >
  57. <template slot-scope="scope">
  58. <el-tooltip class="item" effect="dark" content="点击复制文件路径" placement="top">
  59. <a class="text-over" style="display:block;" @click="copyUrl(scope.row.place)">{{ scope.row.place }}</a>
  60. </el-tooltip>
  61. <span class="text-over" :title="scope.row.description | clearP">{{ scope.row.description | clearP}}</span>
  62. </template>
  63. </el-table-column>
  64. <el-table-column
  65. prop="provider"
  66. label="提供者"
  67. width="120"
  68. align="left"
  69. sortable>
  70. </el-table-column>
  71. <el-table-column
  72. prop="createtime"
  73. label="创建时间"
  74. align="center"
  75. sortable>
  76. <template slot-scope="scope">
  77. {{scope.row.createtime | transformTimestamp}}
  78. </template>
  79. </el-table-column>
  80. </el-table>
  81. </el-row>
  82. <div class="ui container" style="margin-top:50px;text-align:center">
  83. <el-pagination
  84. background
  85. @size-change="handleSizeChange"
  86. @current-change="handleCurrentChange"
  87. :current-page="currentPage"
  88. :page-size="pageSize"
  89. :page-sizes="[5,10,20]"
  90. layout="total, sizes, prev, pager, next, jumper"
  91. :total="totalNum">
  92. </el-pagination>
  93. </div>
  94. </el-tab-pane>
  95. <el-tab-pane label="自定义镜像(云脑1)" name="second" v-loading="loading1">
  96. <div class="ui sixteen wide column">
  97. <div class="ui two column stackable grid">
  98. <div class="column">
  99. <el-input placeholder="请输入镜像名称关健词" v-model="search" class="input-with-select" @keyup.enter.native="searchName()">
  100. <el-button slot="append" id="success" icon="el-icon-search" @click="searchName()">搜索</el-button>
  101. </el-input>
  102. </div>
  103. <!-- <div class="column right aligned">
  104. <el-dropdown>
  105. <span class="el-dropdown-link">
  106. 排序<i class="el-icon-caret-bottom"></i>
  107. </span>
  108. <el-dropdown-menu slot="dropdown">
  109. <el-dropdown-item>最早创建</el-dropdown-item>
  110. <el-dropdown-item>最新创建</el-dropdown-item>
  111. <el-dropdown-item divided>按镜像字母顺序排序</el-dropdown-item>
  112. <el-dropdown-item>按镜像字母逆序排序</el-dropdown-item>
  113. </el-dropdown-menu>
  114. </el-dropdown>
  115. </div> -->
  116. </div>
  117. </div>
  118. <el-row style="margin-top:15px;">
  119. <el-table
  120. :data="tableData1"
  121. style="width: 100%"
  122. :header-cell-style="tableHeaderStyle"
  123. :default-sort="{prop:'createtime',order:'descending'}">
  124. <el-table-column
  125. label="镜像名称"
  126. width="350"
  127. align="left"
  128. prop="name"
  129. sortable
  130. >
  131. <template slot-scope="scope">
  132. <a class="text-over" :title="scope.row.name" style="cursor:default;color:#426290">{{ scope.row.name }}</a>
  133. </template>
  134. </el-table-column>
  135. <el-table-column
  136. label="文件路径/镜像描述"
  137. width="450"
  138. align="left"
  139. >
  140. <template slot-scope="scope">
  141. <el-tooltip class="item" effect="dark" content="点击复制文件路径" placement="top">
  142. <a class="text-over" style="display:block;" @click="copyUrl(scope.row.place)">{{ scope.row.place }}</a>
  143. </el-tooltip>
  144. <span class="text-over" :title="scope.row.description | clearP">{{ scope.row.description | clearP }}</span>
  145. </template>
  146. </el-table-column>
  147. <el-table-column
  148. prop="provider"
  149. label="提供者"
  150. width="120"
  151. align="left"
  152. sortable>
  153. </el-table-column>
  154. <el-table-column
  155. prop="createtime"
  156. label="创建时间"
  157. align="center"
  158. sortable>
  159. <template slot-scope="scope">
  160. {{scope.row.createtime | transformTimestamp}}
  161. </template>
  162. </el-table-column>
  163. </el-table>
  164. </el-row>
  165. <div class="ui container" style="margin-top:50px;text-align:center">
  166. <el-pagination
  167. background
  168. @size-change="handleSizeChange1"
  169. @current-change="handleCurrentChange1"
  170. :current-page="currentPage1"
  171. :page-size="pageSize1"
  172. :page-sizes="[5,10,20]"
  173. layout="total, sizes, prev, pager, next, jumper"
  174. :total="totalNum1">
  175. </el-pagination>
  176. </div>
  177. </el-tab-pane>
  178. <el-tab-pane label="公共镜像(云脑2)" name="third">
  179. <div class="ui sixteen wide column">
  180. <div class="ui two column stackable grid">
  181. <div class="column">
  182. <el-input placeholder="请输入镜像名称关健词" v-model="search" class="input-with-select">
  183. <el-button slot="append" id="success" icon="el-icon-search">搜索</el-button>
  184. </el-input>
  185. </div>
  186. <!-- <div class="column right aligned">
  187. <el-dropdown>
  188. <span class="el-dropdown-link">
  189. 排序<i class="el-icon-caret-bottom"></i>
  190. </span>
  191. <el-dropdown-menu slot="dropdown">
  192. <el-dropdown-item>最早创建</el-dropdown-item>
  193. <el-dropdown-item>最新创建</el-dropdown-item>
  194. <el-dropdown-item divided>按镜像字母顺序排序</el-dropdown-item>
  195. <el-dropdown-item>按镜像字母逆序排序</el-dropdown-item>
  196. </el-dropdown-menu>
  197. </el-dropdown>
  198. </div> -->
  199. </div>
  200. </div>
  201. <el-empty :image-size="200"></el-empty>
  202. </el-tab-pane>
  203. <el-tab-pane label="自定义镜像(云脑2)" name="fourth">
  204. <div class="ui sixteen wide column">
  205. <div class="ui two column stackable grid">
  206. <div class="column">
  207. <el-input placeholder="请输入镜像名称关健词" v-model="search" class="input-with-select">
  208. <el-button slot="append" id="success" icon="el-icon-search">搜索</el-button>
  209. </el-input>
  210. </div>
  211. <!-- <div class="column right aligned">
  212. <el-dropdown>
  213. <span class="el-dropdown-link">
  214. 排序<i class="el-icon-caret-bottom"></i>
  215. </span>
  216. <el-dropdown-menu slot="dropdown">
  217. <el-dropdown-item>最早创建</el-dropdown-item>
  218. <el-dropdown-item>最新创建</el-dropdown-item>
  219. <el-dropdown-item divided>按镜像字母顺序排序</el-dropdown-item>
  220. <el-dropdown-item>按镜像字母逆序排序</el-dropdown-item>
  221. </el-dropdown-menu>
  222. </el-dropdown>
  223. </div> -->
  224. </div>
  225. </div>
  226. <el-empty :image-size="200"></el-empty>
  227. </el-tab-pane>
  228. </el-tabs>
  229. </div>
  230. </div>
  231. </template>
  232. <script>
  233. const {_AppSubUrl, _StaticUrlPrefix, csrf} = window.config;
  234. export default {
  235. components: {
  236. },
  237. data() {
  238. return {
  239. activeName: 'first',
  240. search:'',
  241. currentPage:1,
  242. pageSize:10,
  243. totalNum:0,
  244. params:{page:1,size:10,name:''},
  245. tableData: [],
  246. loading:false,
  247. currentPage1:1,
  248. pageSize1:10,
  249. totalNum1:0,
  250. params1:{page:1,size:10,name:''},
  251. tableData1: [],
  252. loading1:false
  253. };
  254. },
  255. methods: {
  256. handleClick(tab, event) {
  257. if(tab.name=="first"){
  258. this.getImageList()
  259. }
  260. if(tab.name=="second"){
  261. this.getImageList1()
  262. }
  263. },
  264. tableHeaderStyle({row,column,rowIndex,columnIndex}){
  265. if(rowIndex===0){
  266. return 'background:#f5f5f6;color:#606266'
  267. }
  268. },
  269. handleSizeChange(val){
  270. this.params.size = val
  271. this.getImageList()
  272. },
  273. handleCurrentChange(val){
  274. console.log(val)
  275. this.params.page = val
  276. this.getImageList()
  277. },
  278. handleSizeChange1(val){
  279. this.params1.size = val
  280. this.getImageList1()
  281. },
  282. handleCurrentChange1(val){
  283. this.params1.page = val
  284. this.getImageList1()
  285. },
  286. getImageList(){
  287. this.loading = true
  288. this.$axios.get('/explore/images/public',{
  289. params:this.params
  290. }).then((res)=>{
  291. this.totalNum = res.data.count
  292. this.tableData = res.data.rows
  293. this.loading = false
  294. })
  295. },
  296. getImageList1(){
  297. this.loading1 = true
  298. this.$axios.get('/explore/images/custom',{
  299. params:this.params1
  300. }).then((res)=>{
  301. this.totalNum1 = res.data.count
  302. this.tableData1 = res.data.rows
  303. this.loading1 = false
  304. })
  305. },
  306. copyUrl(url){
  307. console.log(url)
  308. const cInput = document.createElement('input')
  309. cInput.value = url
  310. document.body.appendChild(cInput)
  311. cInput.select()
  312. document.execCommand('Copy')
  313. cInput.remove()
  314. },
  315. searchName(){
  316. if(this.activeName=='first'){
  317. this.params.name = this.search
  318. this.params.page = 1
  319. this.getImageList()
  320. }
  321. if(this.activeName=='second'){
  322. this.params1.name = this.search
  323. this.params1.page = 1
  324. this.getImageList1()
  325. }
  326. }
  327. },
  328. filters:{
  329. clearP(value){
  330. console.log("sorce value",value)
  331. if(!value) return ''
  332. const reg = /\<\/?p\>/g;
  333. value = value.replace(reg,'')
  334. console.log("repalace:",value)
  335. return value
  336. },
  337. transformTimestamp(timestamp){
  338. console.log("timestamp",timestamp)
  339. let a = new Date(timestamp).getTime();
  340. const date = new Date(a);
  341. const Y = date.getFullYear() + '-';
  342. const M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
  343. const D = (date.getDate() < 10 ? '0'+date.getDate() : date.getDate()) + ' ';
  344. const h = (date.getHours() < 10 ? '0'+date.getHours() : date.getHours()) + ':';
  345. const m = (date.getMinutes() <10 ? '0'+date.getMinutes() : date.getMinutes()) + ':' ;
  346. const s = (date.getSeconds() <10 ? '0'+date.getSeconds() : date.getSeconds()) ; // 秒
  347. const dateString = Y + M + D + h + m + s;
  348. // console.log('dateString', dateString); // > dateString 2021-07-06 14:23
  349. return dateString;
  350. },
  351. },
  352. watch:{
  353. search(val){
  354. if(!val && this.activeName=='first'){
  355. this.params.name = val
  356. this.getImageList()
  357. }
  358. if(!val && this.activeName=='second'){
  359. this.params1.name = val
  360. this.getImageList1()
  361. }
  362. }
  363. },
  364. mounted() {
  365. this.getImageList()
  366. },
  367. created() {
  368. }
  369. };
  370. </script>
  371. <style scoped>
  372. .header-wrapper {
  373. background-color: #f5f5f6;
  374. padding-top: 15px;
  375. }
  376. .image_text{
  377. padding:25px 0 55px 0 ;
  378. }
  379. #header{
  380. position: relative;
  381. top:-40px;
  382. }
  383. .el-dropdown-menu__item--divided{
  384. border-top: 1px solid blue;
  385. }
  386. .el-table thead{
  387. background-color: #f5f5f6;
  388. }
  389. /deep/ .el-tabs__item:hover{
  390. color: #000;
  391. font-weight: 500;
  392. }
  393. /deep/ .el-tabs__item.is-active {
  394. color: #000;
  395. font-weight: 500;
  396. }
  397. /deep/ .el-tabs__active-bar{
  398. background-color:#000
  399. }
  400. /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active {
  401. background-color: #5bb973;
  402. color: #FFF;
  403. }
  404. /deep/ .el-pagination.is-background .el-pager li.active {
  405. color: #fff;
  406. cursor: default;
  407. }
  408. /deep/ .el-pagination.is-background .el-pager li:hover {
  409. color: #5bb973;
  410. }
  411. /deep/ .el-pagination.is-background .el-pager li:not(.disabled):hover {
  412. color: #5bb973;
  413. }
  414. /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active:hover {
  415. background-color: #5bb973;
  416. color: #FFF;
  417. }
  418. /deep/ .el-pager li.active {
  419. color: #08C0B9;
  420. cursor: default;
  421. }
  422. /deep/ .el-pagination .el-pager li:hover {
  423. color: #08C0B9;
  424. }
  425. /deep/ .el-pagination .el-pager li:not(.disabled):hover {
  426. color: #08C0B9;
  427. }
  428. /* /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active{
  429. background-color: #5bb973;
  430. color: #000;
  431. } */
  432. /* /deep/ .el-pager li:hover{
  433. color: #000;
  434. } */
  435. #success{
  436. background-color: #5bb973;
  437. color: white;
  438. }
  439. .text-over{
  440. overflow: hidden;
  441. text-overflow: ellipsis;
  442. vertical-align: middle;
  443. white-space: nowrap;
  444. }
  445. </style>