1
0
mirror of https://gitee.com/bookshelfplus/bookshelfplus synced 2025-09-16 23:22:20 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

用户反馈书籍失效,下载书籍,以及登录注册时记录用户浏览器指纹(获取不到浏览器指纹的使用浏览器UA代替)

This commit is contained in:
2022-04-19 22:49:31 +08:00
parent fe23b88427
commit 26af60e472
16 changed files with 3131 additions and 25 deletions

View File

@@ -477,7 +477,7 @@
case "腾讯云对象存储":
title = "直链下载";
if (!localStorageUtils.getLoginStatus()) {
downloadLink = "登录后方可使用";
downloadLink = "<span><a href='{}'>登录</a>后方可使用</span>".replace("{}", "/login?redirect=" + encodeURIComponent(location.pathname + location.search));
} else {
content = `<span style="font-size: 12px;"><nobr>每次点击都会扣减下载次数</nobr></span>`;
downloadLink = `<a style="cursor: pointer;" onclick="getDirectLink(${fileObjectInfo.id});">下载</a>`;
@@ -590,7 +590,7 @@
</script>
<script>
// 获取直链下载链接,并下载该文件
function getDirectLink(fileObjectId) {
async function getDirectLink(fileObjectId) {
var fileObject = direckLinkInfo[fileObjectId];
console.log("fileObject", fileObject);
@@ -601,7 +601,9 @@
var fileNameForUser = `${fileObject.fileName}.${fileObject.fileType}`;
var fileKeyForCos = fileObject.filePath;
postRequest("/file/cos/get", { fileSha1: fileObject.fileSha1, fileNameAndExt: fileNameForUser, token: localStorageUtils.getToken(), expireMinute: 30 })
var visitorId = await getVisitorId();
postRequest("/file/cos/get", { fileSha1: fileObject.fileSha1, fileNameAndExt: fileNameForUser, token: localStorageUtils.getToken(), visitorId: visitorId, expireMinute: 30 })
.then(function (response) {
var axiosData = response.data;
var status = axiosData.status;
@@ -625,7 +627,7 @@
</script>
<script>
// 链接失效反馈
function linkFeedback(fileId, fileObjectId) {
async function linkFeedback(fileId, fileObjectId) {
if (!confirm("确定这个下载链接失效了吗?(没失效的链接不可以乱点着玩儿哦)"))
return;
@@ -636,7 +638,8 @@
}
}
postRequest("/file/object/FailureFeedback", { bookId: bookId, fileId: fileId, fileObjectId: fileObjectId, token: localStorageUtils.getToken() })
var visitorId = await getVisitorId();
postRequest("/file/object/FailureFeedback", { bookId: bookId, fileId: fileId, fileObjectId: fileObjectId, token: localStorageUtils.getToken(), visitorId: visitorId })
.then(function (response) {
var axiosData = response.data;
var status = axiosData.status;

View File

@@ -18,4 +18,36 @@
<style>
/* 字体加载前先隐藏,不然文字会闪一下 */
html, body { opacity: 0; }
</style>
</style>
<script>
/**
* 获取用户浏览器指纹
*
* refer:
* - https://fingerprintjs.com/
* - https://github.com/fingerprintjs/fingerprintjs
*
*/
// Initialize the agent at application startup.
const fpPromise = import('/assets/lib/fingerprintjs/3.3.3/esm.min.js')
// const fpPromise = import('https://openfpcdn.io/fingerprintjs/v3')
.then(FingerprintJS => FingerprintJS.load())
// // Get the visitor identifier when you need it.
// fpPromise
// .then(fp => fp.get())
// .then(result => {
// // This is the visitor identifier:
// const visitorId = result.visitorId
// console.log(visitorId)
// });
async function getVisitorId() {
try {
return (await fpPromise.then(fp => fp.get())).visitorId;
} catch (error) {
return JSON.stringify(navigator.userAgent);
}
}
</script>

View File

@@ -105,7 +105,7 @@
}
}
});
$(".btn-submit").click(function () {
$(".btn-submit").click(async function () {
if ($("#username").val() === "" || $("#password").val() === "") {
alert("用户名或密码不能为空!");
if ($("#username").val() === "") {
@@ -126,7 +126,8 @@
// var encryptpwd = hex_md5(password);
localStorageUtils.userLogout();
postRequest("/user/login", { username: username, password: password })
var visitorId = await getVisitorId();
postRequest("/user/login", { username: username, password: password, visitorId: visitorId })
.then(function (response) {
var axiosData = response.data;
var status = axiosData.status;

View File

@@ -64,11 +64,12 @@
$("#username").val("xiaomo");
$("#password").val("123456");
$(".btn-register").click(function() {
$(".btn-register").click(async function() {
var username = $("#username").val();
var password = $("#password").val();
postRequest("/user/register", { username: username, password: password })
var visitorId = await getVisitorId();
postRequest("/user/register", { username: username, password: password, visitorId: visitorId })
.then(function (response) {
var axiosData = response.data;
var status = axiosData.status;