Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Improve Live Photo preview icon https://github.com/siyuan-note/siyuan/issues/20752

Danielc53807e519aa
diff --git a/app/appearance/icons/index.html b/app/appearance/icons/index.html
index 58de67d828..2fdb5591eb 100644
--- a/app/appearance/icons/index.html
+++ b/app/appearance/icons/index.html
@@ -28,6 +28,12 @@
<body>
<h2>SiYuan</h2>
<div class="fn__clear">
+ <div>
+ <svg>
+ <use xlink:href="#iconImagePlay"></use>
+ </svg>
+ iconImagePlay
+ </div>
<div>
<svg>
<use xlink:href="#iconOCR"></use>
diff --git a/app/appearance/icons/litheness/icon.js b/app/appearance/icons/litheness/icon.js
index 7138d1bc05..03ccae0a7c 100644
--- a/app/appearance/icons/litheness/icon.js
+++ b/app/appearance/icons/litheness/icon.js
@@ -1,5 +1,11 @@
document.body.insertAdjacentHTML('afterbegin', `<svg id="iconsLitheness" style="position: absolute; width: 0; height: 0; overflow: hidden;">
<defs>
+ <symbol id="iconImagePlay" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round">
+ <path d="M15 15.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997a1 1 0 0 1-1.517-.86z" />
+ <path d="M21 12.17V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6" />
+ <path d="m6 21 5-5" />
+ <circle cx="9" cy="9" r="2" />
+ </symbol>
<symbol id="iconOCR" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round">
<path d="M3 7V5a2 2 0 0 1 2-2h2" />
<path d="M17 3h2a2 2 0 0 1 2 2v2" />
diff --git a/app/src/protyle/preview/image.livePhoto.test.ts b/app/src/protyle/preview/image.livePhoto.test.ts
index 101eb36287..caa66120be 100644
--- a/app/src/protyle/preview/image.livePhoto.test.ts
+++ b/app/src/protyle/preview/image.livePhoto.test.ts
@@ -17,7 +17,7 @@ test("image gallery releases playing and converting Live Photos on navigation an
response.end(readFileSync("stage/protyle/js/viewerjs/viewer.js"));
} else {
response.writeHead(200, {"Content-Type": "text/html"});
- response.end("<!doctype html><title>Gallery verification</title>");
+ response.end(`<!doctype html><title>Gallery verification</title><body><script>${readFileSync("appearance/icons/litheness/icon.js", "utf8")}</script>`);
}
});
try {
@@ -61,6 +61,10 @@ test("image gallery releases playing and converting Live Photos on navigation an
const viewer=window.siyuan.viewer;
const button=viewer.toolbar.querySelector(".viewer-live-photo");
if (!button || button.classList.contains("fn__none")) {throw new Error("Live Photo action missing");}
+ const icon=button.querySelector("use");
+ if(icon?.getAttribute("xlink:href")!=="#iconImagePlay"){throw new Error("Live Photo icon mismatch");}
+ const bounds=icon.getBBox();
+ if(bounds.width<=0 || bounds.height<=0){throw new Error("Live Photo icon is empty");}
button.click();
viewer.view(0);
await wait(()=>viewer.index===0 && viewer.viewed);
diff --git a/app/src/protyle/preview/image.ts b/app/src/protyle/preview/image.ts
index 794b14d7aa..2f58939257 100644
--- a/app/src/protyle/preview/image.ts
+++ b/app/src/protyle/preview/image.ts
@@ -79,7 +79,7 @@ export const previewImages = (srcList: Array<string | {src: string, video?: stri
liveButton.setAttribute("role", "button");
liveButton.setAttribute("aria-label", window.siyuan.languages.livePhoto);
liveButton.setAttribute("data-position", "north");
- liveButton.innerHTML = '<svg><use xlink:href="#iconVideo"></use></svg>';
+ liveButton.innerHTML = '<svg><use xlink:href="#iconImagePlay"></use></svg>';
const play = () => {
if (stopLivePhoto) {
stopLive();
diff --git a/app/src/protyle/preview/livePhoto.test.ts b/app/src/protyle/preview/livePhoto.test.ts
index 831da84666..4d03c3ad83 100644
--- a/app/src/protyle/preview/livePhoto.test.ts
+++ b/app/src/protyle/preview/livePhoto.test.ts
@@ -79,7 +79,7 @@ test("application-page playback reaches conversion and displays waiting and fail
status.style.color="#eeeeee";
const large={size:parseFloat(getComputedStyle(status).fontSize),height:status.getBoundingClientRect().height};
const toolbar=document.createElement("div");toolbar.className="viewer-toolbar";
- toolbar.innerHTML='<ul><li class="viewer-live-photo"><svg><use href="#iconVideo"></use></svg></li></ul>';
+ toolbar.innerHTML='<ul><li class="viewer-live-photo"><svg><use href="#iconImagePlay"></use></svg></li></ul>';
host.append(toolbar);
const svg=toolbar.querySelector("svg").getBoundingClientRect();
const icon={width:svg.width,height:svg.height};