fix(profile): serve unified content width and accept full admin range

This commit is contained in:
2026-09-23 13:23:04 +08:00
parent c315297d7f
commit 10c63e02d5
5 changed files with 38 additions and 4 deletions
+9
View File
@@ -3468,6 +3468,15 @@ html.dark body.has-scrolled .site-nav--glass {
max-width: var(--container);
}
/* Profile routes use the exact value emitted from the admin content-width setting.
* Keep the shell contract here so the private center and public profile cannot
* drift through route-specific or legacy container rules. */
.site-main.content-shell.aksrt-profile,
.site-main.content-shell.aksrt-user-home {
max-width: var(--content-max, var(--container, 1440px));
box-sizing: border-box;
}
@media (min-width: 768px) {
.content-shell {
padding: 40px 24px 56px;
+1 -1
View File
File diff suppressed because one or more lines are too long
+3 -1
View File
@@ -141,7 +141,9 @@ class GlobalSchema {
['key' => 'close_backdrop', 'label' => '关闭毛玻璃效果', 'type' => 'switch', 'default' => false],
]],
['key' => 'layout', 'title' => '布局设置', 'fields' => [
['key' => 'container_max_width', 'label' => '内容最大宽度', 'type' => 'number', 'default' => 1200, 'min' => 0, 'max' => 1600],
// 0(全宽)与 1200–2200 与设置页下拉选项、Settings::container_max_width() 归一化区间一致;
// 上限低于 UI 可选项会让后台保存被校验拒绝,页面宽度卡在旧值。
['key' => 'container_max_width', 'label' => '内容最大宽度', 'type' => 'number', 'default' => 1200, 'min' => 0, 'max' => 2200],
['key' => 'sidebar_enabled', 'label' => '开启侧边栏', 'type' => 'switch', 'default' => true],
['key' => 'sidebar_position', 'label' => '侧边栏位置', 'type' => 'radio', 'default' => 'right', 'options' => [
['label' => '左侧', 'value' => 'left'],
-2
View File
@@ -23,7 +23,6 @@ class InlineStyleBuilder {
$sidebar_cfg = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_sidebar_config() : ['width' => 311, 'enabled' => true, 'position' => 'right'];
$content_width = $container_max === 0 ? '100%' : $container_max . 'px';
$content_no_sidebar_max = $container_max === 0 ? '100%' : max(860, $container_max - 220) . 'px';
$container_wide = $container_max === 0 ? '100%' : max(1280, $container_max + 160) . 'px';
$radius_sm = max(0, $border_radius - 2);
$radius_lg = $border_radius + 4;
@@ -47,7 +46,6 @@ class InlineStyleBuilder {
$layout_vars = [
'--content-max' => $content_width,
'--content-no-sidebar-max' => $content_no_sidebar_max,
'--container' => $content_width,
'--container-wide' => $container_wide,
'--mian-max-width' => $content_width, // legacy typo token
@@ -420,6 +420,7 @@ test('profile routes load versioned leaf styles and keep dialogs hidden initiall
const userHomeCss = read('assets/css/routes/user-home.css');
const profileLayoutCss = read('assets/css/routes/profile/layout.css');
const frontendLayoutCss = read('assets/css/frontend/layout.css');
const publicBundleCss = read('assets/css/build/public.css');
const userCenterShellCss = read('assets/css/routes/user-center/shell.css');
const profileModalsCss = read('assets/css/routes/profile/modals.css');
const userCenterCreditsCss = read('assets/css/routes/user-center/credits.css');
@@ -453,6 +454,9 @@ test('profile routes load versioned leaf styles and keep dialogs hidden initiall
assert.match(panelFavorites, /array_merge\(\$user_home_render_config, \['wrapper_class' => 'aksrt-user-home__post-list'\]\), \$favorites_query\)/);
assert.doesNotMatch(panelFavorites, /profile-list-item|\$_GET|add_query_arg/);
assert.match(frontendLayoutCss, /\.site-main\.content-shell\.aksrt-profile,[\s\S]*?\.site-main\.content-shell\.aksrt-user-home\s*\{[\s\S]*?max-width:\s*var\(--content-max, var\(--container, 1440px\)\)/);
// The front end enqueues build/public.min.css, not the frontend/ sources, so a
// source-only edit never reaches the page. The bundle must carry the contract.
assert.match(publicBundleCss, /\.site-main\.content-shell\.aksrt-profile,[\s\S]*?\.site-main\.content-shell\.aksrt-user-home\s*\{[\s\S]*?max-width:\s*var\(--content-max, var\(--container, 1440px\)\)/);
assert.doesNotMatch(profileLayoutCss, /\.aksrt-profile\.content-shell\s*,[\s\S]*?max-width:\s*var\(--container/);
assert.doesNotMatch(userCenterShellCss, /\.aksrt-user-center \.content-shell\s*,[\s\S]*?max-width:\s*var\(--container/);
assert.match(profileLayoutCss, /\.aksrt-cover-menu__panel\[hidden\]\s*\{\s*display:\s*none\s*!important;\s*\}/);
@@ -661,3 +665,24 @@ test('resource meta CSS uses one canonical direct stylesheet', () => {
);
}
});
test('content max width is one contract from admin option to runtime var', () => {
const globalSchema = read('src/Admin/Schema/GlobalSchema.php');
const layoutSchema = read('assets/admin/src/schema/sections/global/layout.js');
const themeSearch = read('src/Settings/ThemeSearch.php');
const builder = read('src/Frontend/InlineStyleBuilder.php');
// Every width the settings UI offers must pass REST validation, or the save is
// rejected and the rendered width silently keeps the previous value.
const pxOptions = [...layoutSchema.matchAll(/value: (\d+) \}/g)].map((match) => Number(match[1]));
assert.ok(pxOptions.includes(1200));
assert.ok(pxOptions.includes(2200));
const schemaMax = Number(globalSchema.match(/'container_max_width'[\s\S]*?'max' => (\d+)/)[1]);
assert.equal(schemaMax, Math.max(...pxOptions));
assert.match(globalSchema.match(/'container_max_width'[^\n]*/)[0], /'min' => 0/);
assert.match(themeSearch, /max\(1200, min\(2200, \$width\)\)/);
assert.match(builder, /'--content-max'\s*=> \$content_width/);
// The unused no-sidebar width token was removed; no runtime var may revive it.
assert.doesNotMatch(builder, /content-no-sidebar-max/);
});