fix: 二级目录和本地缓存问题

pull/211/head
iamckun 2024-08-03 22:17:42 +08:00
parent e19876f304
commit 17e1474cd8
4 changed files with 38 additions and 14 deletions

View File

@ -19,9 +19,10 @@ include_once __DIR__ . "/header.php";
<script type="application/javascript" src="<?php static_cdn(); ?>/public/static/viewjs/viewer.min.js"></script>
<script type="application/javascript" src="<?php static_cdn(); ?>/public/static/zui/lib/clipboard/clipboard.min.js"></script>
<script>
if ($.zui.store.length() > 1) {
console.log('saved: ' + $.zui.store.length()) // 获取总数
$.zui.store.forEach(function(key, value) { // 遍历所有本地存储的条目
let history = $.zui.store.get("easy-image-history");
if (history) {
console.log('saved: ' + Object.keys(history).length) // 获取总数
Object.entries(history).forEach(([key, value]) => { // 遍历所有本地存储的条目
console.log('url list: ' + value['url']) // 获取所有链接
if (value['url'] !== undefined) {
let v_url = parseURL(value['url']); // 获取链接路径 console.log(parseURL(value['url']).path);
@ -49,13 +50,15 @@ include_once __DIR__ . "/header.php";
// 清空所有本地存储的条目
$('button').on('click', function() {
new $.zui.Messager('已清空' + $.zui.store.length() + "条历史记录", {
type: "success", // 定义颜色主题
icon: "ok-sign" // 定义消息图标
let history = $.zui.store.get("easy-image-history");
if (history) {
new $.zui.Messager('已清空' + Object.keys(history).length + "条历史记录", {
type: "success", // 定义颜色主题
icon: "ok-sign" // 定义消息图标
}).show();
$.zui.store.clear(); // 清空上传记录
$.zui.store.remove("easy-image-history"); // 清空上传记录
setTimeout(location.reload.bind(location), 2000); // 延迟2秒刷新
}
})
// 复制 文件名/URL

View File

@ -145,7 +145,7 @@ if ($config['ad_top']) echo $config['ad_top_info'];
</div>
<!-- 按日期-->
<div class="col-md-2 col-xs-5">
<form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="get">
<form action="" method="get">
<div class="input-group">
<span class="input-group-addon fix-border fix-padding"></span>
<input type="text" class="form-control form-date input-sm" name="date" value="<?php echo date('Y/m/d/'); ?>" readonly="readonly">
@ -169,9 +169,12 @@ if ($config['ad_top']) echo $config['ad_top_info'];
<script type="application/javascript" src="<?php static_cdn(); ?>/public/static/zui/lib/datetimepicker/datetimepicker.min.js"></script>
<script>
// viewjs
new Viewer(document.getElementById('viewjs'), {
url: 'data-original',
});
const viewjsElement = document.getElementById('viewjs');
if (viewjsElement) {
new Viewer(viewjsElement, {
url: 'data-original',
});
}
// POST 删除提交
function ajax_post(url, mode = 'delete') {

View File

@ -192,7 +192,16 @@ mustLogin();
try { // 储存上传历史
console.log('history localStorage success');
$.zui.store.set(obj.srcName, obj)
// 获取现有的上传记录
let history = $.zui.store.get("easy-image-history");
// 如果不存在,则初始化为一个空对象
if (!history) {
history = {};
}
// 将新的记录添加到对象中,键为 obj.srcName值为 obj
history[obj.srcName] = obj;
// 更新本地存储
$.zui.store.set("easy-image-history", history);
} catch (err) {
// 失败提示
$.zui.messager.show('存储上传记录失败' + err, {

View File

@ -92,7 +92,16 @@ function uploadCopy(copyID, loadClass) {
try { // 储存上传记录
console.log('history localStorage success');
$.zui.store.set(obj.srcName, obj)
// 获取现有的上传记录
let history = $.zui.store.get("easy-image-history");
// 如果不存在,则初始化为一个空对象
if (!history) {
history = {};
}
// 将新的记录添加到对象中,键为 obj.srcName值为 obj
history[obj.srcName] = obj;
// 更新本地存储
$.zui.store.set("easy-image-history", history);
} catch (err) {
// 存储上传记录失败提示
$.zui.messager.show('存储上传记录失败' + err, { icon: 'bell', time: 4000, type: 'danger', placement: 'top' });