diff --git a/public/js/admin.js b/public/js/admin.js
index 9642fac..3228712 100644
--- a/public/js/admin.js
+++ b/public/js/admin.js
@@ -594,6 +594,22 @@
});
})();
+ function absoluteUrl(href) {
+ var h = String(href || '');
+ if (!h) {
+ return '';
+ }
+ // 已是绝对链接
+ if (h.indexOf('http://') === 0 || h.indexOf('https://') === 0) {
+ return h;
+ }
+ // 仅将站内相对路径补齐为绝对链接
+ if (h.indexOf('/') === 0 && window.location && window.location.origin) {
+ return String(window.location.origin) + h;
+ }
+ return h;
+ }
+
// 批次页:一键复制治理集合链接(例如:本批次失败 / 按Top原因)
(function(){
var btns = document.querySelectorAll('[data-action="copy-link"][data-href]');
@@ -602,13 +618,16 @@
btns.forEach(function(btn){
btn.addEventListener('click', function(){
var href = btn.getAttribute('data-href') || '';
- copyToClipboard(href).then(function(){
- if (toastSuccess('已复制链接')) {
+ var label = btn.getAttribute('data-label') || '链接';
+
+ var abs = absoluteUrl(href);
+ copyToClipboard(abs).then(function(){
+ if (toastSuccess('已复制' + label + '链接')) {
return;
}
- try { window.alert('已复制链接'); } catch (e) {}
+ try { window.alert('已复制' + label + '链接'); } catch (e) {}
}).catch(function(){
- try { window.alert('复制失败,请手动复制链接'); } catch (e) {}
+ try { window.alert('复制失败,请手动复制' + label + '链接'); } catch (e) {}
});
});
});
diff --git a/resources/views/admin/platform_batches/show.blade.php b/resources/views/admin/platform_batches/show.blade.php
index 4ba2e6d..4106cde 100644
--- a/resources/views/admin/platform_batches/show.blade.php
+++ b/resources/views/admin/platform_batches/show.blade.php
@@ -124,12 +124,12 @@
@if(($governanceLinks['failed'] ?? '') !== '')
|
本批次失败
-
+
@endif
@if(($governanceLinks['top_reason'] ?? '') !== '')
|
按Top原因
-
+
@endif
@if(($governanceLinks['retry_syncable'] ?? '') !== '')
|
diff --git a/tests/Feature/AdminPlatformBatchShowPageCopyLinkButtonsShouldIncludeLabelsTest.php b/tests/Feature/AdminPlatformBatchShowPageCopyLinkButtonsShouldIncludeLabelsTest.php
new file mode 100644
index 0000000..7468c1d
--- /dev/null
+++ b/tests/Feature/AdminPlatformBatchShowPageCopyLinkButtonsShouldIncludeLabelsTest.php
@@ -0,0 +1,36 @@
+seed();
+
+ $this->post('/admin/login', [
+ 'email' => 'platform.admin@demo.local',
+ 'password' => 'Platform@123456',
+ ])->assertRedirect('/admin');
+ }
+
+ public function test_batch_show_page_copy_link_buttons_should_include_data_label(): void
+ {
+ $this->loginAsPlatformAdmin();
+
+ $runId = 'BAS_COPY_LABEL_0001';
+
+ $html = $this->get('/admin/platform-batches/show?type=bas&run_id=' . $runId)
+ ->assertOk()
+ ->getContent();
+
+ // 至少校验“本批次失败”的复制按钮携带 label
+ $this->assertStringContainsString('data-role="copy-failed-link"', $html);
+ $this->assertStringContainsString('data-label="本批次失败"', $html);
+ }
+}