feat(admin): 引入 admin.js(总台交互渐进增强基线)
This commit is contained in:
34
public/js/admin.js
Normal file
34
public/js/admin.js
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
// SaaSShop Admin JS
|
||||||
|
// 说明:用于增强总台管理的运营交互体验(尽量保持小而可治理)。
|
||||||
|
// 原则:不引入复杂构建链;以渐进增强为主,页面无 JS 也应可用。
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
if (window.__SAASSHOP_ADMIN_JS__) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
window.__SAASSHOP_ADMIN_JS__ = true;
|
||||||
|
|
||||||
|
function qs(sel, root) {
|
||||||
|
return (root || document).querySelector(sel);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 续费缺订阅治理:订单详情页“绑定订阅ID”输入框,小交互增强:
|
||||||
|
// - 输入后按 Enter 直接提交
|
||||||
|
// - 自动聚焦,减少点击
|
||||||
|
var attachInput = qs('#attach_site_subscription_id');
|
||||||
|
if (attachInput) {
|
||||||
|
try {
|
||||||
|
attachInput.focus();
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
attachInput.addEventListener('keydown', function (e) {
|
||||||
|
if (e && (e.key === 'Enter' || e.keyCode === 13)) {
|
||||||
|
var form = attachInput.form;
|
||||||
|
if (form) {
|
||||||
|
e.preventDefault();
|
||||||
|
form.submit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})();
|
||||||
@@ -98,6 +98,7 @@
|
|||||||
@yield('content')
|
@yield('content')
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
<script src="/js/admin.js" defer></script>
|
||||||
<script data-action="topnav-single-open">
|
<script data-action="topnav-single-open">
|
||||||
(function(){
|
(function(){
|
||||||
var root = document.querySelector('[data-role="topnav-groups-root"]');
|
var root = document.querySelector('[data-role="topnav-groups-root"]');
|
||||||
|
|||||||
31
tests/Feature/AdminLayoutShouldLoadAdminJsTest.php
Normal file
31
tests/Feature/AdminLayoutShouldLoadAdminJsTest.php
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class AdminLayoutShouldLoadAdminJsTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
protected function loginAsPlatformAdmin(): void
|
||||||
|
{
|
||||||
|
$this->seed();
|
||||||
|
|
||||||
|
$this->post('/admin/login', [
|
||||||
|
'email' => 'platform.admin@demo.local',
|
||||||
|
'password' => 'Platform@123456',
|
||||||
|
])->assertRedirect('/admin');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_admin_dashboard_should_include_admin_js(): void
|
||||||
|
{
|
||||||
|
$this->loginAsPlatformAdmin();
|
||||||
|
|
||||||
|
$res = $this->get('/admin');
|
||||||
|
$res->assertOk();
|
||||||
|
|
||||||
|
$res->assertSee('/js/admin.js', false);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user