Skip to content

Commit

Permalink
基本的管理后台
Browse files Browse the repository at this point in the history
  • Loading branch information
MonoLogueChi committed Feb 28, 2020
1 parent 185e146 commit 6bb262a
Show file tree
Hide file tree
Showing 8 changed files with 396 additions and 30 deletions.
6 changes: 6 additions & 0 deletions Danmaku/clientapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Danmaku/clientapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"eslint": "^5.16.0",
"eslint-plugin-vue": "^5.0.0",
"install": "^0.13.0",
"linq": "^3.2.1",
"node-sass": "^4.9.2",
"npm": "^6.13.7",
"sass-loader": "^7.0.3",
Expand Down
19 changes: 13 additions & 6 deletions Danmaku/clientapp/src/components/Admin/Admin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
>
<el-menu-item index="1">所有弹幕</el-menu-item>
<el-submenu index="2">
<template slot="title">弹幕管理</template>
<el-menu-item index="2-1">视频检索</el-menu-item>
<el-menu-item index="2-2">时间检索</el-menu-item>
<el-menu-item index="2-3">复杂检索</el-menu-item>
<template slot="title">弹幕检索</template>
<el-menu-item index="2-1" disabled>视频检索</el-menu-item>
<el-menu-item index="2-2" disabled>时间检索</el-menu-item>
<el-menu-item index="2-3" disabled>复杂检索</el-menu-item>
</el-submenu>
<el-menu-item index="3" disabled>用户中心</el-menu-item>
<el-menu-item index="4">
<el-link href="/api/logout" :underline="false">退出登录</el-link>
<el-link href="/api/admin/logout" :underline="false">退出登录</el-link>
</el-menu-item>
</el-menu>
</el-col>
Expand Down Expand Up @@ -105,7 +105,8 @@ export default {
.el-main {
color: #333;
min-height: 90vh;
text-align: center;
min-height: 80vh;
}
body > .el-container {
Expand All @@ -123,5 +124,11 @@ export default {
line-height: 320px;
}
}
.el-table__body{
td {
padding: 6px 0px
}
}
}
</style>
184 changes: 167 additions & 17 deletions Danmaku/clientapp/src/components/Admin/DanmakuList.vue
Original file line number Diff line number Diff line change
@@ -1,32 +1,182 @@
<template>
<div id="danmakulist">
<p>这里是弹幕列表</p>
<p>
<a href="https://dandoc.u2sb.top" target="_blank">文档</a>
</p>
<p>
<router-link :to="'/'">管理</router-link>
</p>
<p>
<router-link :to="'/login'">登录</router-link>
</p>
<p>
<a href="/api/logout">退出</a>
</p>
<el-button type="primary" @click="onSubmit()" style="width: 100px">登录</el-button>
<el-table
v-loading="loading"
:data="tableData"
border
height="72vh"
style="width: 100%; font-size:80%;"
>
<el-table-column fixed prop="num" label width="40"></el-table-column>
<el-table-column fixed prop="vid" label="Vid" width="250" show-overflow-tooltip></el-table-column>
<el-table-column prop="text" label="数据" width="400"></el-table-column>
<el-table-column prop="date" label="时间" width="220" show-overflow-tooltip></el-table-column>
<el-table-column prop="ip" label="IP" width="150" show-overflow-tooltip></el-table-column>
<el-table-column prop="referer" label="网址" width="800" show-overflow-tooltip></el-table-column>
<el-table-column fixed="right" prop="isDelete" label="删除" width="50"></el-table-column>
<el-table-column fixed="right" label="操作" width="120">
<template slot-scope="scope">
<el-button-group>
<el-button
@click.native.prevent="handleEdit(tableData[scope.$index])"
type="primary"
icon="el-icon-edit"
size="mini"
></el-button>
<el-button
@click="handleDelete(tableData[scope.$index])"
type="primary"
icon="el-icon-delete"
size="mini"
></el-button>
</el-button-group>
</template>
</el-table-column>
</el-table>
<div>
<div class="block">
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
:page-sizes="pageSizes"
:page-size="pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="count"
></el-pagination>
</div>
</div>
<danmaku-edit
v-bind:id="danmakuEditId"
v-bind:dialogFormVisible="dialogFormVisible"
@close="DialogClose"
></danmaku-edit>
</div>
</template>


<script>
import Enumerable from 'linq'
import DanmakuEdit from './Edit/DanmakuEdit'
export default {
name: 'danmakulist',
data() {
return {
count: 0,
tableData: [],
pageSizes: [10, 20, 30, 50, 100],
pageSize: 30,
currentPage: 1,
dialogFormVisible: false,
danmakuEditId: '',
loading: true
}
},
mounted: function() {
this.GetData(this.pageSize, this.currentPage)
this.GetCount()
},
methods: {
onSubmit() {
this.$http.get('/api/danmakulist').then(res => {
window.console.log(res.data)
handleSizeChange(val) {
this.pageSize = val
this.GetData(this.pageSize, this.currentPage)
},
handleCurrentChange(val) {
this.currentPage = val
this.GetData(this.pageSize, this.currentPage)
},
handleEdit(row) {
this.danmakuEditId = row.id
this.dialogFormVisible = true
},
handleDelete(row) {
this.$confirm('是否删除?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
this.$http
.get('/api/admin/danmakuedit/delete', {
params: {
id: row.id
}
})
.then(res => {
let dataObj = eval(res.data)
if (dataObj.code === 0) {
this.GetData(this.pageSize, this.currentPage)
this.$notify({
title: '提示',
message: '删除成功',
position: 'bottom-right'
})
} else {
this.$notify.error({
title: '错误',
message: '删除失败',
position: 'bottom-right'
})
}
})
})
.catch(() => {
this.$notify({
title: '提示',
message: '取消删除',
position: 'bottom-right'
})
})
},
GetCount() {
this.$http.get('/api/admin/danmakulist/count').then(res => {
let dataObj = eval(res.data)
if (dataObj.code === 0) {
this.count = dataObj.data.count
} else {
this.$router.push({ path: '/login', query: { ReturnUrl: this.$router.fullPath } })
}
})
},
GetData(size, page) {
this.loading = true
this.$http
.get('/api/admin/danmakulist', {
params: {
size: size,
page: page
}
})
.then(res => {
let dataObj = eval(res.data)
if (dataObj.code === 0) {
this.tableData = Enumerable.from(dataObj.data)
.select((s, i) => ({
num: i,
id: s.id,
vid: s.vid,
text: s.danmakuData.text,
ip: s.ip,
date: s.date,
referer: s.referer,
isDelete: s.isDelete ? '' : ''
}))
.toArray()
this.loading = false
} else if (dataObj.code === 401) {
this.$router.push({ path: '/login', query: { ReturnUrl: this.$router.fullPath } })
}
})
},
DialogClose(isSuccess) {
if (isSuccess === true) {
this.GetData(this.pageSize, this.currentPage)
}
this.dialogFormVisible = false
}
},
components: {
'danmaku-edit': DanmakuEdit
}
}
</script>
Loading

0 comments on commit 6bb262a

Please sign in to comment.