Compare commits

...
14 changed files with 492 additions and 44 deletions

No files matched your search

+55 -2
View File
@@ -14,6 +14,12 @@ use Illuminate\Support\Collection;
class ServerService
{
private const DISPLAY_REGIONS = [
'hk' => '🇭🇰|香港|Hong[ -]?Kong(?=$|[^\p{L}])|HK(?=$|[^\p{L}])',
'jp' => '🇯🇵|日本|Japan(?=$|[^\p{L}])|JP(?=$|[^\p{L}])',
'sg' => '🇸🇬|新加坡|Singapore(?=$|[^\p{L}])|SG(?=$|[^\p{L}])',
'us' => '🇺🇸|美国|美國|United States(?=$|[^\p{L}])|USA?(?=$|[^\p{L}])',
];
/**
* 获取所有服务器列表
@@ -62,10 +68,11 @@ class ServerService
->orWhereRaw('u + d < transfer_enable');
})
->orderBy('sort', 'ASC')
->orderBy('id', 'ASC')
->get()
->append(['last_check_at', 'last_push_at', 'online', 'is_online', 'available_status', 'cache_key', 'server_key']);
$servers = collect($servers)->map(function ($server) use ($user) {
return self::sortForDisplay($servers)->map(function ($server) use ($user) {
// 判断动态端口
if (str_contains($server->port, '-')) {
$port = $server->port;
@@ -78,8 +85,54 @@ class ServerService
$server->rate = $server->getCurrentRate();
return $server;
})->toArray();
}
return $servers;
private static function sortForDisplay(Collection $servers): Collection
{
$positions = $servers->pluck('id')->flip();
return $servers
->groupBy(fn(Server $server) => $server->parent_id ?: $server->id)
->sortBy(function (Collection $group, int $id) use ($positions) {
$primary = $group->firstWhere('id', $id) ?? $group->first();
return [...self::displayOrder($primary), $positions[$primary->id]];
})
->flatMap(fn(Collection $group) => $group
->sortBy(fn(Server $server) => (bool) $server->parent_id)
->values())
->values();
}
private static function displayOrder(Server $server): array
{
$name = preg_replace('/^(?:\[[^\]]+\]\s*)+/', '', trim($server->name));
$region = 0;
foreach (self::DISPLAY_REGIONS as $code => $prefix) {
if (preg_match('/^(?:(?:' . $prefix . ')[\s_-]*)+/iu', $name, $match) === 1) {
$number = self::displayNumber($server, $code, substr($name, strlen($match[0])));
return [$region, $number];
}
$region++;
}
return [$region, PHP_INT_MAX];
}
private static function displayNumber(Server $server, string $region, string $label): int
{
if (preg_match('/^(\d+)(?=$|[^\p{L}\d])/u', $label, $match) === 1) {
return (int) $match[1];
}
foreach ([data_get($server->protocol_settings, 'tls.server_name'), $server->host] as $host) {
if ($host && preg_match('/^(?:[a-z0-9]+-)*' . $region . '(\d+)(?=\.|$)/i', $host, $match) === 1) {
return (int) $match[1];
}
}
return PHP_INT_MAX;
}
/**
+8
View File
@@ -1,5 +1,13 @@
# Fuc:新版 FUC 用户主题适配
## Fuc 0.12.19 compatibility release — 2026-11-07
Based on production d552b8a592314d3e28ed261f213a49e272346f57, preserving the node ordering change. Mobile sidebar uses native vertical scrolling, desktop keeps PerfectScrollbar and the original hover indentation. Mobile dashboard tutorial buttons, subscription controls and chart stay inside their cards. Touch/narrow form controls have at least 16px fonts, touch login does not autofocus, and menu logic follows CSS matchMedia breakpoints.
Release candidate: all 55 core/DOM/motion/app/palette checks passed. Local evidence: 40 DOM/motion/app checks; 80 Chromium route-width measurements across 320–1440px; short/tall checkout dialogs; macOS Safari 375px layout. iOS 18.1 XS showed the new 16px control font, but final focus/keyboard-dismissal/navigation verification is incomplete because native inspector control did not execute reliably. No physical iPhone 13, Android/Windows or Firefox acceptance is claimed.
No shared business logic, admin UI, customer-service module, test accounts or payment-preview behavior included. Production client/tutorial links and pinned-announcement behavior retained. Deployment must record the prior real release path as well as SHA: the old directory name is a11df4f while its HEAD is d552b8a. Rollback is an atomic current symlink switch to that recorded path, without restoring the business database.
当前版本 **0.12.4**,已沿Git发布到独立FUC-XB测试站。IAB桌面/手机页面、动态交互、钱包下单/VIP升级/取消退款及XB原版后台验收已完成;旧FUC、DPL/HN未切换。真实支付、邮件、节点/客户端联网仍后置,不能据此宣布正式营业。完整范围及回执见[FUC-XB测试站](FUC_XB_STAGING.md#2026-11-04-最终验收隔离测试范围通过)。
## 0.12.4 隔离线上页面验收与修复(2026-11-04)
+6
View File
@@ -6,6 +6,12 @@
DPL、HN共享同一app/config/routes/vendor代码根;各自的数据库、用户、套餐、订单、密钥、缓存、会话、队列和日志继续独立。不是按访问域名动态切换数据库的多租户,也不把不同实例的数据合并。
## 用户节点列表与订阅的默认顺序
2026-11-06 用户指定 XB 各子项目共用同一展示顺序。用户节点列表和客户端订阅按香港、日本、新加坡、美国、其他排列。排序在 `ServerService::getAvailableServers()` 的权限与流量过滤之后执行。地区按节点名开头的国旗或地区标签识别。区内优先使用展示编号。以昵称命名的节点可从带同地区编号的 SNI 或主机名取序号。无法识别编号的节点按面板顺序排在同区编号节点之后。主节点和可见分身排在一起,主节点在前。
后台保存的手动顺序用于区内的同序号节点、无编号节点及其他地区。此规则随 XB 后端版本进入各实例,发布以实例的 Git 提交和服务器侧订阅回读为准。
## 唯一主题目录
所有主题以XB根目录下的 `theme/` 为唯一源:
+156 -7
View File
@@ -11,7 +11,7 @@ globalThis.innerWidth=1280;globalThis.matchMedia=()=>({matches:false,addEventLis
globalThis.requestAnimationFrame=window.requestAnimationFrame.bind(window);globalThis.cancelAnimationFrame=window.cancelAnimationFrame.bind(window);
window.scrollTo=()=>{};window.ApexCharts=class{render(){return Promise.resolve()}destroy(){}};
const plans=[{id:1,name:'Paid',month_price:1200,transfer_enable:100},{id:2,name:'Free',month_price:0,transfer_enable:10}];
const calls=[];let delayedLogin,delayedCoupon;
const calls=[];let delayedLogin,delayedCoupon,checkoutAmount=0,checkoutStatus=0,failOrderCheck=false,orders=[];
const payload=(data,status=200)=>({ok:status<400,status,json:async()=>({data})});
globalThis.fetch=async(url,options={})=>{
if(String(url).startsWith('file:'))return {ok:true,text:()=>fs.readFile(new URL(url),'utf8'),json:async()=>JSON.parse(await fs.readFile(new URL(url),'utf8'))};
@@ -26,11 +26,21 @@ globalThis.fetch=async(url,options={})=>{
const notices=Array.from({length:18},(_,i)=>({id:i+1,title:'归档公告 '+(i+1),content:'归档正文',created_at:1793836800}));
return {ok:true,status:200,json:async()=>({data:notices.slice(offset,offset+5),total:notices.length})};
}
if(path==='user/plan/fetch')return payload(plans);
if(path==='user/plan/fetch')return payload([plans[0]]);
if(path==='user/plan/fetch?id=2')return payload({...plans[1],show:false,sell:false,renew:true,capacity_limit:'Sold out'});
if(path==='user/coupon/check')return new Promise(resolve=>delayedCoupon=()=>resolve(payload({name:'QA'})));
if(path==='user/order/save')return payload('synthetic-order');
if(path==='user/order/detail?trade_no=synthetic-order')return payload({trade_no:'synthetic-order',plan:plans[1],period:'month_price',status:0,total_amount:0});
if(path==='user/order/fetch')return payload(orders);
if(path==='user/order/detail?trade_no=synthetic-order')return payload({trade_no:'synthetic-order',plan:plans[1],period:'month_price',status:checkoutStatus,total_amount:checkoutAmount});
if(path==='user/order/check?trade_no=synthetic-order')return payload(checkoutStatus,failOrderCheck?503:200);
if(path==='user/order/getPaymentMethod')return payload([{id:17,name:'空中支付 · 微信支付',payment:'Epay'},{id:21,name:'空中支付 · 支付宝',payment:'Epay'}]);
if(path==='user/order/checkout')return payload({type:1,data:'https://pay.example.test/synthetic-only'});
if(path==='user/order/cancel'){
const order=orders.find(order=>order.trade_no===JSON.parse(options.body).trade_no);
if(!order||Number(order.status)!==0)return payload(null,422);
order.status=2;
return payload(true);
}
return payload([]);
};
const append=document.head.append.bind(document.head);
@@ -70,13 +80,152 @@ test('leaving during the original modal transition leaves no late component erro
assert.deepEqual(jsErrors.map(e=>e.message),[]);
});
test('manual renewal of an off-sale owned plan keeps the actual XB plan and period',async()=>{
await go('myplan');const renewal=document.querySelector('.card-header .dropdown-item');assert.ok(renewal);
renewal.click();await until(()=>document.body.dataset.nativePage==='purchase');
const form=document.querySelector('[data-form=purchase]');form.dispatchEvent(new window.Event('submit',{bubbles:true,cancelable:true}));
await go('plans');
const renewal=document.querySelector('[data-action=buy][data-id="2"][data-period="month_price"]');assert.ok(renewal);
renewal.click();await until(()=>document.querySelector('#coupon_modal.show'));
document.querySelector('#coupon_modal [data-form=purchase-coupon]').dispatchEvent(new window.Event('submit',{bubbles:true,cancelable:true}));
await until(()=>document.querySelector('#order_modal.show'));
document.querySelector('#order_modal [data-form=purchase]').dispatchEvent(new window.Event('submit',{bubbles:true,cancelable:true}));
await until(()=>document.body.dataset.nativePage==='checkout');
assert.deepEqual(calls.find(c=>c.path==='user/order/save').body,{plan_id:2,period:'month_price'});
assert.deepEqual(calls.filter(c=>c.path==='user/order/save').at(-1).body,{plan_id:2,period:'month_price'});
const modal=document.querySelector('#fuc-checkout-modal');
assert.ok(document.querySelector('[data-action=buy][data-id="2"]'));
assert.ok(modal.querySelector('[data-form=checkout]'));
await until(()=>modal.classList.contains('show'));
modal.querySelector('[aria-label="关闭订单详情"]').click();
await until(()=>document.body.dataset.nativePage==='plans');
assert.equal(location.hash,'#/plans');
location.hash='/checkout/synthetic-order';
await until(()=>document.body.dataset.nativePage==='checkout');
assert.equal(document.querySelector('#fuc-checkout-modal'),null);
assert.ok(document.querySelector('[data-form=checkout]'));
});
test('the old plan URL opens the order list, with an unpaid order accessible on its page',async()=>{
orders=Array.from({length:20},(_,i)=>({trade_no:'paid-'+i,status:3}));
orders.push({trade_no:'synthetic-order',status:0});
try{
location.hash='/myplan';
await until(()=>document.body.dataset.nativePage==='orders');
assert.equal(location.hash,'#/orders');
const menu=document.querySelector('.navigation-main a[href="#/orders"]');
assert.equal(menu.querySelector('.menu-title').textContent,'套餐订单');
assert.ok(menu.querySelector('.icon-hard-drive'));
assert.equal(menu.closest('li').nextElementSibling.querySelector('a').getAttribute('href'),'#/wallet');
assert.equal(document.querySelector('[data-pending-order]'),null);
assert.doesNotMatch(document.querySelector('tbody').textContent,/synthetic-order/);
document.querySelector('[data-action=next]').click();
const unpaidLink=()=>document.querySelector('tbody a[href="#/checkout/synthetic-order?from=orders"]');
await until(unpaidLink);
assert.equal(unpaidLink().textContent,'继续支付');
unpaidLink().click();
await until(()=>document.querySelector('#fuc-checkout-modal.show'));
assert.equal(location.hash,'#/checkout/synthetic-order?from=orders');
document.querySelector('#fuc-checkout-modal [data-action=native-dismiss]').click();
await until(()=>document.body.dataset.nativePage==='orders');
assert.equal(location.hash,'#/orders');
orders.pop();
location.hash='/subscribe';
await until(()=>location.hash==='#/orders'&&document.querySelector('tbody tr'));
}finally{orders=[];}
});
test('pending orders can be canceled from their rows after confirmation',async()=>{
await go('plans');
orders=[{trade_no:'first-order',status:0},{trade_no:'row-order',status:'0'},{trade_no:'paid-order',status:3}];
try{
await go('orders');
const sent=()=>calls.filter(call=>call.path==='user/order/cancel').map(call=>call.body.trade_no);
const row=()=>document.querySelector('tbody button[data-trade-no="row-order"]');
const first=()=>document.querySelector('tbody button[data-trade-no="first-order"]');
assert.equal(document.querySelector('[data-pending-order]'),null);
assert.equal(document.querySelector('tbody button[data-trade-no="paid-order"]'),null);
assert.equal(document.querySelector('tbody a[href="#/checkout/paid-order?from=orders"]').textContent,'查看');
row().click();
assert.equal(row().textContent,'再次点击确认取消');
assert.deepEqual(sent(),[]);
row().click();
await until(()=>!row());
first().click();
assert.deepEqual(sent(),['row-order']);
first().click();
await until(()=>!first());
assert.deepEqual(sent(),['row-order','first-order']);
assert.equal(location.hash,'#/orders');
assert.equal(document.querySelectorAll('tbody button[data-trade-no]').length,0);
}finally{orders=[];}
});
test('a shop order opens checkout over the shop and closes back to it',async()=>{
await go('plans');
document.querySelector('[data-action=buy]').click();
await until(()=>document.querySelector('#coupon_modal.show'));
document.querySelector('[data-form=purchase-coupon]').dispatchEvent(new window.Event('submit',{bubbles:true,cancelable:true}));
await until(()=>document.querySelector('#order_modal.show'));
document.querySelector('#order_modal [data-form=purchase]').dispatchEvent(new window.Event('submit',{bubbles:true,cancelable:true}));
await until(()=>document.querySelector('#fuc-checkout-modal.show'));
assert.equal(location.hash,'#/checkout/synthetic-order?from=plans');
assert.ok(document.querySelector('[data-action=buy]'));
document.querySelector('#fuc-checkout-modal [data-action=native-dismiss]').click();
await until(()=>document.body.dataset.nativePage==='plans');
assert.equal(location.hash,'#/plans');
});
test('payment cards show short labels and open the selected native cashier directly',async t=>{
const opened=[];
t.mock.method(window.HTMLAnchorElement.prototype,'click',function(){opened.push([this.href,this.target]);});
checkoutAmount=1200;location.hash='/checkout/synthetic-order?from=plans';
await until(()=>document.querySelector('#fuc-checkout-modal input[name=method]'));
const form=document.querySelector('#fuc-checkout-modal [data-form=checkout]');
const first=form.querySelector('input[value="17"]'),second=form.querySelector('input[value="21"]');
assert.deepEqual([...form.querySelectorAll('.nav-text')].map(node=>node.textContent),['微信','支付宝']);
assert.equal(first.checked,true);assert.equal(document.querySelector('#fuc-checkout-modal details'),null);
second.click();
assert.equal(second.checked,true);assert.equal(first.nextElementSibling.classList.contains('active'),false);
assert.equal(second.nextElementSibling.classList.contains('active'),true);
form.dispatchEvent(new window.Event('submit',{bubbles:true,cancelable:true}));
await until(()=>calls.some(c=>c.path==='user/order/checkout'));
assert.deepEqual(calls.find(c=>c.path==='user/order/checkout').body,{trade_no:'synthetic-order',method:'21'});
await until(()=>opened.length>0);
assert.deepEqual(opened,[['https://pay.example.test/synthetic-only','_self']]);
assert.equal(document.querySelector('#payment-result').textContent,'');
checkoutAmount=0;await go('plans');
});
test('payment refresh is a fallback for failed or slow checks and clears when the order advances',async t=>{
t.mock.method(window.HTMLAnchorElement.prototype,'click',()=>{});
const realSetTimeout=globalThis.setTimeout;
const start=Date.now();
let now=start,nextCheck;
t.mock.method(Date,'now',()=>now);
t.mock.method(globalThis,'setTimeout',(callback,delay,...args)=>{
if(delay!==5000)return realSetTimeout(callback,delay,...args);
const timer=realSetTimeout(callback,delay,...args);
nextCheck=async()=>{clearTimeout(timer);await callback(...args);};
return timer;
});
const refresh=()=>document.querySelector('[data-action=refresh-payment]');
const check=async()=>{assert.ok(nextCheck);const run=nextCheck;nextCheck=null;await run();};
checkoutAmount=1200;
try{
location.hash='/checkout/synthetic-order?from=orders';
await until(()=>refresh());
assert.equal(refresh().hidden,true);
document.querySelector('[data-form=checkout]').dispatchEvent(new window.Event('submit',{bubbles:true,cancelable:true}));
await until(()=>nextCheck);
now=start+5000;await check();
assert.equal(refresh().hidden,true);
failOrderCheck=true;await check();
assert.equal(refresh().hidden,false);
failOrderCheck=false;now=start+60000;await check();
assert.equal(refresh().hidden,false);
checkoutStatus=1;await check();
assert.match(document.querySelector('#fuc-checkout-modal .fuc-checkout-product').textContent,/开通中/);
assert.equal(refresh().hidden,true);
checkoutStatus=3;await check();
assert.match(document.querySelector('#fuc-checkout-modal .fuc-checkout-product').textContent,/已完成/);
assert.equal(refresh(),null);
}finally{
checkoutAmount=0;checkoutStatus=0;failOrderCheck=false;await go('plans');
}
});
test('the announcement page shows all four native XB pages in order',async()=>{
calls.length=0;
await go('notices');
assert.deepEqual(calls.filter(c=>c.path.startsWith('user/notice/fetch?current=')).map(c=>c.path.split('=')[1]),['1','2','3','4']);
const headings=[...document.querySelectorAll('h5')].map(node=>node.textContent.trim()).filter(title=>title.startsWith('归档公告 '));
+60 -18
View File
@@ -10,6 +10,17 @@ const {paymentForm,showPayment}=await import('../../theme/Fuc/assets/payments.mj
const {richText}=await import('../../theme/Fuc/assets/content.mjs');
const {copyText}=await import('../../theme/Fuc/assets/clipboard.mjs');
const native=await import('../../theme/Fuc/assets/native.mjs');await native.nativeReady;
test('touch login waits for a tap while desktop keeps keyboard autofocus',()=>{
const original=window.matchMedia;
try {
window.matchMedia=()=>({matches:true});
const touch=new DOMParser().parseFromString(native.nativeLogin('富蕴'),'text/html');
assert.equal(touch.querySelector('[autofocus]'),null);
window.matchMedia=()=>({matches:false});
const desktop=new DOMParser().parseFromString(native.nativeLogin('富蕴'),'text/html');
assert.equal(desktop.querySelector('[autofocus]').name,'email');
}finally{window.matchMedia=original;}
});
test('user navigation keeps active shared CSS and its dark/bridge overrides attached',async()=>{
const append=document.head.append.bind(document.head),insert=document.head.insertBefore.bind(document.head),moved=[];
document.head.append=node=>{if(node.isConnected&&node.tagName==='LINK')moved.push(node);append(node);if(node.tagName==='LINK')queueMicrotask(()=>node.onload?.());};
@@ -36,18 +47,17 @@ test('wallet-funded checkout and history show package value instead of zero onli
const order={trade_no:'synthetic-wallet-order',status:3,total_amount:0,balance_amount:10000,surplus_amount:0,surplus_credit:0,period:'month_price',plan:{name:'Synthetic plan'},created_at:1};
const context={user:{},sub:{},data:order,methods:[],config:{}};
const detail=new DOMParser().parseFromString(native.nativeSecondary('checkout',context),'text/html');
assert.equal(detail.querySelector('#invoice_content_table tbody td:last-child').textContent.trim(),'100.00');
assert.match(detail.querySelector('[data-order-settlement]').textContent,/套餐价格:.*100\.00/);
assert.match(detail.querySelector('[data-order-settlement]').textContent,/钱包抵扣:.*100\.00/);
const history=new DOMParser().parseFromString(native.nativeSecondary('orders',{...context,data:[order]}),'text/html');
assert.match(history.querySelector('tbody tr').textContent,/100\.00/);
const myplan=new DOMParser().parseFromString(native.nativeSecondary('myplan',{...context,data:[order]}),'text/html');
assert.match(myplan.querySelector('tbody tr').textContent,/100\.00/);
});
test('purchase preview keeps list price but leaves final VIP/coupon/balance settlement to native order',()=>{
const html=native.nativeSecondary('purchase',{user:{vip:{enabled:true,name:'小福',discount_percent:8}},sub:{},data:{id:167,name:'Synthetic',month_price:10000},period:'month_price',config:{}});
const view=new DOMParser().parseFromString(html,'text/html');
assert.equal(view.querySelector('#product-buy-total').textContent,'下单后确认');
assert.match(view.body.textContent,/100\.00/);assert.match(view.querySelector('[data-vip-price]').textContent,/9\.2 折/);
assert.match(view.body.textContent,/100\.00/);assert.doesNotMatch(view.body.textContent,/小福|9\.2 折/);
assert.match(view.querySelector('[data-order-price-notice]').textContent,/取消未支付订单可退回已抵扣余额/);
});
test('zero online remainder needs no channel and cancelled wallet deduction is labelled returned',()=>{
@@ -59,30 +69,53 @@ test('zero online remainder needs no channel and cancelled wallet deduction is l
view=new DOMParser().parseFromString(native.nativeSecondary('checkout',{...context,data:{...context.data,status:2}}),'text/html');
assert.match(view.querySelector('[data-order-settlement]').textContent,/原钱包抵扣(已退回)/);
});
test('discounted checkout formats fixed and percentage coupons without changing the native amount due',()=>{
const context={user:{vip:{levels:[{name:'小福',discount:8}]}},sub:{},asModal:true,data:{trade_no:'synthetic-discount',status:0,period:'month_price',total_amount:404,balance_amount:500,discount_amount:296,coupon_id:1,plan:{name:'Synthetic'}},discountBreakdown:{original_amount:1200,member_amount:96,coupon_amount:200,member_percent:8,coupon_code:'FUCUI2',coupon_type:1},methods:[{id:17,name:"微信",payment:"Epay"},{id:21,name:"支付宝",payment:"Epay"}],config:{}};
const view=new DOMParser().parseFromString(native.nativeSecondary('checkout',context),'text/html');
const text=view.querySelector('[data-order-settlement]').textContent;
assert.match(text,/套餐价格:.*12\.00/);
assert.match(text,/小福:-8%优惠码:-¥2\.00优惠合计:-¥2\.96/);
assert.equal(view.querySelector('[data-order-settlement] > [data-settlement-divider]').textContent,'优惠合计:-¥2.96');
assert.match(text,/钱包抵扣:.*5\.00/);assert.match(text,/还需支付:.*4\.04/);
assert.equal(view.querySelector('#fuc-checkout-modal details'),null);
const pay=view.querySelector('[data-form=checkout] button[type=submit]');
assert.equal(pay.textContent,'在线支付');
assert.equal(pay.disabled,false);
assert.equal(view.querySelectorAll('input[name=method]').length,2);
const checkout=coupon_type=>native.nativeSecondary('checkout',{...context,discountBreakdown:{...context.discountBreakdown,coupon_type}});
assert.match(new DOMParser().parseFromString(checkout(2),'text/html').querySelector('[data-order-settlement]').textContent,/优惠码:-16\.67%/);
assert.match(new DOMParser().parseFromString(checkout(null),'text/html').querySelector('[data-order-settlement]').textContent,/优惠码:-¥2\.00/);
});
test('package amount uses only consumed old-plan credit and displays channel fees separately',()=>{
const context={user:{},sub:{},data:{trade_no:'synthetic',status:3,total_amount:2500,balance_amount:1000,surplus_amount:3000,surplus_credit:1500,handling_amount:125,plan:{name:'Synthetic'},period:'month_price'},methods:[],config:{}};
const view=new DOMParser().parseFromString(native.nativeSecondary('checkout',context),'text/html');
assert.equal(view.querySelector('#invoice_content_table tbody td:last-child').textContent.trim(),'50.00');
assert.match(view.querySelector('[data-order-settlement]').textContent,/套餐价格:.*50\.00/);
const settlement=view.querySelector('[data-order-settlement]').textContent;
assert.match(settlement,/旧套餐折抵:.*15\.00/);assert.match(settlement,/渠道手续费:.*1\.25/);assert.match(settlement,/折抵返余:.*15\.00/);
});
test('VIP uses the original dashboard card and displays cumulative, level and next discount',()=>{
test('VIP uses the original dashboard card without the removed upgrade hint',()=>{
const user={email:'[email protected]',vip:{enabled:true,name:'小福',cumulative_cents:10000,discount_percent:8,next_level:{name:'中福'},remaining_cents:10000}};
const host=document.createElement('div');host.innerHTML=native.nativeDashboard(user,{plan_id:1,plan:{name:'套餐'},transfer_enable:100,u:0,d:0,expired_at:2000000000},[],'福云',v=>v);
const card=host.querySelector('.card-stats .col');assert.equal(card.querySelector('span.h3').textContent,'小福');assert.match(card.textContent,/累计支付:¥ 100.00/);assert.match(card.querySelector('[data-vip-progress]').textContent,/9.2 折.*距中福还差 ¥100.00/);
const card=host.querySelector('.card-stats .col');assert.equal(card.querySelector('span.h3').textContent,'小福');assert.match(card.textContent,/累计支付:¥ 100.00/);assert.equal(card.querySelector('[data-vip-progress]'),null);
const off=document.createElement('div');off.innerHTML=native.nativeDashboard({email:'[email protected]'},{plan:{name:'套餐'}},[],'福云',v=>v);assert.equal(off.querySelector('[data-vip-progress]'),null);
});
test('payment HTML rebuild excludes scripts, handlers and unsafe actions',()=>{
const form=paymentForm('<form action="https://pay.example.test/checkout" method="post" onsubmit="bad()"><input name="signature" value="signed"><input name="bad" type="file"><script>bad()</script></form>');
assert.equal(form.method,'post');assert.equal(form.target,'_blank');assert.equal(form.querySelector('[name=signature]').value,'signed');
assert.equal(form.method,'post');assert.equal(form.target,'_self');assert.equal(form.querySelector('[name=signature]').value,'signed');
assert.equal(form.querySelector('script,[onsubmit],input[type=file]'),null);
assert.throws(()=>paymentForm('<form action="javascript:bad()"></form>'));
assert.throws(()=>paymentForm('<form action="https://u:[email protected]/"></form>'));
});
test('payment redirect is explicit and never reports completed before settlement',async()=>{
test('checkout submits a rebuilt provider form directly without running response HTML',async t=>{
const container=document.createElement('div');
assert.equal(await showPayment({type:1,data:'https://pay.example.test/'},container),false);
assert.equal(container.querySelector('a').rel,'noopener noreferrer');
const sent=[];
t.mock.method(window.HTMLFormElement.prototype,'submit',function(){
assert.ok(this.isConnected);
sent.push([this.action,this.method,this.target,this.querySelector('[name=signature]').value]);
});
assert.equal(await showPayment({type:1,data:'<form action="https://pay.example.test/checkout" method="post"><input name="signature" value="signed"><script>bad()</script></form>'},container),false);
assert.deepEqual(sent,[['https://pay.example.test/checkout','post','_self','signed']]);
assert.equal(container.childElementCount,0);
assert.equal(await showPayment({type:-1,data:true},container),true);
});
test('copy succeeds with original HTTP fallback, cleans selection field and prefers modern clipboard',async()=>{
@@ -143,6 +176,18 @@ test('dashboard retains source empty-subscription state and profile does not inv
const profile=new DOMParser().parseFromString(native.nativeSecondary('profile',{sub:{plan:{name:'Long plan is not an account level'}},richText}),'text/html');
assert.equal(profile.querySelector('.card-profile-stats .heading').textContent,'—');
});
test('the dashboard enables each Nyanpasu download against the configured Resource origin',()=>{
const render=origin=>new DOMParser().parseFromString(native.nativeDashboard({},{},[],'QA',richText,null,origin),'text/html');
const links=view=>[...view.querySelectorAll('[data-nyanpasu-package]')];
assert.ok(links(render('')).every(link=>link.href.startsWith('https://github.com/libnyanpasu/clash-nyanpasu/releases/download/')));
const connected=links(render('http://resource.loc:8612'));
assert.deepEqual(connected.map(link=>link.getAttribute('href')),[
'http://resource.loc:8612/downloads/software/clash-nyanpasu/clash-nyanpasu-windows-x64.exe',
'http://resource.loc:8612/downloads/software/clash-nyanpasu/clash-nyanpasu-macos-arm64.dmg',
'http://resource.loc:8612/downloads/software/clash-nyanpasu/clash-nyanpasu-macos-x64.dmg',
]);
assert.ok(connected.every(link=>!link.hasAttribute('data-action')));
});
test('shop mirrors source plan-group tabs with period cards and original purchase modals',()=>{
const plans=[{id:1,name:'轻量套餐',month_price:1200,year_price:12000,reset_price:500,transfer_enable:100},{id:2,name:'标准套餐',month_price:0,transfer_enable:10}];
const html=native.nativeSecondary('plans',{user:{plan_id:2},sub:{},data:plans,period:'plan-1',richText,config:{}});
@@ -154,18 +199,15 @@ test('shop mirrors source plan-group tabs with period cards and original purchas
assert.equal(view.querySelector('#order_modal form').dataset.form,'purchase');
assert.equal(view.querySelector('#pay-confirm').closest('[data-action]'),null,'submit must not inherit an unrelated banner action');
native.fillPurchaseModal(view,plans[0],'year_price','QA');
assert.match(view.querySelector('[data-confirm-plan-specs]').textContent,/套餐流量:100 GB/);
assert.match(view.querySelector('[data-confirm-plan-specs]').textContent,/优惠码:QA/);
assert.equal(view.querySelector('#order_modal [name=coupon_code]').value,'QA');
assert.match(view.querySelector('#shop_time').textContent,/12 个月/);
assert.equal(view.querySelector('#autorenew').disabled,true);
assert.equal(view.querySelector('#order_modal #autorenew'),null);
assert.doesNotMatch(view.querySelector('#order_modal').textContent,/自动续订|从本地钱包扣费/);
assert.doesNotMatch(view.querySelector('.selling-slide').textContent,/—GB|满—元/);
assert.match(group.querySelector('.pricing-content').textContent,/跟随系统设置/);
});
test('current-plan renewal uses the authorized XB plan and preserves all configured periods',()=>{
const renewPlan={id:7,name:'Existing',sell:false,show:false,renew:true,capacity_limit:'Sold out',month_price:1200,year_price:12000,reset_price:100};
const view=new DOMParser().parseFromString(native.nativeSecondary('myplan',{user:{plan_id:7},sub:{plan:renewPlan},data:[],renewPlan,richText}),'text/html');
assert.deepEqual([...view.querySelectorAll('.card-header .dropdown-item')].map(n=>n.getAttribute('href')),['#/purchase/7?period=month_price','#/purchase/7?period=year_price','#/purchase/7?period=reset_price']);
assert.equal(view.querySelector('.card-header h4').textContent,'Existing');
});
test('captcha contracts cover Turnstile, v2, v3, expiration and disposal with SDK doubles',async()=>{
const {createCaptcha}=await import('../../theme/Fuc/assets/captcha.mjs');
const original=document.head.append.bind(document.head);document.head.append=node=>{original(node);queueMicrotask(()=>node.onload?.());};
+17
View File
@@ -68,3 +68,20 @@ test('Waves is attached and mobile menu backdrop restores scroll on close',()=>{
ui.toggleMenu(root);assert.equal(document.body.style.overflow,'');assert.equal(root.querySelector('.sidenav-overlay').classList.contains('d-none'),true);
ui.disposeInteractions(root);
});
test('menu behavior follows CSS breakpoint when a zoomed visual viewport is narrower',()=>{
const original=window.matchMedia;
root.innerHTML='<div class="main-menu"><div class="main-menu-content"></div></div><a class="menu-toggle"></a>';
document.body.className='vertical-layout vertical-menu-modern menu-expanded';
globalThis.innerWidth=800;
window.matchMedia=query=>({matches:query==='(min-width: 1200px)'});
try {
ui.paintInteractions(root);ui.toggleMenu(root);
assert.equal(document.body.classList.contains('menu-collapsed'),true);
assert.equal(document.body.classList.contains('menu-open'),false);
assert.equal(document.body.style.overflow,'');
window.matchMedia=()=>({matches:false});
ui.toggleMenu(root);
assert.equal(document.body.classList.contains('menu-open'),true);
assert.equal(document.body.style.overflow,'hidden');
}finally{ui.disposeInteractions(root);window.matchMedia=original;}
});
@@ -0,0 +1,96 @@
<?php
namespace Tests\Feature\Server;
use App\Models\Server;
use App\Models\User;
use App\Protocols\ClashMeta;
use App\Services\ServerService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Symfony\Component\Yaml\Yaml;
use Tests\TestCase;
class ServerDisplayOrderTest extends TestCase
{
use RefreshDatabase;
protected function beforeRefreshingDatabase(): void
{
config([
'database.default' => 'sqlite',
'database.connections.sqlite.url' => null,
'database.connections.sqlite.database' => ':memory:',
'cache.default' => 'array',
'cache.stores.redis' => ['driver' => 'array'],
]);
DB::purge('sqlite');
Cache::forgetDriver('redis');
}
public function test_user_list_and_clash_subscription_group_regions_and_keep_aliases_with_their_parent(): void
{
$this->node('🇨🇦 加拿大 - 日本中转', 1);
$this->node('🇺🇸 美国 - 金穗', 2);
$this->node('SG01', 3);
$this->node('日本 JP - 02', 4, 'jp01.example.test');
$this->node('🇭🇰 香港 - 太平', 5, 'hk02.example.test');
$hongKong = $this->node('🇭🇰 香港 - 维港', 6, 'hk01.example.test');
$this->node('🇭🇰 香港 - 扬帆', 16, 'hk01.example.test', ['parent_id' => $hongKong->id]);
$japan = $this->node('🇯🇵 日本 JP - 01', 7, 'jp03.example.test');
$this->node('🇯🇵 日本 - 樱雪', 0, 'jp03.example.test', ['parent_id' => $japan->id]);
$this->node('🇭🇰 香港 - 福来', 8, 'vn01.example.test');
$hidden = $this->node('HK03', 9, 'hk03.example.test', ['group_ids' => ['2']]);
$this->node('HK03 分身', 17, 'hk03.example.test', ['parent_id' => $hidden->id]);
$this->node('其他节点', 10);
$user = new User([
'group_id' => 1,
'uuid' => '123e4567-e89b-12d3-a456-426614174000',
'u' => 0,
'd' => 0,
'transfer_enable' => 1073741824,
'expired_at' => 2000000000,
]);
$expected = [
'🇭🇰 香港 - 维港',
'🇭🇰 香港 - 扬帆',
'🇭🇰 香港 - 太平',
'HK03 分身',
'🇭🇰 香港 - 福来',
'🇯🇵 日本 JP - 01',
'🇯🇵 日本 - 樱雪',
'日本 JP - 02',
'SG01',
'🇺🇸 美国 - 金穗',
'🇨🇦 加拿大 - 日本中转',
'其他节点',
];
$servers = ServerService::getAvailableServers($user);
$this->assertSame($expected, array_column($servers, 'name'));
$response = (new ClashMeta($user, $servers))->handle();
$subscription = Yaml::parse($response->getContent());
$this->assertSame($expected, array_column($subscription['proxies'], 'name'));
$this->assertSame($expected, collect($subscription['proxy-groups'])
->firstWhere('name', '自动选择')['proxies']);
}
private function node(string $name, int $sort, ?string $sni = null, array $overrides = []): Server
{
return Server::create(array_replace([
'name' => $name,
'type' => Server::TYPE_HYSTERIA,
'host' => 'relay.example.test',
'port' => '443',
'server_port' => 443,
'group_ids' => ['1'],
'rate' => 1,
'sort' => $sort,
'show' => true,
'protocol_settings' => ['version' => 2, 'tls' => ['server_name' => $sni]],
], $overrides));
}
}
+5 -4
View File
@@ -1,12 +1,13 @@
import {isDesktopLayout} from './layout.mjs?v=0.12.19';
import {applyPalette} from './palettes.mjs?v=0.12.6';
import {subscriptionUrl as makeSubscriptionUrl,importUrl} from './subscription.mjs?v=0.12.6';
import {interactionsReady,paintInteractions,disposeInteractions,showModal,hideModals,toggleCollapse,selectTab,toggleDropdown,notify,scrollSection,toggleMenu,updateMenu,authFeedback,confirmSubscriptionReset} from './interactions.mjs?v=0.12.17';
import {interactionsReady,paintInteractions,disposeInteractions,showModal,hideModals,toggleCollapse,selectTab,toggleDropdown,notify,scrollSection,toggleMenu,updateMenu,authFeedback,confirmSubscriptionReset} from './interactions.mjs?v=0.12.19';
import {richText} from './content.mjs?v=0.12.14';
import {copyText} from './clipboard.mjs?v=0.12.6';
import {createCaptcha} from './captcha.mjs?v=0.12.6';
import {showPayment,mountCard} from './payments.mjs?v=0.12.14';
import {beginPageProgress,finishPageProgress} from './progress.mjs?v=0.12.6';
import {nativeReady,prepareNativeMode,nativeMode,fillPurchaseModal,nativeHeader,nativeFooter,nativeDashboard,nativeHome,nativeAuth,nativeSecondary,paintNativeChart,paintNativeHome} from './native.mjs?v=0.12.18';
import {nativeReady,prepareNativeMode,nativeMode,fillPurchaseModal,nativeHeader,nativeFooter,nativeDashboard,nativeHome,nativeAuth,nativeSecondary,paintNativeChart,paintNativeHome} from './native.mjs?v=0.12.19';
import {escape as e, money, bytes, date, list, groupedList, periods, orderStates, soldOut, safeUrl, createApi, fetchNotices, routeFromHash,canPurchase} from './core.mjs?v=0.12.13';
const settings = window.fucSettings || {};
const root = document.querySelector('#app');
@@ -288,8 +289,8 @@ matchMedia('(prefers-color-scheme: dark)').addEventListener('change',event=>{if(
window.addEventListener('scroll',()=>{document.getElementById('navbar')?.classList.toggle('nav-sticky',window.scrollY>=50);},{passive:true});
let viewportFrame,desktopViewport=innerWidth>=1200;
window.addEventListener('resize',()=>{cancelAnimationFrame(viewportFrame);viewportFrame=requestAnimationFrame(()=>{const mode=document.body.dataset.nativeMode;if(!mode)return;const desktop=innerWidth>=1200;if(desktop===desktopViewport){updateMenu(root);return;}desktopViewport=desktop;nativeMode(mode,mode==='auth'?getRoute().name:'');updateMenu(root);if(root.querySelector('.modal.show'))document.body.classList.add('modal-open');});});
let viewportFrame,desktopViewport=isDesktopLayout();
window.addEventListener('resize',()=>{cancelAnimationFrame(viewportFrame);viewportFrame=requestAnimationFrame(()=>{const mode=document.body.dataset.nativeMode;if(!mode)return;const desktop=isDesktopLayout();if(desktop===desktopViewport){updateMenu(root);return;}desktopViewport=desktop;nativeMode(mode,mode==='auth'?getRoute().name:'');updateMenu(root);if(root.querySelector('.modal.show'))document.body.classList.add('modal-open');});});
function saveAuth(result,remember){if(!result?.auth_data)throw Error('登录响应缺少身份令牌');clearAuth();(remember?localStorage:sessionStorage).setItem(storageKey,result.auth_data);}
async function captchaPayload(action,instance=captcha){if(authConfigError)throw Error(authConfigError);if(Number(config.is_captcha??config.is_recaptcha)!==1)return {};if(!instance)throw Error('人机验证尚未就绪,请刷新重试');return instance.payload(action);}
+17 -8
View File
@@ -1,3 +1,4 @@
import {isDesktopLayout} from './layout.mjs?v=0.12.19';
// FUC's original UI plugins, driven only by the XB theme's event bindings.
import {loadScript} from './captcha.mjs?v=0.12.6';
const base=new URL('./native/',import.meta.url).href;
@@ -23,7 +24,6 @@ export function paintInteractions(root){
const $=window.jQuery;if(!$)return;
scrollbar?.destroy();scrollbar=null;
const menu=root.querySelector('.main-menu-content');
if(menu)scrollbar=new window.PerfectScrollbar(menu,{suppressScrollX:true,wheelPropagation:false});
if(menu&&!root.querySelector('.sidenav-overlay')){const overlay=document.createElement('div');overlay.className='sidenav-overlay d-none';overlay.dataset.action='menu';root.append(overlay);}
window.Waves.attach(".btn:not([class*='btn-relief-']):not([class*='btn-gradient-']):not([class*='btn-outline-']):not([class*='btn-flat-'])",['waves-float','waves-light']);
window.Waves.attach("[class*='btn-outline-']");window.Waves.attach("[class*='btn-flat-']");
@@ -33,7 +33,7 @@ export function paintInteractions(root){
item.addEventListener('mouseleave',()=>item.classList.remove('hover'));
});
root.querySelectorAll('.main-menu,.navbar-header').forEach(menu=>{
menu.addEventListener('mouseenter',()=>{clearTimeout(hoverTimer);if(innerWidth>=1200)root.querySelectorAll('.main-menu,.navbar-header').forEach(n=>n.classList.add('expanded'));});
menu.addEventListener('mouseenter',()=>{clearTimeout(hoverTimer);if(isDesktopLayout())root.querySelectorAll('.main-menu,.navbar-header').forEach(n=>n.classList.add('expanded'));});
menu.addEventListener('mouseleave',()=>{
hoverTimer=setTimeout(()=>{
if(!document.body.classList.contains('menu-collapsed')||root.querySelector('.main-menu:hover,.navbar-header:hover'))return;
@@ -45,24 +45,33 @@ export function paintInteractions(root){
root.querySelectorAll('.modal').forEach(modal=>$(modal).on('hidden.bs.modal',()=>modal.setAttribute('aria-hidden','true')));
const rtl=document.documentElement.dataset.textdirection==='rtl';
const menuElement=root.querySelector('.main-menu');
if(menuElement){const gesture=new window.Hammer(menuElement);gesture.get('pan').set({direction:window.Hammer.DIRECTION_ALL,threshold:250});gesture.on(rtl?'panright':'panleft',()=>{if(innerWidth<1200&&document.body.classList.contains('menu-open'))toggleMenu(root);});gestures.push(gesture);}
if(menuElement){const gesture=new window.Hammer(menuElement);gesture.get('pan').set({direction:window.Hammer.DIRECTION_HORIZONTAL,threshold:250});gesture.on(rtl?'panright':'panleft',()=>{if(!isDesktopLayout()&&document.body.classList.contains('menu-open'))toggleMenu(root);});gestures.push(gesture);}
const edge=root.querySelector('.drag-target');
if(edge){const gesture=new window.Hammer(edge);gesture.on(rtl?'panleft':'panright',()=>{if(innerWidth<1200&&!document.body.classList.contains('menu-open'))toggleMenu(root);});gestures.push(gesture);}
if(edge){const gesture=new window.Hammer(edge);gesture.on(rtl?'panleft':'panright',()=>{if(!isDesktopLayout()&&!document.body.classList.contains('menu-open'))toggleMenu(root);});gestures.push(gesture);}
const backdrop=root.querySelector('.sidenav-overlay');
if(backdrop){const gesture=new window.Hammer(backdrop);gesture.on('tap',()=>{if(innerWidth<1200&&document.body.classList.contains('menu-open'))toggleMenu(root);});gestures.push(gesture);}
if(backdrop){const gesture=new window.Hammer(backdrop);gesture.on('tap',()=>{if(!isDesktopLayout()&&document.body.classList.contains('menu-open'))toggleMenu(root);});gestures.push(gesture);}
updateMenu(root);
}
export function updateMenu(root){
const body=document.body,expanded=body.classList.contains('menu-expanded')||body.classList.contains('menu-open');
root.querySelectorAll('.menu-toggle').forEach(n=>n.classList.toggle('is-active',expanded));
root.querySelectorAll('.modern-nav-toggle .toggle-icon').forEach(n=>{n.classList.toggle('icon-disc',expanded);n.classList.toggle('icon-circle',!expanded);});
const overlay=root.querySelector('.sidenav-overlay'),open=innerWidth<1200&&body.classList.contains('menu-open');
const desktop=isDesktopLayout();
const overlay=root.querySelector('.sidenav-overlay'),open=!desktop&&body.classList.contains('menu-open');
if(overlay){overlay.classList.toggle('d-block',open);overlay.classList.toggle('d-none',!open);}
body.style.overflow=open?'hidden':'';scrollbar?.update();
body.style.overflow=open?'hidden':'';
const menu=root.querySelector('.main-menu-content');
if(desktop&&menu){
scrollbar??=new window.PerfectScrollbar(menu,{suppressScrollX:true,wheelPropagation:false});
scrollbar.update();
}else if(scrollbar){
scrollbar.destroy();
scrollbar=null;
}
}
export function toggleMenu(root){
clearTimeout(menuTimer);document.body.classList.add('changing-menu');
if(innerWidth<1200){const open=document.body.classList.toggle('menu-open');document.body.classList.toggle('menu-hide',!open);}
if(!isDesktopLayout()){const open=document.body.classList.toggle('menu-open');document.body.classList.toggle('menu-hide',!open);}
else{document.body.classList.toggle('menu-collapsed');document.body.classList.toggle('menu-expanded');localStorage.setItem('fuc_menuToggle',document.body.classList.contains('menu-collapsed')?'close':'open');}
updateMenu(root);clearTimeout(resizeTimer);resizeTimer=setTimeout(()=>window.dispatchEvent(new window.Event('resize')),200);menuTimer=setTimeout(()=>{document.body.classList.remove('changing-menu');scrollbar?.update();},500);
}
+7
View File
@@ -0,0 +1,7 @@
// Match the CSS layout viewport. iOS innerWidth can shrink when the visual
// viewport is zoomed, even though the CSS breakpoint has not changed.
export function isDesktopLayout() {
return typeof window.matchMedia === 'function'
? window.matchMedia('(min-width: 1200px)').matches
: innerWidth >= 1200;
}
+6 -3
View File
@@ -1,8 +1,9 @@
import {isDesktopLayout} from './layout.mjs?v=0.12.19';
import {getPalette,applyPalette} from './palettes.mjs?v=0.12.6';
import {catalogGroups} from './catalog.mjs?v=0.12.6';
import {escape as e,money,bytes,date,safeUrl,soldOut,trafficSummary,canPurchase,orderAmount} from './core.mjs?v=0.12.13';
const base = new URL('./native/',import.meta.url).href;
const bridgeStyle = 'bridge.css?v=0.12.18';
const bridgeStyle = 'bridge.css?v=0.12.19';
let templates = {},sourceStyles={};
const styleReady=fetch(base+'styles.json?v=0.12.13').then(r=>r.json()).then(v=>sourceStyles=v);
export const nativeReady = Promise.all(['footer','header','index','home','login','register','forget','reset','plans','wallet','invite','profile','tickets','ticket','servers','notices','knowledge','article','faq','orders','purchase','checkout','walletlog','afflog'].map(async name=>{const version={footer:'0.12.17',header:'0.12.13',index:'0.12.13',plans:'0.12.13',checkout:'0.12.13',purchase:'0.12.13'}[name]||'ui-unify-1';const r=await fetch(`${base}${name}.html?v=${version}`);if(!r.ok)throw Error('原版模板加载失败');templates[name]=await r.text();})).then(()=>styleReady);
@@ -50,8 +51,8 @@ export function nativeMode(mode, page='') {
if(currentMode!==key+':'+getPalette())void prepareNativeMode(mode,page);
let dark=document.getElementById('native-dark');if(!dark){dark=document.createElement('link');dark.id='native-dark';dark.rel='stylesheet';dark.href=base+'theme/cool/assets/css/theme/dark-layout.css';document.head.append(dark);}dark.disabled=mode!=='user'||document.documentElement.dataset.color!=='dark';
let bridge=document.getElementById('native-bridge');if(!bridge){bridge=document.createElement('link');bridge.id='native-bridge';bridge.rel='stylesheet';bridge.href=base+bridgeStyle;document.head.append(bridge);}
document.body.className=mode==='home'?'native-public':mode==='auth'?'vertical-layout vertical-menu-modern 1-column navbar-floating footer-static bg-full-screen-image blank-page':`vertical-layout ${innerWidth>=1200?'vertical-menu-modern menu-expanded':'vertical-overlay-menu'} navbar-floating footer-static ${document.documentElement.dataset.color==='dark'?'dark-layout':''}`;
if(mode==='user'&&innerWidth>=1200&&localStorage.getItem('fuc_menuToggle')==='close'){document.body.classList.remove('menu-expanded');document.body.classList.add('menu-collapsed');}document.body.dataset.nativeMode=mode;document.body.dataset.menu=innerWidth>=1200?'vertical-menu-modern':'vertical-overlay-menu';document.body.classList.add(window.Pace?.running?'pace-running':'pace-done');syncNativeMenu(document);
document.body.className=mode==='home'?'native-public':mode==='auth'?'vertical-layout vertical-menu-modern 1-column navbar-floating footer-static bg-full-screen-image blank-page':`vertical-layout ${isDesktopLayout()?'vertical-menu-modern menu-expanded':'vertical-overlay-menu'} navbar-floating footer-static ${document.documentElement.dataset.color==='dark'?'dark-layout':''}`;
if(mode==='user'&&isDesktopLayout()&&localStorage.getItem('fuc_menuToggle')==='close'){document.body.classList.remove('menu-expanded');document.body.classList.add('menu-collapsed');}document.body.dataset.nativeMode=mode;document.body.dataset.menu=isDesktopLayout()?'vertical-menu-modern':'vertical-overlay-menu';document.body.classList.add(window.Pace?.running?'pace-running':'pace-done');syncNativeMenu(document);
}
const routes={'/':'#/home','/user':'#/dashboard','/user/':'#/dashboard','/user/shop':'#/plans','/user/announcement':'#/notices','/user/code':'#/wallet','/user/plan':'#/orders','/user/invite':'#/invite','/user/profile':'#/profile','/user/ticket':'#/tickets','/user/node':'#/servers','/user/faq/1':'#/faq','/auth/login':'#/login','/auth/register':'#/register','/password/reset':'#/forget'};
@@ -143,6 +144,8 @@ export function nativeHome(plans,brand,loggedIn=false) {
}
export function nativeLogin(brand,preview) {
const host=document.createElement('div');host.innerHTML=sanitize(templates.login).replace(/福云/g,e(brand));
// Do not open the touch keyboard or trigger Safari's focus zoom on route entry.
if(window.matchMedia?.('(pointer: coarse)').matches)host.querySelectorAll('[autofocus]').forEach(n=>n.removeAttribute('autofocus'));
const form=host.querySelector('#login_form');if(form){form.dataset.form='login';form.querySelector('[name=passwd]')?.setAttribute('name','password');form.querySelector('[id="2fa-form"]')?.remove();form.querySelectorAll('[name="remember-me"],[name=remember_me]').forEach(n=>n.name='remember');const submit=form.querySelector('[type=submit]')||form.querySelector('button');if(submit){submit.type='submit';submit.removeAttribute('onclick');}const email=form.querySelector('[name=email]');if(email){email.type='email';email.required=true;}const pass=form.querySelector('[name=password]');if(pass)pass.required=true;}
return host.innerHTML;
}
+57
View File
@@ -23,6 +23,19 @@ body[data-native-mode=user] .main-menu .navigation-main {
padding-block-start: var(--fuc-menu-shadow-bleed);
}
@media (max-width: 1199.98px) {
body[data-native-mode=user] .main-menu .main-menu-content {
overflow-x: hidden;
overflow-y: auto;
overscroll-behavior-y: contain;
scrollbar-width: none;
}
body[data-native-mode=user] .main-menu .main-menu-content::-webkit-scrollbar {
display: none;
}
}
[data-dashboard-notice] :is(.card-header h4, .card-content :not(i, svg, svg *)) {
font-weight: 400 !important;
}
@@ -85,9 +98,53 @@ body[data-native-mode=user] .main-menu .navigation-main {
}
}
@media (max-width: 575.98px) {
html:has(> body[data-native-mode=user][data-native-page=dashboard]) {
overflow-x: clip;
}
#dashboard-analytics .tab-pane .card-spacer-x > .d-flex {
flex-wrap: wrap;
gap: .65rem;
}
#dashboard-analytics .tab-pane .card-spacer-x > .d-flex > .d-flex {
min-width: 0;
max-width: 100%;
overflow-wrap: anywhere;
}
#dashboard-analytics .tab-pane .card-spacer-x > .d-flex > .d-flex:last-child {
flex-wrap: wrap;
row-gap: .5rem;
}
#dashboard-analytics .card-stats .row > .col {
min-width: 0;
overflow-wrap: anywhere;
}
#dashboard-analytics :is(.btn-sub, .btn-shadowrocket) {
max-width: 100%;
white-space: normal;
}
#dashboard-analytics #donut-chart {
overflow: hidden;
}
}
/* Read-only unsupported fields retain the source input appearance. */
body[data-native-mode=auth] .form-control[readonly]{background-color:#fff;opacity:1}
/* iOS zooms focused controls below 16px and keeps that visual zoom after SPA
navigation. Size the controls themselves; never disable the user's zoom. */
@media (max-width: 1199.98px), (pointer: coarse) {
body[data-native-mode] :is(input:not([type=checkbox]):not([type=radio]), textarea, select) {
font-size: max(16px, 1rem);
}
}
/* Enlarge the login mark without shifting the form below it. */
.auth-wrapper .card-body:has(> #login_form) .fuc-auth-mark {
transform: scale(1.1);
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "Fuc",
"description": "直接复用新版FUC原始用户模板、样式、图标及素材,接入XB接口;XB管理员后台保持原样。",
"version": "0.12.18",
"version": "0.12.19",
"images": "",
"configs": [
{
+1 -1
View File
@@ -57,7 +57,7 @@
];
@endphp
<script>window.fucSettings = @json($fucSettings);</script>
<script type="module" src="/theme/{{ $theme }}/assets/app.mjs?v=0.12.18"></script>
<script type="module" src="/theme/{{ $theme }}/assets/app.mjs?v=0.12.19"></script>
</body>
</html>