diff --git a/server/src/main/resources/web/compress.ftl b/server/src/main/resources/web/compress.ftl index b57018eb..d40aef7c 100644 --- a/server/src/main/resources/web/compress.ftl +++ b/server/src/main/resources/web/compress.ftl @@ -779,6 +779,10 @@ toggleTreePanelIconEl.textContent = collapsed ? ">" : "<"; } + function isDirectoryNode(node) { + return !!node && Array.isArray(node.children); + } + function countTreeStats(nodes) { var stats = { folders: 0, files: 0 }; var queue = [].concat(nodes || []); @@ -787,7 +791,7 @@ if (!node) { continue; } - if (node.children && node.children.length) { + if (isDirectoryNode(node)) { stats.folders += 1; queue = queue.concat(node.children); } else { @@ -841,7 +845,8 @@ function normalizeTreeNodes(nodes) { (nodes || []).forEach(function (node) { - if (node.children && node.children.length) { + if (isDirectoryNode(node)) { + node.isParent = true; normalizeTreeNodes(node.children); return; } @@ -851,7 +856,7 @@ } function decorateTreeNode(treeId, treeNode) { - if (treeNode.isParent) { + if (isDirectoryNode(treeNode)) { return; } var anchor = $("#" + treeNode.tId + "_a"); @@ -903,7 +908,7 @@ } function handleNodeClick(event, treeId, treeNode) { - if (treeNode.isParent) { + if (isDirectoryNode(treeNode)) { zTreeObj.expandNode(treeNode, !treeNode.open, false, false, false); return false; } diff --git a/server/src/main/resources/web/picture.ftl b/server/src/main/resources/web/picture.ftl index 4017b5a6..648430a3 100644 --- a/server/src/main/resources/web/picture.ftl +++ b/server/src/main/resources/web/picture.ftl @@ -11,10 +11,14 @@ body { background-color: #f1f3f5; } - .viewer-container:focus, - .viewer-container:focus-visible { + .viewer-container:focus { outline: none !important; } + .viewer-container:focus-visible { + outline: 2px solid rgba(95, 107, 122, 0.65) !important; + outline-offset: 2px; + box-shadow: 0 0 0 4px rgba(95, 107, 122, 0.14); + } #image { width: 800px; margin: 0 auto; font-size: 0;} #image li { display: inline-block;width: 50px;height: 50px; margin-left: 1%; padding-top: 1%;} /*#dowebok li img { width: 200%;}*/ diff --git a/server/src/test/java/cn/keking/PdfViewerCompatibilityTests.java b/server/src/test/java/cn/keking/PdfViewerCompatibilityTests.java index 6b04b0f5..dc1a07fb 100644 --- a/server/src/test/java/cn/keking/PdfViewerCompatibilityTests.java +++ b/server/src/test/java/cn/keking/PdfViewerCompatibilityTests.java @@ -28,14 +28,14 @@ public class PdfViewerCompatibilityTests { @Test void shouldOpenPdfPreviewWithThumbnailSidebarByDefault() throws IOException { - String pdfTemplate = readWebResource("/web/pdf.ftl"); + String pdfTemplate = readResource("/web/pdf.ftl"); assertTrue(pdfTemplate.contains("#page=1&pagemode=thumbs")); } @Test void shouldPreferPdfForOfficePreviewByDefault() throws IOException { - String properties = readConfigResource("/application.properties"); + String properties = readResource("/application.properties"); assertTrue(properties.contains("office.preview.type = ${KK_OFFICE_PREVIEW_TYPE:pdf}")); } @@ -46,18 +46,4 @@ public class PdfViewerCompatibilityTests { return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8); } } - - private String readWebResource(String resourcePath) throws IOException { - try (InputStream inputStream = getClass().getResourceAsStream(resourcePath)) { - assertNotNull(inputStream); - return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8); - } - } - - private String readConfigResource(String resourcePath) throws IOException { - try (InputStream inputStream = getClass().getResourceAsStream(resourcePath)) { - assertNotNull(inputStream); - return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8); - } - } }