File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,6 +66,9 @@ services:
6666docker compose up -d
6767```
6868
69+ > 容器启动时会自动修复 ` ./images ` 目录权限,无需手动 chown。
70+ > 如果是从旧版本升级,首次启动可能需要几秒完成权限修复。
71+
6972访问 ` http://localhost:3400/image ` ,后台 ` http://localhost:3400/image/admin ` 。
7073
7174</details >
Original file line number Diff line number Diff line change @@ -378,6 +378,50 @@ tr:last-child td {
378378 border-bottom : 0 ;
379379}
380380
381+ td .api-link {
382+ display : inline-flex;
383+ align-items : center;
384+ gap : 6px ;
385+ max-width : 320px ;
386+ white-space : nowrap;
387+ overflow : hidden;
388+ text-overflow : ellipsis;
389+ vertical-align : middle;
390+ margin : 0 ;
391+ padding : 4px 8px ;
392+ font-size : 0.82rem ;
393+ border-radius : 5px ;
394+ }
395+
396+ td .api-link span {
397+ overflow : hidden;
398+ text-overflow : ellipsis;
399+ }
400+
401+ td .copy-btn {
402+ flex-shrink : 0 ;
403+ min-height : 26px ;
404+ padding : 0 8px ;
405+ font-size : 0.76rem ;
406+ font-weight : 700 ;
407+ border-radius : 4px ;
408+ cursor : pointer;
409+ color : var (--primary );
410+ background : var (--primary-soft );
411+ border : 1px solid transparent;
412+ }
413+
414+ td .copy-btn : hover {
415+ background : var (--primary );
416+ color : # fff ;
417+ }
418+
419+ td .copy-btn .copied {
420+ color : var (--success );
421+ background : var (--teal-soft );
422+ pointer-events : none;
423+ }
424+
381425code {
382426 display : block;
383427 width : 100% ;
Original file line number Diff line number Diff line change @@ -18,17 +18,22 @@ function parseLimit(value) {
1818
1919function galleryRows ( galleries ) {
2020 if ( galleries . length === 0 ) {
21- return '<tr><td colspan="4 ">暂无图库,请在后台创建图库或手动放入图片目录。</td></tr>' ;
21+ return '<tr><td colspan="5 ">暂无图库,请在后台创建图库或手动放入图片目录。</td></tr>' ;
2222 }
2323 return galleries
2424 . map (
2525 ( gallery ) => {
2626 const displayName = gallery . label || gallery . name ;
27+ const nameCell = gallery . label
28+ ? `${ escapeHtml ( displayName ) } <br><span class="muted">${ escapeHtml ( gallery . name ) } </span>`
29+ : escapeHtml ( displayName ) ;
30+ const apiUrl = `/image/api/random?gallery=${ encodeURIComponent ( gallery . name ) } ` ;
2731 return `<tr>
28- <td>${ escapeHtml ( displayName ) } </td>
32+ <td>${ nameCell } </td>
2933 <td>${ gallery . total } </td>
3034 <td>${ gallery . pc } </td>
3135 <td>${ gallery . mobile } </td>
36+ <td><code class="api-link"><span>${ escapeHtml ( apiUrl ) } </span> <button type="button" class="copy-btn" data-copy="${ escapeHtml ( apiUrl ) } " title="复制">复制</button></code></td>
3237 </tr>` ;
3338 }
3439 )
Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ <h2>图库统计</h2>
5858 < th > 总数</ th >
5959 < th > PC</ th >
6060 < th > Mobile</ th >
61+ < th > API</ th >
6162 </ tr >
6263 </ thead >
6364 < tbody > {{galleryRows}}</ tbody >
@@ -78,5 +79,17 @@ <h2>API 调用示例</h2>
7879 </ article >
7980 </ section >
8081 </ main >
82+ < script >
83+ document . addEventListener ( 'click' , async ( e ) => {
84+ const btn = e . target . closest ( '.copy-btn' ) ;
85+ if ( ! btn ) return ;
86+ try {
87+ await navigator . clipboard . writeText ( btn . dataset . copy ) ;
88+ btn . textContent = '已复制' ;
89+ btn . classList . add ( 'copied' ) ;
90+ setTimeout ( ( ) => { btn . textContent = '复制' ; btn . classList . remove ( 'copied' ) ; } , 1500 ) ;
91+ } catch { btn . textContent = '失败' ; }
92+ } ) ;
93+ </ script >
8194 </ body >
8295</ html >
You can’t perform that action at this time.
0 commit comments