Skip to content

Commit

Permalink
feat: 稍后再看
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaviilee committed Oct 26, 2024
1 parent c864d83 commit 2b55b1a
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 29 deletions.
1 change: 1 addition & 0 deletions assets/css/thx.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.w-like2,
.w-fav2,
.w-boxcoin-user,
.w-share2,
.w-boxcoin-admin {
.mr(20px);
}
Expand Down
15 changes: 14 additions & 1 deletion assets/js/stat.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
Reporter
} from "@jx3box/reporter"
import { __Domain } from "@jx3box/jx3box-common/data/jx3box.json";
// import { $next } from "@jx3box/jx3box-common/js/https_v2";

/**
* 16进制转int
Expand Down Expand Up @@ -51,7 +52,6 @@ function getUUID(domain = __Domain) {

// 统计指令
const stat = {

/**
* 上报指令 vue2
* @param {string} user_id 用户id 使用User.getInfo().uid获取
Expand Down Expand Up @@ -89,4 +89,17 @@ const stat = {
}
}

/**
* 添加历史记录
* @param {*} data
* @param {*} data.source_type 例如:macro,community
* @param {*} data.source_id 例如:文章id,帖子id
* @param {*} data.link 例如:文章链接,帖子链接
* @param {*} data.title 例如:文章标题,帖子标题
* @returns
*/
// export function postHistory(data) {
// return $next({mute: true}).post("/api/next2/userdata/visit-history/item", data);
// }

export default stat;
32 changes: 16 additions & 16 deletions package-lock.json

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

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jx3box/jx3box-vue3-ui",
"version": "0.9.4",
"version": "0.9.5",
"description": "JX3BOX Vue3 UI",
"main": "index.js",
"scripts": {
Expand All @@ -26,8 +26,8 @@
},
"dependencies": {
"@element-plus/icons-vue": "^2.1.0",
"@jx3box/jx3box-common": "^8.4.1",
"@jx3box/jx3box-data": "^3.6.9",
"@jx3box/jx3box-common": "^8.4.3",
"@jx3box/jx3box-data": "^3.7.0",
"@jx3box/jx3box-emotion": "^1.2.8",
"@jx3box/jx3box-macro": "^1.0.1",
"@jx3box/jx3box-talent": "^1.3.2",
Expand Down
12 changes: 11 additions & 1 deletion service/fav.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,14 @@ function addFav(post_type, post_id, post_title) {
function delFav(id) {
return $n.delete(`api/article/favorites/my/${id}`);
}
export { hasFav, addFav, delFav };

// 稍后再看
function addWatchLater(data) {
return $n.post(`api/next2/userdata/favorite/item`, data)
}

function delWatchLater(params) {
return $n.delete(`api/next2/userdata/favorite/item`, { params })
}

export { hasFav, addFav, delFav, addWatchLater, delWatchLater };
93 changes: 93 additions & 0 deletions src/interact/WatchLater.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<template>
<div class="w-watch-later" @click="onWatchLaterClick">
<el-tooltip effect="dark" :content="favContent" placement="top-start">
<div>
<img v-if="favorite" class="u-icon" svg-inline :src="rmSrc" />
<img v-else class="u-icon" svg-inline :src="addSrc" />
</div>
</el-tooltip>
</div>
</template>

<script>
import User from "@jx3box/jx3box-common/js/user";
const JX3BOX = require("@jx3box/jx3box-common/data/jx3box.json");
import { addWatchLater, delWatchLater } from "../../service/fav";
import { omit } from "lodash";
export default {
name: "WatchLater",
props: {
category: {
type: String,
default: "article",
},
title: {
type: String,
default: "",
},
},
data: function () {
return {
login: User.isLogin(),
favorite: false,
};
},
computed: {
favContent() {
return this.favorite ? "已添加稍后在看" : "添加至稍后再看";
},
addSrc() {
return JX3BOX.__cdn + "design/vector/icon/time.svg"
},
rmSrc() {
return JX3BOX.__cdn + "design/vector/icon/time1.svg"
},
data() {
return {
category: this.category,
link: location.href,
title: this.title,
}
}
},
methods: {
onWatchLaterClick: function () {
if (this.login) {
this.favorite ? this.rmWatchLater() : this.addWatchLater();
} else {
User.toLogin();
}
},
addWatchLater: function () {
// add watch later
addWatchLater(this.data).then(() => {
this.favorite = true;
});
},
rmWatchLater: function () {
// remove watch later
delWatchLater(omit(this.data, ['title'])).then(() => {
this.favorite = false;
});
},
}
}
</script>

<style lang="less">
.w-watch-later {
.pointer;
.dbi;
.u-icon {
.size(26px);
.y;
.pr;
}
.u-count {
color: #888;
.ml(10px);
top: 4px;
.pr;
}
}
</style>
3 changes: 3 additions & 0 deletions src/single/Thx.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
:client="finalClient"
/>
<Share :postId="postId" :postType="postType" :client="client" />
<watch-later :category="postType" :title="postTitle"></watch-later>
</div>
<div class="w-thx-records">
<boxcoin-records :postId="postId" :postType="postType" :postClient="finalClient" :cacheRecord="cacheRecord"
Expand All @@ -50,6 +51,7 @@ import BoxcoinAdmin from "../interact/BoxcoinAdmin.vue";
import BoxcoinUser from "../interact/BoxcoinUser.vue";
import BoxcoinRecords from "../interact/BoxcoinRecords.vue";
import Share from "../interact/Share.vue";
import WatchLater from "../interact/WatchLater.vue";
import User from "@jx3box/jx3box-common/js/user";
import { getBoxcoinStatus, getPostBoxcoinConfig } from "../../service/thx";
Expand All @@ -63,6 +65,7 @@ export default {
BoxcoinUser,
BoxcoinRecords,
Share,
WatchLater,
},
props: {
type: {
Expand Down
21 changes: 13 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1152,10 +1152,10 @@
"uuid" "^9.0.0"
"vue" "^2.6.12"

"@jx3box/jx3box-common@^8.3.4", "@jx3box/jx3box-common@^8.4.1":
"integrity" "sha512-EaWD37juB7mWRE8TJuQL24NU9JjX1arRBOaIXIQPlcat8MkoHLDeBaOXeONfZeDcvahcd2f6ZhgA8AjOjE/VdA=="
"resolved" "https://registry.npmjs.org/@jx3box/jx3box-common/-/jx3box-common-8.4.1.tgz"
"version" "8.4.1"
"@jx3box/jx3box-common@^8.3.4", "@jx3box/jx3box-common@^8.4.3":
"integrity" "sha512-BTK6h/RTZxzWwTOrAjR10eOfN9uapOaDsxAeWruKlRkXCmhUdyp/EWpPy6iAO+tGuHzWQHama4XNIQq3Vv2pEQ=="
"resolved" "https://registry.npmjs.org/@jx3box/jx3box-common/-/jx3box-common-8.4.3.tgz"
"version" "8.4.3"
dependencies:
"@jx3box/reporter" "^0.0.5"
"axios" "^1.6.8"
Expand All @@ -1167,10 +1167,10 @@
"uuid" "^9.0.0"
"vue" "^2.6.12"

"@jx3box/jx3box-data@^3.3.0", "@jx3box/jx3box-data@^3.6.6", "@jx3box/jx3box-data@^3.6.9":
"integrity" "sha512-KCWuruEb3nR5JpuAyT7V/L8hP5zFrR7OKNUZQkA6k4WreyqPqaHrMHmkEsFs0/kxS5K46QyF26rOr11lVrdsTA=="
"resolved" "https://registry.npmjs.org/@jx3box/jx3box-data/-/jx3box-data-3.6.9.tgz"
"version" "3.6.9"
"@jx3box/jx3box-data@^3.3.0", "@jx3box/jx3box-data@^3.6.6", "@jx3box/jx3box-data@^3.7.0":
"integrity" "sha512-/SxD/D2chKuSEfflBTSKDxLnAYFNGITL91DZF5xlAjAvmRCqJAryCxCrlcHOhCE56lW7zJjDMo4r6qiuMDpbVg=="
"resolved" "https://registry.npmjs.org/@jx3box/jx3box-data/-/jx3box-data-3.7.0.tgz"
"version" "3.7.0"

"@jx3box/jx3box-emotion@^1.2.8":
"integrity" "sha512-vKQf49S4ejnK6tQInmsuD1NN3RxZOC9LMFyrOq3ld+jqyuY3/9Xu19D1bdDEZhy4m/XW+p4uEMg0oXE6es5VXg=="
Expand Down Expand Up @@ -4183,6 +4183,11 @@
"resolved" "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz"
"version" "1.0.0"

"fsevents@~2.3.2":
"integrity" "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA=="
"resolved" "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz"
"version" "2.3.2"

"function-bind@^1.1.1":
"integrity" "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
"resolved" "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz"
Expand Down

0 comments on commit 2b55b1a

Please sign in to comment.