Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
ujia
/
uj-store
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 12b2021a
authored
Oct 12, 2026
by
liimin
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix(Login): 修复自动填充输入框淡色背景并调整品牌文案
1 parent
e87fc91a
Pipeline
#330
for
12b2021a
failed
in 0 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
12 deletions
.workbuddy/memory/2026-10-12.md
src/pages/Login/index.tsx
src/pages/Profile/index.tsx
src/theme/design.css
src/utils/datetime.ts
src/utils/index.ts
.workbuddy/memory/2026-10-12.md
View file @
12b2021
...
...
@@ -4,3 +4,12 @@
-
LoginClock.tsx:原 today/base 仅挂载时算一次、tick 靠 setInterval 累加。新增 document.visibilitychange 监听,页面重新可见时 setToday(new Date()) + setBase(nowTotalSeconds()) + setTick(0) 重新锚定到当前时间;base/today 改为可更新 state。
-
LoginAside.tsx:now 改为可更新 state;新增可见性监听(切回即 setNow(new Date()) 重算 greet/dateText)+ 60s 定时(防前台常开跨午夜变旧)。
-
tsc --noEmit 通过(EXIT=0)。
## 登录框 autofill 背景色修复(09:07)
-
问题:浏览器记住密码→自动填充后,UInput/UInput.Password 输入框被染成默认淡色(淡蓝/淡黄),与白色登录卡片(.uj-login-card 背景 #fff)不搭。
-
根因:autofill 背景是浏览器内联强制画上的,普通 background 改不掉。
-
修法(src/theme/design.css,紧接 .uj-login-card 后新增规则):对
`.uj-login-card input:-webkit-autofill(:hover/:focus/:active)`
用
`box-shadow: 0 0 0 1000px #fff inset`
+
`transition: background-color 9999s`
覆盖为白;
`-webkit-text-fill-color`
/
`caret-color`
保持深色保证可读。纯 CSS,无 TS 变动。
-
09:12 补充:聚焦(focus)时淡色背景重现。根因:新版 Chrome 在 input 聚焦时会把 autofill 背景重放一遍,且此时
`:-webkit-autofill`
伪类不稳定匹配(背景改由 UA 内联样式绘制),仅靠伪类盖不住。强化:直接对
`.uj-login-card`
内
`.ant-input`
/
`.ant-input-affix-wrapper`
的所有态(含 focus/hover/active/focused)强制
`background-color:#fff !important`
压过浏览器与 antd 背景,autofill 伪类仅作 box-shadow 兜底。
-
09:18 修正:用户确认淡蓝/淡黄仍未消除。根因非伪类/聚焦,而是特异性不足——antd 6 CSS-in-JS 把 .ant-input 的 background 注入到 head 末尾(晚于 design.css 加载),原选择器被 antd 规则盖过。修正:选择器重复 class 抬特异性(.ant-input.ant-input 等)+ 补全 antd6 变体(outlined/password/focused),background 改简写 #fff !important;autofill 伪类加 background:#fff !important + inset 阴影 + 9999s 过渡。
-
09:29 最终纠正(用户指出"第一版方向对、后续改崩了"):09:12/09:18 两版
**方向全错**
——autofill 淡色只能用
`box-shadow: 0 0 0 1000px #fff inset`
盖,改
`background`
无效,所以越改越没效果。聚焦态重现的真正根因是 Chrome 聚焦时用标准
`:autofill`
(无前缀)伪类,第一版只盖了
`:-webkit-autofill`
,漏了
`:autofill`
。最终方案:删除所有 background 强制规则,回归 box-shadow inset #fff 方案,并补
`input:autofill(:hover/:focus/:active)`
覆盖聚焦态。纯 CSS,无 TS 变动。
src/pages/Login/index.tsx
View file @
12b2021
...
...
@@ -11,7 +11,7 @@ export default function Login() {
<LoginForm />
</div>
<UText type="secondary" style={{ marginTop: 24, fontSize: 12 }}>
© 2026 优加门店上架系统 ·
企业级
门店治理平台
© 2026 优加门店上架系统 ·
一站式
门店治理平台
</UText>
</main>
</div>
...
...
src/pages/Profile/index.tsx
View file @
12b2021
...
...
@@ -9,6 +9,7 @@ import { UCard, UForm, UInput, UButton, UAlert, UText, Skeleton } from '@uj/ui';
import { auth, type UserInfo } from '@/api';
import { useAppStore } from '@/store/useAppStore';
import { useAccess } from '@/access';
import { formatDateTime } from '@/utils';
interface PasswordForm {
oldPassword: string;
...
...
@@ -16,17 +17,6 @@ interface PasswordForm {
confirmPassword: string;
}
/** 后端 date-time 字符串 → yyyy-MM-dd hh:mm:ss(本地时区);空值或解析失败回退原值 */
function formatDateTime(input?: string | null): string {
if (!input) return '—';
const d = new Date(input);
if (Number.isNaN(d.getTime())) return input;
const p = (n: number) => String(n).padStart(2, '0');
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(
d.getHours(),
)}:${p(d.getMinutes())}:${p(d.getSeconds())}`;
}
export default function Profile() {
const navigate = useNavigate();
const { message } = App.useApp();
...
...
src/theme/design.css
View file @
12b2021
...
...
@@ -396,6 +396,26 @@
box-shadow
:
var
(
--uj-shadow-pop
);
border
:
1px
solid
#eef1f6
;
}
/* 浏览器「记住密码」自动填充后,输入框出现默认淡色背景(淡蓝/淡黄),与白色卡片不搭。
autofill 的淡色必须用 inset 阴影盖——普通 background 改不掉它。
Chrome 聚焦态改用标准 :autofill(无前缀)伪类,故 :-webkit-autofill 与 :autofill 都要覆盖,
否则一聚焦淡色就重现。文字/光标保持深色,保证账号密码可读。 */
.uj-login-card
input
:-webkit-autofill
,
.uj-login-card
input
:-webkit-autofill:hover
,
.uj-login-card
input
:-webkit-autofill:focus
,
.uj-login-card
input
:-webkit-autofill:active
,
.uj-login-card
input
:autofill
,
.uj-login-card
input
:autofill:hover
,
.uj-login-card
input
:autofill:focus
,
.uj-login-card
input
:autofill:active
{
-webkit-text-fill-color
:
#1f2d4d
!important
;
caret-color
:
#1f2d4d
!important
;
-webkit-box-shadow
:
0
0
0
1000px
#fff
inset
!important
;
box-shadow
:
0
0
0
1000px
#fff
inset
!important
;
transition
:
background-color
9999s
ease-in-out
0s
,
color
9999s
ease-in-out
0s
;
}
@media
(
max-width
:
880px
)
{
.uj-login-aside
{
display
:
none
;
...
...
src/utils/datetime.ts
0 → 100644
View file @
12b2021
/**
* 后端 date-time 字符串(如 ISO 8601)→ `yyyy-MM-dd hh:mm:ss`(本地时区)。
* 空值返回「—」;解析失败(非法串)则原样回退,避免吞掉原始值。
*/
export
function
formatDateTime
(
input
?:
string
|
null
):
string
{
if
(
!
input
)
return
'—'
;
const
d
=
new
Date
(
input
);
if
(
Number
.
isNaN
(
d
.
getTime
()))
return
input
;
const
p
=
(
n
:
number
)
=>
String
(
n
).
padStart
(
2
,
'0'
);
return
`
${
d
.
getFullYear
()}
-
${
p
(
d
.
getMonth
()
+
1
)}
-
${
p
(
d
.
getDate
())}
${
p
(
d
.
getHours
(),
)}
:
${
p
(
d
.
getMinutes
())}
:
${
p
(
d
.
getSeconds
())}
`
;
}
src/utils/index.ts
0 → 100644
View file @
12b2021
export
*
from
'./datetime'
;
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment