Files
SimpleNav/assets/css/admin.css
T
laoyang 92eb9d90be 后台上传站点图标:首页品牌图 + favicon + PWA 图标一起换
需求:后台新增设置,允许管理员上传自己的图标;上传后首页品牌图标与浏览器
标签页 favicon(以及「添加到手机主屏」图标)一起换成它。

要点:
- 一张上传图服务端居中裁剪成正方形,生成 16/32/48/64/180/192/512 +
  maskable 192/512 整套尺寸,并手工拼装多帧 favicon.ico。
- 单一来源 site_icon_url() 统一取址;site_icon_head() 被首页/登录页/后台
  三处共用;PWA manifest 改由 manifest.php 动态输出、maskable 也跟随 ——
  三处防线共同杜绝「首页换了、标签页还是旧的」这类半生效。
- 目录可写则落静态文件(最快);不可写的保守环境整套压进设置、由
  site-icon.php 按需输出,功能不因权限限制整块不可用。
- 与「网站列表里每个网站自己的图标」是两个维度:目录与设置键都分开,
  清理时互不误伤。

顺手修掉两个真问题:
- login.php / admin/_auth.php 各留了一行写死的 favicon,与新的
  site_icon_head() 并存 → head 里两条 rel="icon",是「上传了却没换」的
  温床。已删掉写死那两行。
- 自定义 favicon.ico 原先只塞 16+32 两帧,而内置是 16/32/48/64 四帧 ——
  换图标反而退步。已补齐 icon-64 并统一为 4 帧。
- setting() 的请求内缓存导致「同请求写后再读」拿到旧值(真实坑):
  settings_cache() 支持强制重载 + settings_reload(),写入后立即失效。

验证:单测 44/44(含只读目录动态回退)、HTTP 56/56、e2e 174/0、
反向验证 5 变体全部被抓住(含「写死残留」与「ico 只塞两帧」两个新哨兵)、
真机几何 360/390/768/1440 无溢出、线上直连桌面+移动端几何全绿、
线上诊断页走通「上传→前台全换→复原」。
2026-09-28 22:28:23 +08:00

151 lines
7.5 KiB
CSS

/* 简航 SimpleNav —— 后台样式 */
:root {
--wrap: 1140px;
--gutter: 16px;
--pad-x: max(var(--gutter), calc((100% - var(--wrap)) / 2));
}
body.admin { background: #eef0f3; color: #333; font-size: 14px; }
.topbar {
display: flex; align-items: center; gap: 16px; padding: 0 var(--pad-x); height: 56px;
background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.06); position: sticky; top: 0; z-index: 50;
}
.topbar .brand { font-size: 17px; font-weight: 700; }
.topbar .brand a { color: #2F6BF7; }
.topbar .brand span { color: #999; font-weight: 400; font-size: 13px; margin-left: 6px; }
.topnav { display: flex; gap: 4px; flex: 1; }
.topnav a { padding: 8px 14px; border-radius: 8px; color: #555; }
.topnav a:hover { background: #f2f4f7; }
.topnav a.active { background: #2F6BF7; color: #fff; }
.topright { display: flex; align-items: center; gap: 10px; color: #666; }
.wrap { padding: 0 var(--pad-x); margin: 20px 0 60px; }
.card { background: #fff; border-radius: 12px; padding: 18px; margin-bottom: 18px; box-shadow: 0 2px 10px rgba(0,0,0,.04); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-head h2 { font-size: 16px; margin: 0; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.grid-form label { display: flex; flex-direction: column; font-size: 13px; color: #555; gap: 5px; }
.grid-form label.chk { flex-direction: row; align-items: center; gap: 6px; }
.grid-form .span2 { grid-column: 1 / -1; }
.grid-form .row { display: flex; gap: 8px; }
.grid-form .row input { flex: 1; }
.grid-form input[type=text], .grid-form input[type=password], .grid-form select {
height: 38px; padding: 0 10px; border: 1px solid #d9dde3; border-radius: 8px; font-size: 14px; width: 100%;
}
.grid-form input:focus, .grid-form select:focus { outline: none; border-color: #2F6BF7; }
.form-actions { display: flex; align-items: center; gap: 10px; }
.hint { color: #999; font-size: 12px; }
.btn { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 16px; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; }
.btn.primary { background: #2F6BF7; color: #fff; }
.btn.primary:hover { background: #2456cc; }
.btn.ghost { background: #f2f4f7; color: #444; }
.btn.ghost:hover { background: #e6e9ee; }
.btn.block { width: 100%; justify-content: center; }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.alert.ok { background: #e8f6ee; color: #1a7f45; }
.alert.err { background: #fdecec; color: #c0392b; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
/* 窄屏下表格自己横向滚动,绝不撑破页面 */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl th, .tbl td { padding: 9px 8px; text-align: left; border-bottom: 1px solid #f0f1f3; vertical-align: middle; }
.tbl th { color: #888; font-weight: 500; }
.tbl tr:hover td { background: #fafbfc; }
.tbl .muted { color: #999; }
.tbl .ell { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl .nowrap { white-space: nowrap; }
.mini { width: 26px; height: 26px; border-radius: 6px; object-fit: contain; background: #f4f5f7; }
.mini.letter { display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 13px; }
.inline { display: inline; }
.ico-btn {
display: inline-flex; align-items: center; justify-content: center;
border: none; background: #f2f4f7; width: 28px; height: 28px; border-radius: 6px;
cursor: pointer; color: #555; margin: 0 1px; padding: 0; transition: background .15s, color .15s;
}
.ico-btn:hover { background: #e6e9ee; }
.ico-btn:disabled { opacity: .5; cursor: default; }
.ico-btn.danger { color: #c0392b; }
.ico-btn.danger:hover { background: #fdecec; }
.ok-dot { color: #1a7f45; font-size: 12px; }
/* 显示 / 隐藏 切换按钮:绿=显示中,灰=已隐藏 */
.ico-btn.toggle { color: #9aa3af; }
.ico-btn.toggle:hover { background: #e6e9ee; color: #555; }
.ico-btn.toggle.on { color: #1a7f45; background: #e8f6ee; }
.ico-btn.toggle.on:hover { background: #d6efe1; }
.ico-btn.toggle svg { display: block; }
/* 状态胶囊 */
.state {
display: inline-block; min-width: 52px; padding: 2px 8px; border-radius: 10px;
font-size: 12px; line-height: 18px; text-align: center; vertical-align: middle;
}
.state.on { background: #e8f6ee; color: #1a7f45; }
.state.off { background: #f1f3f5; color: #98a2b3; }
/* 「自定义图标」标记 */
.badge {
display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 8px;
background: #eef3ff; color: #2F6BF7; font-size: 11px; line-height: 16px; vertical-align: middle;
}
/* 图数字段 */
.icon-field {
display: flex; gap: 16px; align-items: flex-start; padding: 12px;
border: 1px dashed #d9dde3; border-radius: 10px; background: #fafbfc;
}
.icon-field-preview { flex: 0 0 72px; }
.icon-preview {
display: flex; align-items: center; justify-content: center; width: 72px; height: 72px;
border-radius: 14px; background: #fff; border: 1px solid #e6e9ee; overflow: hidden;
}
.icon-preview img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.icon-preview .ph { color: #bbb; font-size: 12px; }
/* 站点整体图标:比格子里的图标大一号,看得清 */
.icon-preview.big { width: 96px; height: 96px; border-radius: 20px; }
.icon-field-preview.big { flex: 0 0 96px; }
.pill {
display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px;
font-weight: 400; background: #eef2f7; color: #667085; vertical-align: 1px;
}
.pill[data-site-icon="custom"] { background: #e8f1fe; color: #2456cc; }
.icon-field-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.icon-field-title { font-size: 13px; color: #555; font-weight: 600; }
.icon-field-body input[type=text] {
height: 38px; padding: 0 10px; border: 1px solid #d9dde3; border-radius: 8px; font-size: 14px; width: 100%;
}
.icon-field-body input[type=text]:focus { outline: none; border-color: #2F6BF7; }
.icon-row2 { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.icon-row2 .chk { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; font-size: 13px; color: #555; }
.icon-row2 input[type=file] {
font-size: 13px; color: #666; background: #fff; border: 1px solid #d9dde3;
border-radius: 8px; padding: 6px 8px; max-width: 300px;
}
.icon-field .hint { line-height: 1.75; margin: 0; }
.icon-field .hint b { color: #2F6BF7; }
/* 已隐藏的行稍作弱化 */
.tbl tr.row-off td:first-child, .tbl tr.row-off td:nth-child(2) { color: #98a2b3; }
/* 登录页 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 340px; background: #fff; border-radius: 14px; padding: 30px 26px; box-shadow: 0 10px 30px rgba(0,0,0,.08); text-align: center; }
.login-card h1 { font-size: 20px; margin: 8px 0 2px; }
.login-card .sub { color: #999; font-size: 13px; margin: 0 0 18px; }
.login-card input { width: 100%; height: 42px; margin-bottom: 12px; padding: 0 12px; border: 1px solid #d9dde3; border-radius: 8px; font-size: 14px; }
.login-card input:focus { outline: none; border-color: #2F6BF7; }
.login-card .btn { height: 42px; }
.login-logo { width: 56px; height: 56px; }
@media (max-width: 720px) {
.grid-form { grid-template-columns: 1fr; }
.topbar { flex-wrap: wrap; height: auto; padding: 10px var(--pad-x); }
.tbl { min-width: 620px; }
.tbl .ell { max-width: 120px; }
.icon-field { flex-direction: column; }
.icon-field-preview { flex: 0 0 auto; }
.icon-row2 input[type=file] { max-width: 100%; }
}