Skip to content

Commit

Permalink
fix: 点赞回复按钮点击会回到顶部 #620 (#621)
Browse files Browse the repository at this point in the history
  • Loading branch information
imaegoo authored Nov 27, 2023
1 parent d8e3fef commit ee5d8bc
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 29 deletions.
2 changes: 1 addition & 1 deletion docs/.vitepress/theme/Twikoo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@ onMounted(() => {

<!-- Twikoo -->
<div id="twikoo"></div>
<component :is="'script'" src="https://cdn.jsdelivr.net/npm/twikoo@1.6.25/dist/twikoo.all.min.js" ref="twikooJs"></component>
<component :is="'script'" src="https://cdn.jsdelivr.net/npm/twikoo@1.6.26/dist/twikoo.all.min.js" ref="twikooJs"></component>
</div>
</template>
2 changes: 1 addition & 1 deletion docs/backend.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ exports.main = require('twikoo-func').main
8. 创建完成后,点击“twikoo"进入云函数详情页,进入“函数代码”标签,点击“文件 - 新建文件”,输入 `package.json`,回车
9. 复制以下代码、粘贴到代码框中,点击“保存并安装依赖”
``` json
{ "dependencies": { "twikoo-func": "1.6.25" } }
{ "dependencies": { "twikoo-func": "1.6.26" } }
```

## 腾讯云命令行部署
Expand Down
10 changes: 5 additions & 5 deletions docs/frontend.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ twikoo:

``` html
<div id="tcomment"></div>
<script src="https://cdn.staticfile.org/twikoo/1.6.25/twikoo.all.min.js"></script>
<script src="https://cdn.staticfile.org/twikoo/1.6.26/twikoo.all.min.js"></script>
<script>
twikoo.init({
envId: '您的环境id', // 腾讯云环境填 envId;Vercel 环境填地址(https://xxx.vercel.app)
Expand All @@ -103,10 +103,10 @@ twikoo.init({

如果遇到默认 CDN 加载速度缓慢,可更换其他 CDN 镜像。以下为可供选择的公共 CDN,其中一些 CDN 可能需要数天时间同步最新版本:

* `https://cdn.staticfile.org/twikoo/1.6.25/twikoo.all.min.js`
* `https://lib.baomitu.com/twikoo/1.6.25/twikoo.all.min.js`
* `https://cdn.bootcdn.net/ajax/libs/twikoo/1.6.25/twikoo.all.min.js`
* `https://cdn.jsdelivr.net/npm/twikoo@1.6.25/dist/twikoo.all.min.js`
* `https://cdn.staticfile.org/twikoo/1.6.26/twikoo.all.min.js`
* `https://lib.baomitu.com/twikoo/1.6.26/twikoo.all.min.js`
* `https://cdn.bootcdn.net/ajax/libs/twikoo/1.6.26/twikoo.all.min.js`
* `https://cdn.jsdelivr.net/npm/twikoo@1.6.26/dist/twikoo.all.min.js`

## 开启管理面板(腾讯云环境)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "twikoo",
"version": "1.6.25",
"version": "1.6.26",
"description": "A simple comment system.",
"keywords": [
"twikoojs",
Expand Down
2 changes: 1 addition & 1 deletion src/client/version.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const version = '1.6.25'
const version = '1.6.26'

export { version }
10 changes: 6 additions & 4 deletions src/client/view/components/TkAction.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<template>
<div class="tk-action">
<a class="tk-action-link" :class="{ 'tk-liked': liked }" @click="onLike">
<a class="tk-action-link" :class="{ 'tk-liked': liked }" href="#" @click="onLike">
<span class="tk-action-icon" v-html="iconLike"></span>
<span class="tk-action-icon tk-action-icon-solid" v-html="iconLikeSolid"></span>
<span class="tk-action-count">{{ likeCountStr }}</span>
</a>
<a class="tk-action-link" @click="onReply">
<a class="tk-action-link" href="#" @click="onReply">
<span class="tk-action-icon" v-html="iconComment"></span>
<span class="tk-action-icon tk-action-icon-solid" v-html="iconCommentSolid"></span>
<span class="tk-action-count">{{ repliesCountStr }}</span>
Expand Down Expand Up @@ -42,10 +42,12 @@ export default {
}
},
methods: {
onLike () {
onLike ($event) {
$event.preventDefault()
this.$emit('like')
},
onReply () {
onReply ($event) {
$event.preventDefault()
this.$emit('reply')
}
}
Expand Down
10 changes: 6 additions & 4 deletions src/client/view/components/TkAdmin.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="tk-admin-container">
<div class="tk-admin" :class="{ '__show': show }" v-loading="loading">
<a class="tk-admin-close" @click="onClose" v-html="iconClose"></a>
<a class="tk-admin-close" href="#" @click="onClose" v-html="iconClose"></a>
<div class="tk-login-title" v-if="needUpdate">
<div>{{ t('ADMIN_NEED_UPDATE') }}</div>
<a href="https://twikoo.js.org/update.html" target="_blank">https://twikoo.js.org/update.html</a>
Expand Down Expand Up @@ -39,7 +39,7 @@
<div class="tk-panel" v-if="isLogin">
<div class="tk-panel-title">
<div>{{ t('ADMIN_TITLE') }}</div>
<a class="tk-panel-logout" @click="onLogout">{{ t('ADMIN_LOGOUT') }}</a>
<a class="tk-panel-logout" href="#" @click="onLogout">{{ t('ADMIN_LOGOUT') }}</a>
</div>
<div class="tk-tabs">
<div class="tk-tab" :class="{ __active: activeTabName === 'comment' }" @click="activeTabName = 'comment'">{{ t('ADMIN_COMMENT') }}</div>
Expand Down Expand Up @@ -134,7 +134,8 @@ export default {
}
this.loading = false
},
async onLogout () {
async onLogout ($event) {
$event.preventDefault()
this.loading = true
if (this.$tcb) {
await this.$tcb.auth.signOut()
Expand Down Expand Up @@ -207,7 +208,8 @@ export default {
throw e
}
},
onClose () {
onClose ($event) {
$event.preventDefault()
this.$emit('close')
}
},
Expand Down
14 changes: 8 additions & 6 deletions src/client/view/components/TkComment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
<time :datetime="jsonTimestamp" :title="localeTime">{{ displayCreated }}</time>
</small>
<small class="tk-actions" v-if="isLogin">
<a v-if="comment.isSpam" @click="handleSpam(false)">{{ t('ADMIN_COMMENT_SHOW') }}</a>
<a v-if="!comment.isSpam" @click="handleSpam(true)">{{ t('ADMIN_COMMENT_HIDE') }}</a>
<a v-if="!comment.rid && comment.top" @click="handleTop(false)">{{ t('ADMIN_COMMENT_UNTOP') }}</a>
<a v-if="!comment.rid && !comment.top" @click="handleTop(true)">{{ t('ADMIN_COMMENT_TOP') }}</a>
<a href="#" v-if="comment.isSpam" @click="handleSpam(false, $event)">{{ t('ADMIN_COMMENT_SHOW') }}</a>
<a href="#" v-if="!comment.isSpam" @click="handleSpam(true, $event)">{{ t('ADMIN_COMMENT_HIDE') }}</a>
<a href="#" v-if="!comment.rid && comment.top" @click="handleTop(false, $event)">{{ t('ADMIN_COMMENT_UNTOP') }}</a>
<a href="#" v-if="!comment.rid && !comment.top" @click="handleTop(true, $event)">{{ t('ADMIN_COMMENT_TOP') }}</a>
</small>
</div>
<tk-action :liked="liked"
Expand Down Expand Up @@ -227,10 +227,12 @@ export default {
this.isLogin = this.$twikoo.serverConfig && this.$twikoo.serverConfig.IS_ADMIN
}
},
handleSpam (isSpam) {
handleSpam (isSpam, $event) {
$event.preventDefault()
this.setComment({ isSpam })
},
handleTop (top) {
handleTop (top, $event) {
$event.preventDefault()
this.setComment({ top })
},
async setComment (set) {
Expand Down
2 changes: 1 addition & 1 deletion src/server/function/twikoo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "twikoo-func",
"version": "1.6.25",
"version": "1.6.26",
"description": "A simple comment system.",
"author": "imaegoo <hello@imaegoo.com> (https://github.com/imaegoo)",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion src/server/netlify/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "twikoo-netlify",
"version": "1.6.25",
"version": "1.6.26",
"description": "A simple comment system.",
"author": "imaegoo <hello@imaegoo.com> (https://github.com/imaegoo)",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions src/server/self-hosted/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tkserver",
"version": "1.6.25",
"version": "1.6.26",
"description": "A simple comment system.",
"keywords": [
"twikoo",
Expand Down Expand Up @@ -31,7 +31,7 @@
"get-user-ip": "^1.0.1",
"lokijs": "^1.5.12",
"mongodb": "^3.6.3",
"twikoo-func": "1.6.25",
"twikoo-func": "1.6.26",
"uuid": "^8.3.2"
}
}
4 changes: 2 additions & 2 deletions src/server/vercel/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "twikoo-vercel",
"version": "1.6.25",
"version": "1.6.26",
"description": "A simple comment system.",
"author": "imaegoo <hello@imaegoo.com> (https://github.com/imaegoo)",
"license": "MIT",
Expand All @@ -13,7 +13,7 @@
"dependencies": {
"get-user-ip": "^1.0.1",
"mongodb": "^3.6.3",
"twikoo-func": "1.6.25",
"twikoo-func": "1.6.26",
"uuid": "^8.3.2"
}
}

0 comments on commit ee5d8bc

Please sign in to comment.