Skip to content

Commit

Permalink
fix: pre代码块超长加滚动条;取消删除话题按钮因为api不支持;
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolausliu committed Apr 28, 2021
1 parent 1180d62 commit 3209173
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ export const updateTopic = (axios, params) => {
}

export const deleteTopic = (axios, id, params) => {
return axios.post(`/topic/${id}/update`, params)
return axios.post(`/topic/${id}/delete`, params)
}
18 changes: 15 additions & 3 deletions pages/topic/_id/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<div class="topic-actions">
<span @click="switchCollect">{{ info.is_collect ? '取消收藏' : '收藏' }}</span>
<NuxtLink v-if="isOwner" :to="`/topic/${info.id}/edit`">编辑</NuxtLink>
<span v-if="isOwner" @click="handleDelete">删除</span>
<!-- <span v-if="isOwner" @click="handleDelete">删除</span> -->
</div>
</div>

Expand Down Expand Up @@ -207,9 +207,19 @@ export default {
},
handleDelete() {
deleteTopic(this.$axios, this.info.id, { accesstoken: this.accesstoken }).then(() => {
this.$nuxt.redirect(`/`)
this.$confirm('确定要删除此话题吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
deleteTopic(this.$axios, this.info.id, { accesstoken: this.accesstoken }).then(() => {
this.$nuxt.redirect(`/`)
})
})
.catch(() => {
console.log('取消删除')
})
},
switchUpdown(id, index) {
Expand Down Expand Up @@ -365,6 +375,8 @@ export default {
}
&__info {
flex-grow: 1;
// fix: 代码块会超出最大长度
width: calc(100% - 58px);
}
&__top {
line-height: 20px;
Expand Down
4 changes: 2 additions & 2 deletions utils/time.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
export const timeago = (time) => {
const now = Date.parse(new Date()) / 1000
const date = new Date(time)
const limit = now - date.getTime() / 1000
const limit = now - Date.parse(date) / 1000
let content = ''
const _minute = 60
const _hour = _minute * 60
const _day = _hour * 24
const _year = _day * 365
if (limit < _minute) {
content = `${limit}秒前`
content = `${Math.floor(limit)}秒前`
} else if (limit >= _minute && limit < _hour) {
content = `${Math.floor(limit / 60)}分钟前`
} else if (limit >= _hour && limit < _day) {
Expand Down

0 comments on commit 3209173

Please sign in to comment.