From 72401d08ca5e2680aefaaf69a812ffc024c34269 Mon Sep 17 00:00:00 2001 From: dddx Date: Sat, 29 Jun 2024 16:56:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BE=88=E5=A4=9A=E5=9C=B0=E6=96=B9?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E6=98=BE=E7=A4=BA=E7=BC=A9=E7=95=A5=E5=9B=BE?= =?UTF-8?q?=EF=BC=8C=E8=80=8C=E4=B8=8D=E6=98=AF=E5=8E=9F=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker/docker-compose.yml | 11 +- web/index.html | 411 +++++++++++++++++++++++----------- web/store.html | 452 ++++++++++++++++++++------------------ 3 files changed, 525 insertions(+), 349 deletions(-) diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 779a95f..9200d60 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,13 +1,14 @@ -version: "3" +version: "3.0" services: image-oss: - image: dingdangdog/image-oss:latest + container_name: image-oss + image: dingdangdog/image-oss:2.0.1 restart: always environment: TZ: "Asia/Shanghai" volumes: - - ${PWD}/images:/data/image-oss/images - - ${PWD}/application.yml:/usr/image-oss/jar/application.yml + - ./images:/app/images + - ./config.json:/app/config/config.json ports: - - 11080:80 \ No newline at end of file + - 11080:80 diff --git a/web/index.html b/web/index.html index d7f8b14..9a4e0eb 100644 --- a/web/index.html +++ b/web/index.html @@ -1,73 +1,140 @@ - + - - + 图床工具 - - - + + + - - + + + - + - -
-

- + +
+

+  图床工具 -

+

-
+
- - - - - + + + + +
-
-
+
+
- - - - - - + + + + + +
-
+
-
+
-
- +
+ +
+ +
+ +
+
+ 图片上传后在此显示 +
+ + +
+ + + +
+ +
-
- - - -
- - -
- - - -
- -
- -
- - - \ No newline at end of file + imageDiv = document.getElementById("image-div"); + // 图片添加右键点击事件,显示管理菜单 + imageDiv.addEventListener("contextmenu", (e) => { + // 阻止右键默认行为,并显示自定义菜单 + e.preventDefault(); + menus.style.display = "block"; + menus.style.left = e.pageX + "px"; + menus.style.top = e.pageY + "px"; + // 记录当前点击的数据ID(图片名称) + window.localStorage.setItem("clickImgId", e.target.id); + window.localStorage.setItem("clickImgSrc", e.target.src); + }); + + // 右键菜单容器 + const menus = document.getElementById("manager-menu"); + // 整个DOM元素,任意地方左键点击,则隐藏右键菜单,并上次右键的文件名 + document.addEventListener("click", (e) => { + menus.style.display = "none"; + window.localStorage.removeItem("clickImgId"); + window.localStorage.removeItem("clickImgSrc"); + }); + + // 复制按钮 + const copyUrl = document.getElementById("copy-url"); + copyUrl.addEventListener("click", () => { + url = window.localStorage.getItem("clickImgSrc"); + realUrl = url.replace("/thumb/", "/"); + navigator.clipboard.writeText(realUrl); + alertSuccess("复制成功", 2000); + }); + + // 复制Markdown + const copyMarkdown = document.getElementById("copy-markdown"); + copyMarkdown.addEventListener("click", () => { + url = window.localStorage.getItem("clickImgSrc"); + realUrl = url.replace("/thumb/", "/"); + navigator.clipboard.writeText(`![image](${realUrl})`); + alertSuccess("复制成功", 2000); + }); + + // 删除按钮 + const deleteMenu = document.getElementById("delete"); + // 删除确认弹窗 + const deletePrompt = document.getElementById("delete-prompt"); + // 删除确认按钮 + const confirmBtn = deletePrompt.querySelector("#confirmBtn"); + let imageName; + deleteMenu.addEventListener("click", () => { + imageName = window.localStorage.getItem("clickImgId"); + if (typeof deletePrompt.showModal === "function") { + deletePrompt.showModal(); + } else { + deletePrompt.value = + "Sorry, the API is not supported by this browser."; + } + }); + + // 确认删除,调用删除接口 + confirmBtn.addEventListener("click", () => { + $.ajax({ + url: + baseApiUrl + + "store/deleteImage?key=" + + key + + "&imageName=" + + imageName, + type: "POST", + headers: { + "Access-Control-Allow-Origin": "*", + }, + crossDomain: true, + processData: false, // 告诉jQuery不要去处理发送的数据 + contentType: false, // 告诉jQuery不要去设置Content-Type请求头 + success: function (data) { + if (data.code === 200) { + alertSuccess(data.message, 2000); + // 重新获取图片 + findImages(); + } else { + alertError(data.message, 2000); + } + }, + error: function (data) { + alertError("System Error!", 2000); + }, + }); + }); + + diff --git a/web/store.html b/web/store.html index 839d08a..ac0c0f3 100644 --- a/web/store.html +++ b/web/store.html @@ -1,281 +1,309 @@ - + - - + 图库 | 图床工具 - - - - + + + + - - + + - + - -
-

- + +
+

+  图库 | 图床工具 -

-
+

+
- + -
- -
-
+
+ +
- - + + - -
- Fullscreen Image + +
+ Fullscreen Image × -
+
- -
+ +
+ -
+
- +
-

- -

-
- - -
+

+ +

+
+ + +
-
- -
- - - - \ No newline at end of file + getImageList(key, $("#find").val()); + } + + +