From c4fda5c61c6e71c1ffa6ed334522885d8699a729 Mon Sep 17 00:00:00 2001 From: shalousun <836575280@qq.com> Date: Sun, 12 Jul 2026 00:15:28 +0800 Subject: [PATCH 1/2] feat: add global server URL configuration to debug pages - Add editable server URL input at top of debug pages with flat, seamless design that blends into the page by default - CSS hover/focus states provide subtle visual feedback and title tooltip hints at click-to-edit behavior - Server URL value persisted to localStorage for session survival - resolveUrl() dynamically replaces the base URL in API requests with the user-configured server address - Display URL now shows path only (doc.path) instead of full server-prefixed URL, since the server is globally configurable --- src/main/resources/template/debug-all.html | 44 ++++++++++++++++++++- src/main/resources/template/html/debug.html | 41 ++++++++++++++++++- src/main/resources/template/js/debug.js | 41 ++++++++++++++++++- 3 files changed, 121 insertions(+), 5 deletions(-) diff --git a/src/main/resources/template/debug-all.html b/src/main/resources/template/debug-all.html index f7a3b095..f55a19d4 100644 --- a/src/main/resources/template/debug-all.html +++ b/src/main/resources/template/debug-all.html @@ -17,6 +17,39 @@ .hljs { padding: 0 } + @@ -88,7 +121,14 @@ -
<%if(isNotEmpty(revisionLogList)){%> +
+
+ Server URL: + +
+ <%if(isNotEmpty(revisionLogList)){%>
@@ -137,7 +177,7 @@ class="line-through">${htmlEscape(doc.desc)}<%}else{%><%if(!apiDocListOnlyHasDefaultGroup){%>${apiGroup.order}.${api.order}.${doc.order}. ${htmlEscape(doc.desc)}<%}else{%>${api.order}.${doc.order}. ${htmlEscape(doc.desc)}<%}%><%}%>

URL: ${doc.url}

+ data-page="${doc.page}">

URL: ${doc.path}

Type: ${doc.type}

diff --git a/src/main/resources/template/html/debug.html b/src/main/resources/template/html/debug.html index 005dd1a1..30835cbb 100644 --- a/src/main/resources/template/html/debug.html +++ b/src/main/resources/template/html/debug.html @@ -17,6 +17,39 @@ .hljs { padding: 0em } + @@ -63,6 +96,12 @@
+
+ Server URL: + +

${order}. ${desc}

<%for(doc in list){%> @@ -73,7 +112,7 @@ href="#_${order}_${doc.order}_${doc.desc}">${order}.${doc.order}. ${htmlEscape(doc.desc)}<%}%>

URL: ${doc.url}

+ id="${doc.methodId}-url">

URL: ${doc.path}

Type: ${doc.type}

diff --git a/src/main/resources/template/js/debug.js b/src/main/resources/template/js/debug.js index a3ed9a9e..070c6f21 100644 --- a/src/main/resources/template/js/debug.js +++ b/src/main/resources/template/js/debug.js @@ -36,6 +36,43 @@ $("[contenteditable=plaintext-only]").on('blur', function (e) { const highlightedCode = hljs.highlight('json', content).value; $this.html(highlightedCode); }) +// Server URL management +const SERVER_URL_STORAGE_KEY = 'smart-doc-server-url'; + +function getServerUrl() { + var $input = $('#smart-doc-server-url'); + if ($input.length && $input.val().trim()) { + return $input.val().trim().replace(/\/+$/, ''); + } + return ''; +} + +function resolveUrl(originalUrl) { + var serverUrl = getServerUrl(); + if (!serverUrl || !originalUrl) return originalUrl; + // originalUrl may contain multiple URLs separated by semicolon + return originalUrl.split(';').map(function (u) { + u = u.trim(); + if (!u) return u; + try { + var parsed = new URL(u); + return serverUrl + parsed.pathname + parsed.search + parsed.hash; + } catch (e) { + return serverUrl + '/' + u.replace(/^\//, ''); + } + }).join(';'); +} + +$(function () { + var savedUrl = localStorage.getItem(SERVER_URL_STORAGE_KEY); + if (savedUrl) { + $('#smart-doc-server-url').val(savedUrl); + } + $('#smart-doc-server-url').on('change input', function () { + localStorage.setItem(SERVER_URL_STORAGE_KEY, $(this).val().trim()); + }); +}); + $("button").on("click", function () { const $this = $(this); const id = $this.data("id"); @@ -58,9 +95,9 @@ $("button").on("click", function () { // query param const $queryElement = $("#" + id + "-query-params") let $urlDataElement = $("#" + id + "-url"); - const url = $urlDataElement.data("url"); + const url = resolveUrl($urlDataElement.data("url")); const isDownload = $urlDataElement.data("download"); - const page = $urlDataElement.data("page"); + const page = resolveUrl($urlDataElement.data("page")); const method = $("#" + id + "-method").data("method"); const contentType = $("#" + id + "-content-type").data("content-type"); console.log("request-headers=>" + JSON.stringify(headersData)) From 6149c452349bbc0c02a024567a46224c08825500 Mon Sep 17 00:00:00 2001 From: shalousun <836575280@qq.com> Date: Sun, 12 Jul 2026 01:04:53 +0800 Subject: [PATCH 2/2] chore: replace GITHUB_TOKEN with ORG_CHECKOUT_TOKEN for cross-repo access --- .github/workflows/build-and-run-example-project.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-run-example-project.yml b/.github/workflows/build-and-run-example-project.yml index 7b85a465..4d42cf31 100644 --- a/.github/workflows/build-and-run-example-project.yml +++ b/.github/workflows/build-and-run-example-project.yml @@ -66,7 +66,7 @@ jobs: uses: actions/checkout@v5 with: repository: smart-doc-group/smart-doc-maven-plugin - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.ORG_CHECKOUT_TOKEN }} - name: Set up JDK 8 uses: actions/setup-java@v5 @@ -133,7 +133,7 @@ jobs: uses: actions/checkout@v5 with: repository: smart-doc-group/smart-doc-example-cn - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.ORG_CHECKOUT_TOKEN }} - name: Set up JDK 17 uses: actions/setup-java@v5 @@ -262,7 +262,7 @@ jobs: uses: actions/checkout@v5 with: repository: smart-doc-group/smart-doc-example-cn - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.ORG_CHECKOUT_TOKEN }} - name: Set up JDK 17 uses: actions/setup-java@v5