themeList.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <div>
  3. <HeaderBar/>
  4. <div class="my-themes">
  5. <div class="container">
  6. <ul class="theme-list">
  7. <li class="theme-item create" @click="create">
  8. <div class="create-area">
  9. <p>创建作品</p>
  10. </div>
  11. </li>
  12. <template v-for="item in list">
  13. <li class="theme-item" @click="toEditor(item)">
  14. <div class="thumb" >
  15. <img src="../../assets/images/default.png" alt="">
  16. </div>
  17. <div class="footer">
  18. <div class="title">{{item.title}}</div>
  19. <div class="content">{{item.description}}</div>
  20. <el-button class="delete" @click.stop="deleteTheme(item)" type="danger">删除</el-button>
  21. </div>
  22. </li>
  23. </template>
  24. </ul>
  25. </div>
  26. </div>
  27. </div>
  28. </template>
  29. <script>
  30. import HeaderBar from '../../components/HeaderBar'
  31. import tools from '../../util/tools'
  32. // import ThemeItem from '../../components/ThemeItem'
  33. export default {
  34. computed: {
  35. list () {
  36. return this.$store.state.editor.themeList
  37. }
  38. },
  39. mounted () {
  40. this.$store.dispatch('getUserThemeList', 'spa')
  41. },
  42. methods: {
  43. toEditor (item) {
  44. this.$store.dispatch('setEditorTheme', item)
  45. this.$store.dispatch('setEditorPage', item.pages[0])
  46. this.$router.replace({ path: '/spaeditor', query: { itemId: item._id } })
  47. },
  48. deleteTheme (item) {
  49. this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
  50. confirmButtonText: '确定',
  51. cancelButtonText: '取消',
  52. type: 'warning'
  53. }).then(() => {
  54. this.$store.dispatch('deleteTheme', item)
  55. this.$message({
  56. type: 'success',
  57. message: '删除成功!'
  58. })
  59. }).catch(() => {
  60. this.$message({
  61. type: 'info',
  62. message: '已取消删除'
  63. })
  64. })
  65. },
  66. create () {
  67. this.$store.dispatch('createTheme', 'spa')
  68. this.$store.dispatch('addPage')
  69. let $this = this
  70. this.$store.dispatch('saveTheme', tools.vue2json(this.$store.state.editor.editorTheme)).then(() => {
  71. this.$router.replace({ path: '/spaeditor', query: { itemId: $this.$store.state.editor.editorTheme._id } })
  72. })
  73. }
  74. },
  75. components: {
  76. HeaderBar
  77. }
  78. }
  79. </script>
  80. <style lang="less" scoped>
  81. .my-themes {
  82. width: 100%;
  83. height: 100%;
  84. background-color: #f2f5f6;
  85. }
  86. .my-themes .container {
  87. width: 1024px;
  88. margin: 0 auto;
  89. padding-top: 20px;
  90. }
  91. .my-themes .theme-list {
  92. overflow: hidden;
  93. }
  94. .theme-item {
  95. width: 230px;
  96. height: 328px;
  97. float: left;
  98. margin-right: 20px;
  99. margin-bottom: 20px;
  100. background: #fff;
  101. }
  102. .theme-item .thumb img {
  103. width: 100%;
  104. height: 230px;
  105. }
  106. .theme-item .footer {
  107. height: 98px;
  108. padding: 10px;
  109. background-color: #fff;
  110. box-sizing: border-box;
  111. position: relative;
  112. }
  113. .theme-item .footer > .title {
  114. color: #4a4a4a;
  115. font-size: 14px;
  116. width: 100%;
  117. overflow: hidden;
  118. text-overflow: ellipsis;
  119. white-space: nowrap;
  120. }
  121. .theme-item .footer > .content {
  122. color: #83817b;
  123. margin-top: 12px;
  124. font-size: 14px;
  125. max-height: 40px;
  126. overflow: hidden;
  127. line-height: 1.5;
  128. }
  129. .footer .delete {
  130. position: absolute;
  131. right: 10px;
  132. bottom: 10px;
  133. }
  134. .theme-item.create {
  135. text-align: center;
  136. }
  137. .theme-item.create .create-area p {
  138. font-size: 20px;
  139. cursor: pointer;
  140. margin-top: 100px;
  141. }
  142. </style>