Skip to content

Commit 5d2b693

Browse files
committed
再进行删除或取关操作时重新查询
1 parent f0dca9d commit 5d2b693

File tree

6 files changed

+496
-222
lines changed

6 files changed

+496
-222
lines changed

src/views/user/cycle-bin.vue

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,23 @@
66
<v-icon class="pointer" @click="showTip=false">mdi-close</v-icon>
77
</v-card>
88
<div class="cycle-bin-list">
9-
<v-skeleton-loader type="list-item-two-line" v-show="loading" v-for="item in 10" :key="item"></v-skeleton-loader>
10-
<v-card elevation="0" color="#272727" class="instance d-flex flex-ai" v-show="!loading" v-for="item in list"
11-
:key="item.exampleId">
9+
<v-skeleton-loader type="list-item-two-line" v-show="loading" v-for="item in 12" :key="item"></v-skeleton-loader>
10+
<v-card elevation="0" color="#272727" class="instance flex-ai" v-show="!loading"
11+
v-for="(item, index) in list" :key="item.exampleId">
1212
<div class="d-flex flex-clo">
1313
<span class="instance-title">{{item.exampleName}}</span>
1414
<span class="delete-time text-describe text-sm">删除日期:{{item.updateTime}}</span>
1515
</div>
1616
<v-spacer></v-spacer>
17-
<v-btn color="#333333" class="restore-btn" @click="restore(item.exampleId)" :loading="restoreLoading">恢复</v-btn>
18-
<v-btn color="error" class="delete-btn" @click="perDelete(item.exampleId)" :loading="deleteLoading">永久删除</v-btn>
17+
<v-btn color="#333333" class="restore-btn" @click="restore(item.exampleId,index)"
18+
:loading="restoreLoading&&curIndex===index">恢复</v-btn>
19+
<v-btn color="error" class="delete-btn" @click="perDelete(item.exampleId,index)"
20+
:loading="deleteLoading&&curIndex===index">永久删除</v-btn>
1921
</v-card>
2022
</div>
2123
<div class="cycle-tip" v-show="showNothing">
2224
<div class="d-flex flex-clo flex-jcc flex-ai">
23-
<span class="title-xl">🗑</span>
25+
<span class="icon-cycle">🗑</span>
2426
<span class="text-describe text-sm">回收站空空如也</span>
2527
</div>
2628
</div>
@@ -36,6 +38,7 @@ export default {
3638
loading: true,
3739
deleteLoading: false,
3840
restoreLoading: false,
41+
curIndex: null,
3942
list: [],
4043
showNothing: false,
4144
}
@@ -46,7 +49,7 @@ export default {
4649
!this.loginState ||
4750
this.curUserDetail.username !== this.loginInfo.username
4851
) {
49-
// this.$router.replace({ name: '404' })
52+
this.$router.replace('/404')
5053
}
5154
this.getRecycle()
5255
},
@@ -57,19 +60,22 @@ export default {
5760
async getRecycle() {
5861
this.loading = true
5962
try {
60-
const res = await this.$http.searchCycleBin()
61-
if (res.state) {
62-
this.list = res.data
63-
this.showNothing = res.data.length === 0
63+
const { state, data } = await this.$http.searchCycleBin()
64+
if (state) {
65+
this.list = data
66+
this.showNothing = data.length === 0
67+
this.$emit('setPageConn', true, true)
68+
this.$emit('updateNum', 'cycleBin', data.length)
6469
this.$message.success('查询成功!')
6570
} else {
6671
this.$message.error('查询失败!')
6772
}
6873
} catch (err) {}
6974
this.loading = false
7075
},
71-
async restore(exampleId) {
76+
async restore(exampleId, index) {
7277
this.restoreLoading = true
78+
this.curIndex = index
7379
try {
7480
const res = await this.$http.resumeDelWork({
7581
username: this.loginInfo.username,
@@ -82,15 +88,17 @@ export default {
8288
this.$message.error('恢复失败!')
8389
}
8490
} catch (err) {}
91+
this.curIndex = null
8592
this.restoreLoading = false
8693
},
87-
async perDelete(exampleId) {
94+
async perDelete(exampleId, index) {
8895
const confRes = await this.$alert({
8996
content: '该实例永久删除后将不可恢复!',
9097
okText: '确认并继续',
9198
okColor: 'error',
9299
})
93100
if (confRes) {
101+
this.curIndex = index
94102
this.deleteLoading = true
95103
try {
96104
const res = await this.$http.permanentDelWork({
@@ -106,6 +114,7 @@ export default {
106114
} catch (err) {
107115
console.log(err)
108116
}
117+
this.curIndex = null
109118
this.deleteLoading = false
110119
}
111120
},
@@ -135,6 +144,7 @@ export default {
135144
grid-gap: 15px;
136145
grid-template-columns: repeat(auto-fill, minmax(450px, 1fr));
137146
.instance {
147+
display: flex;
138148
padding: 10px;
139149
margin-bottom: 15px;
140150
.restore-btn {
@@ -144,6 +154,9 @@ export default {
144154
}
145155
.cycle-tip {
146156
margin: 50px 0 100px;
157+
.icon-cycle {
158+
font-size: 48px;
159+
}
147160
}
148161
}
149162
</style>

src/views/user/followers.vue

Lines changed: 74 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,94 @@
11
<template>
22
<div id="followers">
3-
<div class="follower-list">
3+
<div class="follower-list" v-show="!nothing">
44
<div class="skeleton-list-item" v-for="(item, index) in 20" :key="index" v-show="loading">
55
<follow-skeleton></follow-skeleton>
66
</div>
7-
<div class="follower-list-item" v-for="item in followersList" :key="item" v-show="!loading">
8-
<follow-card></follow-card>
7+
<div class="follower-list-item" v-for="(item, index) in followersList" :key="item.username" v-show="!loading">
8+
<follow-card :cardIndex="index" @setFollow="setFollow" :userInfo="item"></follow-card>
99
</div>
1010
</div>
11-
<div class="page-opt d-flex flex-jcc">
12-
<v-btn class="before-btn" @click="switchPage(-1)" :disabled="p<=1">上一页</v-btn>
13-
<v-btn color="primary" class="after-btn" @click="switchPage(1)">下一页</v-btn>
11+
<div class="followers-tip flex-jcc" v-show="showNothingTip">
12+
<div class="tip-content d-flex flex-clo flex-ai" v-if="isSelfProfile">
13+
<span class="text-describe">你还没有粉丝...</span>
14+
<span class="text-describe">创造优秀作品,提升你在社区的影响力!</span>
15+
<router-link to="/newWork">
16+
<v-btn color="primary">
17+
<v-icon left>mdi-plus</v-icon>新建实例
18+
</v-btn>
19+
</router-link>
20+
</div>
21+
<div class="tip-content d-flex flex-clo flex-ai" v-else>
22+
<span class="title-lg">🍃</span>
23+
<span class="title-sm text-describe">这里空空如也...</span>
24+
</div>
1425
</div>
1526
</div>
1627
</template>
1728

1829
<script>
30+
import { mapState, mapGetters } from 'vuex'
1931
import FollowSkeleton from '@components/skeleton/followSkeleton'
2032
import FollowCard from '@components/followCard'
33+
import * as p2b from '@utils/paramsToBase64'
2134
export default {
35+
name: 'Followers',
2236
data() {
2337
return {
24-
p: 1,
2538
followersList: [],
2639
loading: true,
40+
nothing: true,
41+
showNothingTip: false,
2742
}
2843
},
2944
created() {
30-
this.followersList = Array.from({ length: 20 }, (_, i) => i + 20)
31-
let p = this.$route.query.p
32-
if (p) {
33-
p = parseInt(p)
34-
this.p = p > 1 ? p : 1
35-
} else {
36-
this.p = 1
37-
}
38-
this.search()
45+
this.init()
46+
},
47+
computed: {
48+
...mapState(['curUserDetail']),
49+
...mapGetters(['isSelfProfile']),
3950
},
4051
methods: {
41-
switchPage(changeNum) {
42-
this.$router.push({
43-
path: 'following',
44-
query: { p: (this.p += changeNum) },
45-
})
46-
this.search()
52+
init() {
53+
let page = 1
54+
let f = this.$route.query.f
55+
if (f) {
56+
;({ page } = p2b.decode(f))
57+
page = parseInt(page)
58+
}
59+
this.search(page)
4760
},
48-
search(p) {
49-
p = p || this.p
61+
async search(page) {
5062
this.loading = true
51-
setTimeout(() => {
52-
this.loading = false
53-
}, 5000)
63+
this.nothing = false
64+
try {
65+
const { state, data } = await this.$http.searchFollowers({
66+
currentPage: page,
67+
username: this.curUserDetail.username,
68+
})
69+
if (state) {
70+
const { isFirstPage, isLastPage, list, total } = data
71+
this.nothing = list.length === 0
72+
this.showNothingTip = list.length === 0
73+
this.followersList = list
74+
this.$emit('setPageConn', isFirstPage, isLastPage)
75+
this.$emit('updateNum', 'followers', total)
76+
this.$message.success('查询成功!')
77+
} else {
78+
this.$message.error('查询失败!')
79+
}
80+
} catch (err) {
81+
console.log(err)
82+
}
83+
this.loading = false
84+
},
85+
setFollow(isFollow, index) {
86+
this.followersList[index].myFollow = isFollow
5487
},
5588
},
5689
components: {
57-
'follow-skeleton': FollowSkeleton,
58-
'follow-card': FollowCard,
90+
FollowSkeleton,
91+
FollowCard,
5992
},
6093
}
6194
</script>
@@ -73,6 +106,18 @@ export default {
73106
margin-right: 15px;
74107
}
75108
}
109+
.followers-tip {
110+
display: flex;
111+
padding: 50px 0 150px 0;
112+
.tip-content {
113+
background-color: $deep-4;
114+
padding: 25px 50px;
115+
border-radius: 5px;
116+
span {
117+
margin-bottom: 10px;
118+
}
119+
}
120+
}
76121
}
77122
@include Mobile {
78123
#followers {

0 commit comments

Comments
 (0)