ソースを参照

添加 /admin 路由下的子路由和新页面

reghao 2 年 前
コミット
514b2c78fa
3 ファイル変更419 行追加6 行削除
  1. 37 0
      src/router/index.js
  2. 4 6
      src/views/admin/AdminPost.vue
  3. 378 0
      src/views/admin/AdminUser.vue

+ 37 - 0
src/router/index.js

@@ -39,7 +39,14 @@ const PostAnalysis = () => import('views/post/PostAnalysis')
 const MessageIndex = () => import('views/message/Message')
 const DiscoverIndex = () => import('views/home/Discover')
 const BdMap = () => import('views/home/BdMap')
+
+const Admin = () => import('views/admin/AdminUser')
+const AdminUser = () => import('views/admin/AdminUser')
 const AdminPost = () => import('views/admin/AdminPost')
+const AdminPostVideo = () => import('views/admin/AdminPost')
+const AdminPostAudio = () => import('views/admin/AdminPost')
+const AdminPostImage = () => import('views/admin/AdminPost')
+const AdminPostArticle = () => import('views/admin/AdminPost')
 
 // 使用安装路由插件
 Vue.use(VueRouter)
@@ -281,9 +288,39 @@ const routes = [
   },
   {
     path: '/admin',
+    name: 'Admin',
+    component: Admin
+  },
+  {
+    path: '/admin/user',
+    name: 'AdminUser',
+    component: AdminUser
+  },
+  {
+    path: '/admin/post',
     name: 'AdminPost',
     component: AdminPost
   },
+  {
+    path: '/admin/post/video',
+    name: 'AdminPostVideo',
+    component: AdminPostVideo
+  },
+  {
+    path: '/admin/post/image',
+    name: 'AdminPostImage',
+    component: AdminPostImage
+  },
+  {
+    path: '/admin/post/audio',
+    name: 'AdminPostAudio',
+    component: AdminPostAudio
+  },
+  {
+    path: '/admin/post/article',
+    name: 'AdminPostArticle',
+    component: AdminPostArticle
+  },
   {
     path: '*',
     name: '404',

+ 4 - 6
src/views/admin/AdminPost.vue

@@ -324,9 +324,8 @@ export default {
       dataList: [],
       /*************************************************************************/
       navList: [
-        { path: '/post/publish', name: '发布', icon: 'el-icon-upload' },
-        { path: '/post/list', name: '稿件', icon: 'el-icon-files' },
-        { path: '/post/analysis', name: '数据', icon: 'el-icon-data-analysis' }
+        { path: '/admin/user', name: '用户', icon: 'el-icon-user' },
+        { path: '/admin/post', name: '稿件', icon: 'el-icon-files' },
       ],
       activeName: 'video',
       userId: 10001,
@@ -340,7 +339,7 @@ export default {
     }
   },
   created() {
-    document.title = "稿件列表"
+    document.title = "稿件管理"
 
     const path = this.$route.path
     if (path.endsWith("video")) {
@@ -394,7 +393,6 @@ export default {
           }
         }
       })
-      console.log('预览 ' + row.videoId);
     },
     handleEdit(index, row) {
       console.log(row.videoId);
@@ -435,7 +433,7 @@ export default {
       this.goToTab(this.activeName)
     },
     goToTab(activeName) {
-      const path = '/post/' + activeName
+      const path = '/admin/post/' + activeName
       if (this.$route.path === path) {
         this.$router.go(0)
         return

+ 378 - 0
src/views/admin/AdminUser.vue

@@ -0,0 +1,378 @@
+<template>
+  <el-row>
+    <el-col :md="2">
+      <el-menu
+        :default-active="this.$route.path"
+        router
+        class="el-menu-vertical-demo"
+      >
+        <el-menu-item v-for="(item,i) in navList" :key="i" :index="item.path">
+          <i :class="item.icon" />
+          <span slot="title">{{ item.name }}</span>
+        </el-menu-item>
+      </el-menu>
+    </el-col>
+    <el-col :md="22">
+      <el-row>
+        <el-row :md="6" :sm="12" :xs="12">
+          <el-table
+            :data="dataList"
+            style="width: 100%"
+          >
+            <el-table-column
+              type="index">
+            </el-table-column>
+            <el-table-column
+              prop="pubDate"
+              label="注册时间">
+            </el-table-column>
+            <el-table-column
+              prop="coverUrl"
+              label="头像"
+              width="80">
+              <template   slot-scope="scope">
+                <el-image :src="scope.row.coverUrl" min-width="40" height="30" />
+              </template>
+            </el-table-column>
+            <el-table-column
+              prop="videoId"
+              label="用户 ID">
+              <template slot-scope="scope">
+                <router-link target="_blank" :to="`/video/${scope.row.videoId}`">
+                  <span>{{scope.row.videoId}}</span>
+                </router-link>
+              </template>
+            </el-table-column>
+            <el-table-column
+              prop="title"
+              label="用户名">
+            </el-table-column>
+            <el-table-column
+              prop="description"
+              label="签名">
+            </el-table-column>
+            <el-table-column
+              prop="scope"
+              label="状态">
+              <template slot-scope="scope">
+                <el-tooltip class="item" effect="dark" content="点击修改视频可见范围" placement="top-end">
+                  <el-button
+                    v-if="scope.row.scope === 1"
+                    size="mini"
+                    @click="handleScope(scope.$index, scope.row)">所有人可见</el-button>
+                  <el-button
+                    v-else-if="scope.row.scope === 2"
+                    size="mini"
+                    type="success"
+                    @click="handleScope(scope.$index, scope.row)">VIP 可见</el-button>
+                  <el-button
+                    v-else-if="scope.row.scope === 3"
+                    size="mini"
+                    type="warning"
+                    @click="handleScope(scope.$index, scope.row)">验证码可见</el-button>
+                  <el-button
+                    v-else
+                    size="mini"
+                    type="danger"
+                    @click="handleScope(scope.$index, scope.row)">本人可见</el-button>
+                </el-tooltip>
+              </template>
+            </el-table-column>
+            <el-table-column
+              prop="scope"
+              label="审核状态">
+              <template slot-scope="scope">
+                <el-tag v-if="scope.row.status === 1" :type="'warning'" disable-transitions>
+                  审核中
+                </el-tag>
+                <el-tag v-else-if="scope.row.status === 2" :type="'success'" disable-transitions>
+                  审核通过
+                </el-tag>
+                <el-tag v-else-if="scope.row.status === 3" :type="'danger'" disable-transitions>
+                  审核未通过
+                </el-tag>
+                <el-tag v-else :type="'danger'" disable-transitions>
+                  下架
+                </el-tag>
+              </template>
+            </el-table-column>
+            <el-table-column label="操作" width="210">
+              <template slot-scope="scope">
+                <el-button
+                  size="mini"
+                  @click="handlePreview(scope.$index, scope.row)">预览</el-button>
+                <el-button
+                  size="mini"
+                  @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
+                <el-button
+                  size="mini"
+                  type="danger"
+                  @click="handleDelete(scope.$index, scope.row)">删除</el-button>
+              </template>
+            </el-table-column>
+          </el-table>
+        </el-row>
+      </el-row>
+      <el-row>
+        <el-col :span="22" class="pagination">
+          <el-pagination
+            background
+            :small="screenWidth <= 768"
+            layout="prev, pager, next"
+            :page-size="pageSize"
+            :current-page="currentPage"
+            :total="totalSize"
+            @current-change="handleCurrentChange"
+            @prev-click="handleCurrentChange"
+            @next-click="handleCurrentChange"
+          />
+        </el-col>
+      </el-row>
+    </el-col>
+
+    <!-- 修改视频可见范围对话框 -->
+    <el-dialog
+      append-to-body
+      :visible.sync="showEditScopeDialog"
+      width="30%"
+      center
+    >
+      <el-card class="box-card">
+        <div slot="header" class="clearfix">
+          <span>修改视频可见范围</span>
+          <el-button style="float: right; padding: 3px 0" type="text" @click="onUpdateVideoScope">更新</el-button>
+        </div>
+        <div class="text item">
+          <el-form ref="form" :model="form" label-width="80px">
+            <el-form-item label="可见范围">
+              <el-select v-model="form.scope" placeholder="选择可见范围">
+                <el-option label="所有人可见" value="1" />
+                <el-option label="验证码可见" value="2" />
+                <el-option label="VIP 可见" value="3" />
+                <el-option label="仅自己可见" value="4" />
+              </el-select>
+            </el-form-item>
+          </el-form>
+        </div>
+      </el-card>
+    </el-dialog>
+    <!-- 视频预览对话框 -->
+    <el-dialog
+      title="预览视频"
+      append-to-body
+      :visible.sync="showPreviewDialog"
+      :before-close="handleDialogClose"
+      width="70%"
+      center
+    >
+      <template>
+        <video-preview-player :video-prop.sync="this.videoProp"/>
+      </template>
+    </el-dialog>
+  </el-row>
+</template>
+
+<script>
+import VideoPreviewPlayer from 'components/VideoPreviewPlayer'
+
+import {userVideoPost, updateVideoScope, videoInfo, deleteVideo} from "@/api/video";
+import {getUserAlbums} from "@/api/image";
+import { getUserAudio } from "@/api/audio";
+
+export default {
+  name: 'AdminPost',
+  components: { VideoPreviewPlayer },
+  data() {
+    return {
+      // 屏幕宽度, 为了控制分页条的大小
+      screenWidth: document.body.clientWidth,
+      currentPage: 1,
+      pageSize: 12,
+      totalSize: 0,
+      dataList: [],
+      /*************************************************************************/
+      navList: [
+        { path: '/admin/user', name: '用户', icon: 'el-icon-user' },
+        { path: '/admin/post', name: '稿件', icon: 'el-icon-files' },
+      ],
+      userId: 10001,
+      showPreviewDialog: false,
+      videoProp: null,
+      showEditScopeDialog: false,
+      form: {
+        videoId: null,
+        scope: null
+      }
+    }
+  },
+  created() {
+    document.title = "用户管理"
+    this.getData()
+  },
+  watch: {
+    $route(){
+      this.$router.go()
+    }
+  },
+  methods: {
+    handleCurrentChange(pageNumber) {
+      this.currentPage = pageNumber
+      this.getData()
+      // 回到顶部
+      scrollTo(0, 0)
+    },
+    handleScope(index, row) {
+      this.form.videoId = row.videoId
+      this.form.scope = row.scope
+      this.showEditScopeDialog = true
+    },
+    handleDialogClose(done) {
+      this.showPreviewDialog = false
+      this.videoProp = {
+        videoId: null,
+        play: false
+      }
+      done()
+    },
+    handlePreview(index, row) {
+      videoInfo(row.videoId).then(res => {
+        if (res.code === 0) {
+          this.showPreviewDialog = true
+          this.videoProp = {
+            videoId: res.data.videoId,
+            play: true
+          }
+        }
+      })
+      console.log('预览 ' + row.videoId);
+    },
+    handleEdit(index, row) {
+      console.log(row.videoId);
+      const path = '/post/edit/video/' + row.videoId
+      this.$router.push(path)
+    },
+    handleDelete(index, row) {
+      deleteVideo(row.videoId).then(res => {
+         if (res.code === 0) {
+           this.$notify({
+             title: '提示',
+             message: '视频稿件已删除',
+             type: 'warning',
+             duration: 3000
+           })
+           this.$router.go(0)
+         }
+      })
+    },
+    handleEditImage(index, row) {
+      console.log(row.videoId);
+      const path = '/post/edit/album/' + row.albumId
+      this.$router.push(path)
+    },
+    handleDeleteImage(index, row) {
+      console.log(row.videoId);
+    },
+    handleEditAudio(index, row) {
+      console.log(row.videoId);
+      const path = '/post/edit/audio/' + row.audioId
+      this.$router.push(path)
+    },
+    handleDeleteAudio(index, row) {
+      console.log(row.videoId);
+    },
+    getData() {
+      this.dataList = []
+      userVideoPost(this.currentPage).then(res => {
+        if (res.code === 0) {
+          const resData = res.data
+          this.dataList = resData.list
+          this.totalSize = resData.totalSize
+
+          if (this.totalSize !== 0) {
+            this.showEmpty = false
+          } else {
+            this.showEmpty = true
+          }
+        } else {
+          this.$notify({
+            title: '提示',
+            message: res.msg,
+            type: 'warning',
+            duration: 3000
+          })
+        }
+      }).catch(error => {
+        this.$notify({
+          title: '提示',
+          message: error.message,
+          type: 'error',
+          duration: 3000
+        })
+      })
+    },
+    onUpdateVideoScope() {
+      this.showEditScopeDialog = false
+      updateVideoScope(this.form).then(res => {
+        if (res.code === 0) {
+          this.$notify({
+            title: '提示',
+            message: '视频可见范围已更新',
+            type: 'warning',
+            duration: 3000
+          })
+        }
+      }).catch(error => {
+        this.$notify({
+          title: '提示',
+          message: error.message,
+          type: 'warning',
+          duration: 3000
+        })
+      })
+    }
+  }
+}
+</script>
+
+<style>
+.uploader-example {
+  width: 500px;
+  padding: 15px;
+  margin: 40px auto 0;
+  font-size: 12px;
+  box-shadow: 0 0 10px rgba(0, 0, 0, .4);
+}
+.uploader-example .uploader-btn {
+  margin-right: 4px;
+}
+.uploader-example .uploader-list {
+  max-height: 440px;
+  overflow: auto;
+  overflow-x: hidden;
+  overflow-y: auto;
+}
+
+.avatar-uploader .el-upload {
+  border: 1px dashed #d9d9d9;
+  border-radius: 6px;
+  cursor: pointer;
+  position: relative;
+  overflow: hidden;
+}
+.avatar-uploader .el-upload:hover {
+  border-color: #409EFF;
+}
+.avatar-uploader-icon {
+  font-size: 28px;
+  color: #8c939d;
+  width: 320px;
+  height: 240px;
+  line-height: 178px;
+  text-align: center;
+}
+.avatar {
+  width: 320px;
+  height: 240px;
+  display: block;
+}
+</style>