feat: 新增主题色功能,支持用户自定义界面主色调
新增主题色选择器组件,支持青、蓝、靛蓝、紫、玫红、橙六种颜色选项 前后端适配主题色存储与同步,用户偏好新增 color 字段 登录页与个人设置界面适配主题色展示,样式表按主题色拆分多套配色 完善相关国际化文案与测试用例,优化登录页面布局适配主题色切换main
parent
cb3f2ee10e
commit
71458e2c32
33
README.md
33
README.md
|
|
@ -3274,7 +3274,9 @@ key 等于每换一张单整页重挂,那些 `watch` 全成了死代码,浏
|
|||
- 复用层:`components/common/*`(`DataTable`、`TablePageLayout`、`BaseDialog`、
|
||||
`ConfirmDialog`、`Pagination`、`Select`、`StatCard`、`DateRangePicker`、`SearchInput`)、
|
||||
`style.css` 中的 `.btn/.input/.card/.badge/.tabs/.switch/.page-header/.stat-*`、
|
||||
teal 主色的 Tailwind 主题、暗色模式、`useTableLoader` 分页与请求取消、Pinia store 骨架
|
||||
主色可换的 Tailwind 主题(默认 teal 青,色板是 `style.css` 里那几组 `--primary-*`,
|
||||
换档只换 `<html data-accent>`,见「主题色」那一节)、暗色模式、
|
||||
`useTableLoader` 分页与请求取消、Pinia store 骨架
|
||||
- OA 新增:`components/oa/FormRenderer.vue`(按表单定义渲染 12 种字段,`design` 模式
|
||||
额外画出卡片化的字段、空位斜纹与「第 N 行 · 第 i/2 列」角标,审批页用的就是同一个组件)、
|
||||
`utils/formLayout.ts`(字段落位算法:行/列/占几格、被挤到下一行留出的空位、字段名去重、设计校验)、
|
||||
|
|
@ -3355,7 +3357,12 @@ key 等于每换一张单整页重挂,那些 `watch` 全成了死代码,浏
|
|||
一句人话 + 送回门户,等待态是 `index.html` 里那幅进站骨架,320ms 之内不出现);
|
||||
`views/auth/LoginView.vue`(Hub 开启时显示 Hub
|
||||
下发的验证码、登录失败自动换一张;`hub.sso_only` 时不渲染账号密码,只留「前往统一门户」,
|
||||
`?local=1` 保留应急本地口令入口);`utils/portal.ts` 是唯一的「整页跳去统一门户」出口,
|
||||
`?local=1` 保留应急本地口令入口。版面抄统一门户那边 EDRS 的登录页:宽屏左边一整栏讲系统、
|
||||
右边一块半透明磨砂只放登录,底下「其他登录方式」那一排圆钮就是回门户的那条第三方入口
|
||||
(点的还是原来那颗「前往统一门户」走的那条路:先让后端写 state,再整页跳),
|
||||
样式集中在 `style.css` 的 `.login-*` 那一组,底色跟着主题色走;
|
||||
`components/layout/AuthLayout.vue` 是那层壳子,右上角两颗是语言与深浅);
|
||||
`utils/portal.ts` 是唯一的「整页跳去统一门户」出口,
|
||||
`utils/sessionIdle.ts` 挂空闲心跳与本地超时计时(后端没配 `OA_SESSION_IDLE_MINUTES` 时什么都不做);
|
||||
`components/oa/HubPermissionPanel.vue`(权限角色页顶部:自己在 Hub 上的角色/权限码/数据范围、
|
||||
与本地权限目录对账 + 一键登记、按账号代查;`hub_perm_enabled` 关着时整块不渲染)
|
||||
|
|
@ -3376,6 +3383,27 @@ key 等于每换一张单整页重挂,那些 `watch` 全成了死代码,浏
|
|||
`t('a.b')`,逐条走两棵树,任何一环取不到就报出「文件 + key」。它自己不发明写法,
|
||||
动态拼出来的 key(``t(`${x}.title`)``)归各自那道闸门看住
|
||||
|
||||
- 主题色(整体颜色):一整套界面的主色只有 `style.css` 里那十一组 `--primary-*`(RGB 三元组),
|
||||
`tailwind.config.js` 把 `primary-*` 全部指到这些变量上并交出 `<alpha-value>`,
|
||||
所以 `bg-primary-500/30` 这类带透明度的写法照旧生效,换一处就换整套。用哪一套由
|
||||
`<html data-accent="…">` 决定,色板本身只住在 CSS 里(六套:青(默认)/ 蓝 / 靛蓝 / 紫 / 玫红 / 橙),
|
||||
JS 只带一个 id:`utils/themeColor.ts` 认档、写属性、顺手把 `<meta name="theme-color">` 对上;
|
||||
`index.html` 那段防闪脚本在画第一笔之前就把属性写上(认不出的值不写,落回默认青),
|
||||
因此不会出现"先青后蓝闪一下"。存法与深色档、字号同一班车——本地 `oa.accent` 是缓存,
|
||||
`users.preferences.color` 才是权威,登录后由 `adoptPreferences` 接回来,
|
||||
换设备、清缓存、从企微换入口进来都还是自己挑的那一版;后端只认
|
||||
`schemas.ACCENT_COLORS` 那六个值,认不出的整档丢掉。入口三处共用
|
||||
`components/common/AccentColorPicker.vue`(顶栏「外观」、桌面「个人设置」、手机「我的」)。
|
||||
CSS 变量到不了的两处也问同一本账:统计页画在 canvas 上的线与柱子、页签上那枚内置 "OA" 图标,
|
||||
由 `accentColor(600)` / `accentRgba(600, .18)` 现问浏览器「当前这一档的 `--primary-600`
|
||||
算出来是哪三个数」,换档时上层那些 `computed` 跟着重算,图会当场改颜色;流程、日程、
|
||||
未知后缀文件在**没配色**时的兜底同样走这条路(配过的颜色是数据,不跟着换),
|
||||
日程接口也不再替空颜色填上旧的 `#0d9488`。只有 `DEFAULT_ACCENT_RGB` 一份是抄下来的,
|
||||
用在样式表还没下载的那一瞬,`themeColor.spec.ts` 会把 `style.css` 抠出来逐档比对,抄漏了当场红。
|
||||
**加一档颜色要在两处对齐**:`style.css` 里补一份同名色板 + `utils/themeColor.ts` 的
|
||||
`ACCENT_OPTIONS` 加一条(含两份 locale 里那两个名字),只动 JS 那一头会静默退回默认青,
|
||||
`utils/themeColor.spec.ts` 钉的就是这层对应关系
|
||||
|
||||
## 自检
|
||||
|
||||
仓库里不留测试代码:`backend/tests/` 那 42 套验收脚本、`backend/scripts/run_all.py`、
|
||||
|
|
@ -3425,6 +3453,7 @@ pnpm typecheck # vue-tsc --noEmit
|
|||
pnpm lint:check # eslint(不带 --fix)
|
||||
pnpm build # vue-tsc -b && vite build
|
||||
pnpm vitest run src/utils/browserCompatGuard.spec.ts # 浏览器口径闸门:带出值/展示这条链不许用回没有兜底的写法
|
||||
pnpm vitest run src/utils/themeColor.spec.ts src/components/common/AccentColorPicker.spec.ts # 动过主题色(style.css 那几组 --primary-* / utils/themeColor / 那一排圆点):六档与色板一一对应、点一档就换 <html data-accent> 并留在本地、认不出的值不换画面也不写盘
|
||||
pnpm vitest run src/utils/branding.spec.ts # 动过主色 / 左上角那块 "OA" 磁贴 / index.html 里那两句图标链接:浏览器页签上那一枚必须还是同一张图(换主色要重跑 frontend/scripts/gen-icons.py)
|
||||
pnpm vitest run src/stores/tabs.spec.ts src/components/layout/AppLayout.tabs.spec.ts src/composables/useTableLoader.persist.spec.ts src/views/oa/MonitorView.persist.spec.ts src/views/oa/ReadListView.batch.spec.ts # 动过页签 / KeepAlive / 列表条件持久化 / 待阅批量:两张单子各占一格且写的是单据标题、列表页留活而详情页每回重新拉、关掉那张之后钥匙换号、条件与页码带得回来(窄屏只带条件、越界那页收回去)、批量只发看得见的这几条
|
||||
pnpm vitest run src/views/oa/TodoListView.batchRead.spec.ts src/views/oa/TodoListView.batch.spec.ts src/views/oa/ReadListView.batch.spec.ts # 动过待办 / 待阅那两颗批量钮与「全选这一片」:批量已读只交「动哪几条」不发出口不发意见、按下去先确认一次、五档各说一句人话、整片那一档交的是条件不是几个 id、手机端那一横条上第二颗钮还在(少了 `secondary-label` 手机上就退回点十几下)
|
||||
|
|
|
|||
|
|
@ -935,7 +935,7 @@ def update_my_preferences(
|
|||
user: CurrentUser = Depends(current_user),
|
||||
db: Session = Depends(get_db),
|
||||
) -> dict:
|
||||
"""保存本人的界面偏好(深色档 / 字号):设一次,换设备、清缓存之后还是那一版。
|
||||
"""保存本人的界面偏好(深色档 / 字号 / 主题色):设一次,换设备、清缓存之后还是那一版。
|
||||
|
||||
只收白名单里的取值(见 :func:`app.schemas.clean_preferences`),认不出的那几档整档丢掉;
|
||||
没给的键保持原样,所以界面可以只提交刚改动的那一档。这是展示层的偏好,
|
||||
|
|
@ -945,8 +945,11 @@ def update_my_preferences(
|
|||
if person is None:
|
||||
raise unauthorized()
|
||||
patch = schemas.clean_preferences(
|
||||
{name: value for name, value in (("theme", body.theme), ("font", body.font))
|
||||
if name in body.model_fields_set}
|
||||
{name: value for name, value in (
|
||||
("theme", body.theme),
|
||||
("font", body.font),
|
||||
("color", body.color),
|
||||
) if name in body.model_fields_set}
|
||||
)
|
||||
#: JSON 列原地改 SQLAlchemy 认不出来(比对的是同一个对象),必须整体换一个 dict 上去
|
||||
merged = dict(person.preferences or {})
|
||||
|
|
|
|||
|
|
@ -297,10 +297,19 @@ class ChangePasswordRequest(CamelModel):
|
|||
THEMES = ("light", "dark", "system")
|
||||
#: 字号档位与前端 ``useMobileShell.FontScale`` 一字不差:m 是默认(不写进库)。
|
||||
FONT_SCALES = ("m", "l", "xl")
|
||||
#: 主题色档位与前端 ``utils/themeColor.ACCENTS`` 一字不差(色板在 style.css 按
|
||||
#: ``<html data-accent>`` 分套):认不出的那一档画不出颜色,留着只会让人以为设坏了。
|
||||
ACCENT_COLORS = ("teal", "blue", "indigo", "violet", "rose", "amber")
|
||||
#: teal 是默认那一档,存进库也画成同一个样子,但照样收着——它表达的是"我挑的",
|
||||
#: 和"从没挑过"在界面上是同一张脸,没必要为这点差别另开一列。
|
||||
|
||||
|
||||
#: 每一档认的取值;``None`` 单独认,意思是"这一档回到默认"。
|
||||
PREFERENCE_VALUES: dict[str, tuple[str, ...]] = {"theme": THEMES, "font": FONT_SCALES}
|
||||
PREFERENCE_VALUES: dict[str, tuple[str, ...]] = {
|
||||
"theme": THEMES,
|
||||
"font": FONT_SCALES,
|
||||
"color": ACCENT_COLORS,
|
||||
}
|
||||
|
||||
|
||||
def clean_preferences(raw: object) -> dict:
|
||||
|
|
@ -326,10 +335,11 @@ def clean_preferences(raw: object) -> dict:
|
|||
|
||||
|
||||
class PreferencesBody(CamelModel):
|
||||
"""``PUT /auth/me/preferences``:界面偏好(深色档 / 字号),没给的键保持原样。"""
|
||||
"""``PUT /auth/me/preferences``:界面偏好(深色档 / 字号 / 主题色),没给的键保持原样。"""
|
||||
|
||||
theme: str | None = None
|
||||
font: str | None = None
|
||||
color: str | None = None
|
||||
|
||||
|
||||
class BankAccountBody(CamelModel):
|
||||
|
|
|
|||
|
|
@ -888,7 +888,9 @@ def schedule(row: models.Schedule) -> dict:
|
|||
"start_time": dt(row.start_time),
|
||||
"end_time": dt(row.end_time),
|
||||
"all_day": row.all_day,
|
||||
"color": row.color or "#0d9488",
|
||||
# 没配色就回空串,让前端拿当前那一档主题色兜底。
|
||||
# 早先这里写死 "#0d9488":界面换成别的档,没填过颜色的日程仍旧一片旧青。
|
||||
"color": row.color,
|
||||
"owner": row.owner,
|
||||
"owner_name": row.owner_name,
|
||||
"shared_identities": list(row.shared_identities or []),
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@
|
|||
# 永远读不到(文件路径本身就是它决定的),后端会在日志里提醒一句并忽略。
|
||||
# -----------------------------------------------------------------------------
|
||||
[env]
|
||||
name = "dev"
|
||||
name = "prod"
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# 哪些项必须写在 config.<环境名>.toml 里(本文件不放,放了也是被盖住的那一层):
|
||||
|
|
@ -80,7 +80,7 @@ port = 8000 # 监听端口(OA_PORT);uvicorn 命令行的 --port
|
|||
# Logo、是否开放注册按内置默认,界面上改
|
||||
# -----------------------------------------------------------------------------
|
||||
[site]
|
||||
name = "UnisOA" # 系统名称(OA_SITE_NAME)
|
||||
name = "紫光汇智OA" # 系统名称(OA_SITE_NAME)
|
||||
description = "紫光汇智流程审批系统" # 一句话描述(OA_SITE_DESCRIPTION),显示在登录页
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -73,14 +73,38 @@ PC 与手机两版的版式逐条写在 `docs/todo-inbox-unified-design.md` §4
|
|||
|
||||
## 4. 色彩
|
||||
|
||||
`tailwind.config.js` 定义了三个语义槽,注意 primary 实际是 Teal/Cyan 而不是蓝:
|
||||
`tailwind.config.js` 定义了三个语义槽,注意 primary 默认是 Teal/Cyan 而不是蓝:
|
||||
|
||||
| 槽 | 色相 | 用途 |
|
||||
| --- | --- | --- |
|
||||
| `primary-500` = `#14b8a6` | 青 | 主按钮、当前导航、聚焦环、进度条 |
|
||||
| `primary-500` = `#14b8a6`(默认档) | 青 | 主按钮、当前导航、聚焦环、进度条 |
|
||||
| `accent` / `dark` | 深蓝灰 slate | 中性层、边框、深色模式底色 |
|
||||
| 画布选中态 `indigo-600` | 靛蓝 | **仅**出现在设计器工具栏激活态,不与主色争夺注意力 |
|
||||
|
||||
primary 那一套不是写死的:`tailwind.config.js` 把 `primary-*` 指到
|
||||
`rgb(var(--primary-N) / <alpha-value>)`,色板住在 `style.css` 的 `:root` 与各
|
||||
`html[data-accent=…]` 里(青 / 蓝 / 靛蓝 / 紫 / 玫红 / 橙六套,每套 50…950 共十一组
|
||||
RGB 三元组)。存三元组而不是整条颜色,为的是界面里那些 `primary-500/30`
|
||||
的写法——只有把 RGB 拆开交给 `<alpha-value>`,才能既换色又保住透明度层次。
|
||||
用户在「外观」里挑哪一套,`utils/themeColor.ts` 就往 `<html>` 上写那个属性,
|
||||
登录页 `.login-*` 那一组底色也读同一批变量,所以换色是整套的,不留死角。
|
||||
**新加一档要在 `style.css` 与 `ACCENT_OPTIONS` 两处对齐**,只对上一半会静默退回默认青。
|
||||
|
||||
CSS 变量到不了的地方只有两类,都收在 `utils/themeColor.ts` 里问同一本账:
|
||||
|
||||
| 场景 | 用法 |
|
||||
| --- | --- |
|
||||
| 画在 canvas 上(统计页折线/柱状)、拼给 SVG、`<img>` 里的图标 | `accentColor(600)` / `accentRgba(600, .18)`:现问浏览器「当前这一档的 `--primary-600` 算出来是哪三个数」,不在 JS 里抄第二份色板 |
|
||||
| 数据没配颜色时的兜底(流程、日程、未知后缀的文件) | 同上,`process.color \|\| accentColor(600)`。管理员**配过**的颜色是数据,跟着主题换才叫串色 |
|
||||
|
||||
`accentColor()` 读了 `accent` 这一档,所以套在 `computed` 与模板里会跟着换色实时重算,
|
||||
已经画出来的图会当场改颜色。页签上那枚内置 "OA" 图标也由它重画(管理员在「站点信息」
|
||||
里配过自己的 logo 时让开)。唯一跟着不到的是 `public/manifest.webmanifest` 的
|
||||
`theme_color` 与装到桌面上的 PNG——那是静态文件,由 `scripts/gen-icons.py` 生成,
|
||||
按默认档固定,属于已知边界。
|
||||
`DEFAULT_ACCENT_RGB` 是"样式表还没加载"时的那一份兜底副本,
|
||||
`themeColor.spec.ts` 会把 `style.css` 抠出来逐档比,改 CSS 忘了改这里会红。
|
||||
|
||||
类型色板固定,流程节点、图例、轨迹图共用(`flowGraph.TYPE_COLORS`):
|
||||
|
||||
```
|
||||
|
|
@ -94,7 +118,15 @@ parallel/merge/split #7c3aed 紫 script/invoke/embed #2563eb 蓝 delay #0891b
|
|||
圆点式状态用 `StatusBadge.vue`(`active/success` 绿、`warning` 黄、`danger` 红、其余灰)。
|
||||
|
||||
深色模式靠 `class="dark"` 切换(`main.ts` 的 `initThemeClass` 读 localStorage 与
|
||||
`prefers-color-scheme`),组件里成对写 `dark:`,不做第二套主题文件。
|
||||
`prefers-color-scheme`),组件里成对写 `dark:`,不做第二套主题文件。主题色同一道理:
|
||||
组件里照旧写 `bg-primary-600`,不在组件里写死十六进制,否则换色时会露出一块没跟着走的旧色。
|
||||
|
||||
**故意不跟着主题色走的几处**(都是"分类"而不是"品牌",换色时它们必须保持不动,
|
||||
否则图例和实际颜色会对不上):流程节点类型色 `flowGraph.TYPE_COLORS`、
|
||||
设计器里字段类型的底色与选中态 `indigo`(`FormSheetCanvas.vue`,选中态必须压得过任何一档主色)、
|
||||
文件后缀色板(`FilePanel.vue` / `FileDriveView.vue` 的 `TINTS`)、
|
||||
新建日程那八颗色片里除第一颗以外的七颗、以及库里存着的业务数据色
|
||||
(流程定义 `color`、门户分类色、门户封面图)。
|
||||
|
||||
## 5. 排版
|
||||
|
||||
|
|
|
|||
|
|
@ -219,11 +219,15 @@
|
|||
|
||||
## 8. 外观偏好(顺带)
|
||||
|
||||
深色档与字号以前只活在 `localStorage`,换台设备回到解放前。现在 `users.preferences`(JSON)
|
||||
深色档、字号与主题色(2026-11-18 起多这一档,`users.preferences.color`,六档:
|
||||
青 / 蓝 / 靛蓝 / 紫 / 玫红 / 橙)以前只活在 `localStorage`,换台设备回到解放前。现在 `users.preferences`(JSON)
|
||||
是权威,`PUT /auth/me/preferences` 写,`GET /auth/me` 回;`localStorage` 降级成缓存,
|
||||
因为首屏那段防闪脚本只能在本地读(等接口回来再上色,人已经看见一次白闪)。
|
||||
会话落地时 `stores/auth.ts` 调 `adoptPreferences` 把服务端的接过来。
|
||||
读写都在 `utils/appearance.ts`,入口两处:顶栏那颗外观钮(电脑端)与个人页那一格分段选择。
|
||||
深浅与字号读写在 `utils/appearance.ts`,主题色在 `utils/themeColor.ts`(色板本身在
|
||||
`style.css`,JS 只带一个 id;`index.html` 那段防闪脚本负责画第一笔),`adoptPreferences`
|
||||
一次把三档都接过来。入口三处:顶栏那颗外观钮(电脑端)、个人页那一格分段选择、
|
||||
手机「我的」里那一栏,三处共用 `components/common/AccentColorPicker.vue`。
|
||||
|
||||
## 9. 上线要动库
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,14 @@
|
|||
// 不用 classList.toggle(name, force):IE 11 认不出第二个参数,深色档会变反。
|
||||
if (dark) document.documentElement.classList.add('dark')
|
||||
else document.documentElement.classList.remove('dark')
|
||||
// 主题色同理:整套色板在样式表里按 <html data-accent> 分套,
|
||||
// 首屏这一笔只写那一个属性,色值一份都不抄(抄一份就会走样)。
|
||||
// 认不出的值干脆不写,落回 :root 那一套默认青。
|
||||
var accent = localStorage.getItem('oa.accent')
|
||||
if (accent === 'teal' || accent === 'blue' || accent === 'indigo' ||
|
||||
accent === 'violet' || accent === 'rose' || accent === 'amber') {
|
||||
document.documentElement.setAttribute('data-accent', accent)
|
||||
}
|
||||
} catch (e) {
|
||||
/* 隐私模式里 localStorage 会抛:照着浅色画就是 */
|
||||
}
|
||||
|
|
@ -140,7 +148,12 @@
|
|||
.dark .boot-tabs { border-color: #1e293b; }
|
||||
.dark .boot-card { background: #1e293b; }
|
||||
.boot-bar, .boot-card, .boot-tabs, .boot-block {
|
||||
background-image: linear-gradient(90deg, transparent 0%, rgba(13, 148, 136, 0.08) 50%, transparent 100%);
|
||||
background-image: linear-gradient(
|
||||
90deg,
|
||||
transparent 0%,
|
||||
rgb(var(--primary-500, 20 184 166) / 0.08) 50%,
|
||||
transparent 100%
|
||||
);
|
||||
background-size: 200% 100%;
|
||||
background-repeat: no-repeat;
|
||||
animation: boot-shimmer 1.6s linear infinite;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { http } from './client'
|
||||
import type { BankAccount, LoginResponse, PublicSettings, User } from '@/types'
|
||||
import type { AccentId } from '@/utils/themeColor'
|
||||
|
||||
export interface LoginPayload {
|
||||
account: string
|
||||
|
|
@ -105,7 +106,7 @@ export async function updateBankAccount(payload: Pick<BankAccount, 'bank_name' |
|
|||
}
|
||||
|
||||
/**
|
||||
* 保存本人的界面偏好(深色档 / 字号):``users.preferences`` 那一格。
|
||||
* 保存本人的界面偏好(深色档 / 字号 / 主题色):``users.preferences`` 那一格。
|
||||
*
|
||||
* 只提交改动的那一档就够——后端没给的键保持原样。回的是整份 ``/auth/me`` 出参,
|
||||
* 调用方拿它刷新登录态。这一份是**权威**,本地 localStorage 就此降级成缓存:
|
||||
|
|
@ -119,6 +120,7 @@ export async function updatePreferences(payload: UserPreferencesPayload): Promis
|
|||
export interface UserPreferencesPayload {
|
||||
theme?: 'light' | 'dark' | 'system' | null
|
||||
font?: 'm' | 'l' | 'xl' | null
|
||||
color?: AccentId | null
|
||||
}
|
||||
|
||||
export async function getPublicSettings(): Promise<PublicSettings> {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,58 @@
|
|||
// @vitest-environment jsdom
|
||||
/**
|
||||
* 主题色那一排圆点:点了要立刻换色,并且当前那一颗看得出来是选中了的。
|
||||
*
|
||||
* 三个入口(顶栏「外观」、桌面个人设置、手机「我的」)共用这一个组件,
|
||||
* 所以这里只钉组件本身该做的事——存库那条路归 useAppearance 管。
|
||||
*/
|
||||
import { beforeEach, describe, expect, it } from 'vitest'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import { createPinia, setActivePinia } from 'pinia'
|
||||
import { createI18n } from 'vue-i18n'
|
||||
import zh from '@/i18n/locales/zh'
|
||||
import { useAuthStore } from '@/stores'
|
||||
import { ACCENT_ATTR, ACCENT_OPTIONS, accent, DEFAULT_ACCENT, setAccentLocal } from '@/utils/themeColor'
|
||||
import AccentColorPicker from './AccentColorPicker.vue'
|
||||
|
||||
const i18n = createI18n({ legacy: false, locale: 'zh', messages: { zh } })
|
||||
|
||||
function open() {
|
||||
const pinia = createPinia()
|
||||
setActivePinia(pinia)
|
||||
useAuthStore()
|
||||
return mount(AccentColorPicker, { props: { testPrefix: 'oa' }, global: { plugins: [i18n, pinia] } })
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
// 这一档的状态是模块级的一份 ref,跨用例还留着:先把它按回默认再清本地,
|
||||
// 否则「点当前这一档不写盘」那一条会被上一个用例选的色污染。
|
||||
setAccentLocal(DEFAULT_ACCENT)
|
||||
localStorage.clear()
|
||||
document.documentElement.removeAttribute(ACCENT_ATTR)
|
||||
})
|
||||
|
||||
describe('主题色选择器', () => {
|
||||
it('一档一颗圆点,标题写的是这一档的名字', async () => {
|
||||
const wrapper = open()
|
||||
const buttons = wrapper.findAll('button')
|
||||
expect(buttons).toHaveLength(ACCENT_OPTIONS.length)
|
||||
expect(buttons.map((button) => button.attributes('title'))).toEqual(
|
||||
ACCENT_OPTIONS.map((option) => zh.mobile[option.nameKey.split('.')[1]])
|
||||
)
|
||||
})
|
||||
|
||||
it('点一颗就整套界面换色,并把这一档标成选中', async () => {
|
||||
const wrapper = open()
|
||||
await wrapper.get('[data-test="oa-color-blue"]').trigger('click')
|
||||
expect(document.documentElement.getAttribute(ACCENT_ATTR)).toBe('blue')
|
||||
expect(accent.value).toBe('blue')
|
||||
expect(wrapper.get('[data-test="oa-color-blue"]').attributes('aria-pressed')).toBe('true')
|
||||
expect(wrapper.get('[data-test="oa-color-teal"]').attributes('aria-pressed')).toBe('false')
|
||||
})
|
||||
|
||||
it('点当前这一档不重复写本地(省一次没必要的写盘)', async () => {
|
||||
const wrapper = open()
|
||||
await wrapper.get('[data-test="oa-color-teal"]').trigger('click')
|
||||
expect(localStorage.getItem('oa.accent')).toBeNull()
|
||||
})
|
||||
})
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
<template>
|
||||
<!-- 一排放得下的圆点色板:点了就整套界面换色(先当场生效,再存进账号)。
|
||||
圆点本身画的是各自那一档的 600 号,跟按钮实际用的那一只同色,所见即所得。 -->
|
||||
<div class="flex flex-wrap items-center gap-2" role="group" :aria-label="t('mobile.themeColor')">
|
||||
<button
|
||||
v-for="opt in options"
|
||||
:key="opt.id"
|
||||
type="button"
|
||||
class="grid h-7 w-7 flex-shrink-0 place-items-center rounded-full transition-all duration-150 hover:scale-105 focus:outline-none focus-visible:ring-2 focus-visible:ring-gray-400 focus-visible:ring-offset-2 dark:focus-visible:ring-offset-dark-800"
|
||||
:class="[
|
||||
accent === opt.id
|
||||
? 'scale-105 ring-2 ring-gray-900/25 ring-offset-2 ring-offset-white dark:ring-white/40 dark:ring-offset-dark-800'
|
||||
: 'ring-1 ring-black/5 dark:ring-white/15'
|
||||
]"
|
||||
:style="{ backgroundColor: opt.dot }"
|
||||
:title="opt.label"
|
||||
:aria-label="opt.label"
|
||||
:aria-pressed="accent === opt.id"
|
||||
:data-test="`${prefix}-color-${opt.id}`"
|
||||
@click="setThemeColor(opt.id)"
|
||||
>
|
||||
<Icon v-if="accent === opt.id" name="check" class="h-3.5 w-3.5 text-white" />
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 主题色选择器:顶栏那颗外观钮里、桌面「个人设置」、手机「我的」里那一栏,三处同一份。
|
||||
*
|
||||
* 状态与存法都不在这里:取自 composables/useAppearance(本地缓存 + 写回账号),
|
||||
* 所以任何一处点了色,另外两处当场跟着变。色板本身住在 style.css,
|
||||
* 这里只带画圆点要用的那一个数(见 utils/themeColor)。
|
||||
*/
|
||||
import { computed } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import Icon from '@/components/icons/Icon.vue'
|
||||
import { useAppearance } from '@/composables/useAppearance'
|
||||
import { ACCENT_OPTIONS } from '@/utils/themeColor'
|
||||
|
||||
const props = withDefaults(defineProps<{ testPrefix?: string }>(), { testPrefix: 'oa' })
|
||||
|
||||
const { t } = useI18n()
|
||||
const { accent, setThemeColor } = useAppearance()
|
||||
|
||||
const options = computed(() =>
|
||||
ACCENT_OPTIONS.map((option) => ({ id: option.id, dot: option.dot, label: t(option.nameKey) }))
|
||||
)
|
||||
|
||||
const prefix = computed(() => props.testPrefix)
|
||||
</script>
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<div class="w-full">
|
||||
<label v-if="label" :for="id" class="input-label mb-1.5 block">
|
||||
<label v-if="label" :for="id" class="input-label mb-1.5 block" :class="hideLabel ? 'sr-only' : ''">
|
||||
{{ label }}
|
||||
<span v-if="required" class="text-red-500">*</span>
|
||||
</label>
|
||||
|
|
@ -76,6 +76,8 @@ interface Props {
|
|||
maxlength?: number
|
||||
/** 明细表格子里用:跟同排控件等高 */
|
||||
compact?: boolean
|
||||
/** 标签只留给读屏念:靠占位文字认字段的那一屏(登录页)用,字段本身照样有名字 */
|
||||
hideLabel?: boolean
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ export { default as Toast } from './Toast.vue'
|
|||
export { default as LoadingSpinner } from './LoadingSpinner.vue'
|
||||
export { default as EmptyState } from './EmptyState.vue'
|
||||
export { default as LocaleSwitcher } from './LocaleSwitcher.vue'
|
||||
export { default as AccentColorPicker } from './AccentColorPicker.vue'
|
||||
export { default as BackButton } from './BackButton.vue'
|
||||
|
||||
// Export types
|
||||
|
|
|
|||
|
|
@ -34,6 +34,10 @@ export const ICONS = {
|
|||
signature: 'M3 17.25c2 0 2.5-6.5 4.2-6.5s1.8 4.5 3.6 4.5 2.2-3.2 3.7-3.2 1.8 2.2 3.5 2.2h1.5M3 20.25h18',
|
||||
flag: 'M3 3v1.5M3 21v-6m0 0l2.77-.693a9 9 0 016.208.682l.108.054a9 9 0 006.086.71l3.114-.732a48.524 48.524 0 01-.005-10.499l-3.11.732a9 9 0 01-6.085-.711l-.108-.054a9 9 0 00-6.208-.682L3 4.5M3 15V4.5',
|
||||
|
||||
// 外观设置里那颗「主题色」(调色盘:一圈调色板 + 四颗颜料点)
|
||||
palette:
|
||||
'M12 3a9 9 0 100 18c.93 0 1.65-.75 1.65-1.69 0-.44-.18-.83-.44-1.12-.29-.29-.44-.65-.44-1.12a1.64 1.64 0 011.67-1.67h2c2.76 0 5.06-2.27 5.06-5.03C21.5 6.36 17.2 3 12 3zM7.5 12h.01M10 8h.01M14.5 7.5h.01M17.5 11h.01',
|
||||
|
||||
// Designer: canvas and sheet controls
|
||||
zoomIn: 'M21 21l-4.35-4.35m1.35-6.15a7.5 7.5 0 11-15 0 7.5 7.5 0 0115 0zM12 8.5v7M8.5 12h7',
|
||||
zoomOut: 'M21 21l-4.35-4.35m1.35-6.15a7.5 7.5 0 11-15 0 7.5 7.5 0 0115 0zM8.5 12h7',
|
||||
|
|
|
|||
|
|
@ -87,8 +87,8 @@
|
|||
|
||||
<LocaleSwitcher />
|
||||
|
||||
<!-- 外观:深色档与字号。桌面上从前只有一颗"深/浅"切换钮,字号那三档只长在手机上,
|
||||
电脑上调了字号也没处使;这一层把两件事并排放,选完就存进库里(换设备还是这一版)。 -->
|
||||
<!-- 外观:深色档、字号与主题色。桌面上从前只有一颗"深/浅"切换钮,字号那三档只长在手机上,
|
||||
电脑上调了字号也没处使;这一层把几件事并排放,选完就存进库里(换设备还是这一版)。 -->
|
||||
<div class="relative">
|
||||
<button
|
||||
type="button"
|
||||
|
|
@ -141,6 +141,10 @@
|
|||
{{ opt.label }}
|
||||
</button>
|
||||
</div>
|
||||
<p class="mt-3 text-xs font-medium text-gray-400 dark:text-dark-500">{{ t('mobile.themeColor') }}</p>
|
||||
<div class="mt-2">
|
||||
<AccentColorPicker test-prefix="oa" />
|
||||
</div>
|
||||
<p class="mt-3 text-[11px] leading-snug text-gray-400 dark:text-dark-500">{{ t('mobile.appearanceHint') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -201,6 +205,7 @@ import { useRoute, useRouter } from 'vue-router'
|
|||
import { useI18n } from 'vue-i18n'
|
||||
import Icon from '@/components/icons/Icon.vue'
|
||||
import LocaleSwitcher from '@/components/common/LocaleSwitcher.vue'
|
||||
import AccentColorPicker from '@/components/common/AccentColorPicker.vue'
|
||||
import { supportAPI } from '@/api'
|
||||
import { useAppearance } from '@/composables/useAppearance'
|
||||
import { usePwa } from '@/composables/usePwa'
|
||||
|
|
|
|||
|
|
@ -1,62 +1,117 @@
|
|||
<template>
|
||||
<div class="relative flex min-h-screen items-center justify-center overflow-hidden bg-gray-50 px-4 py-10 dark:bg-dark-950">
|
||||
<div class="pointer-events-none absolute inset-0 bg-mesh-gradient"></div>
|
||||
<div class="pointer-events-none absolute -left-24 top-1/4 h-72 w-72 rounded-full bg-primary-200/40 blur-3xl dark:bg-primary-900/20"></div>
|
||||
|
||||
<!-- 窄屏照旧:一张居中的卡片,手机上就是这个比例。
|
||||
宽屏换成「左边讲清楚这是什么系统、右边登录」两栏——以前不管多大的窗口
|
||||
都只有 448px 那张卡漂在一片留白中间,在 27 寸上看着特别不像桌面产品。 -->
|
||||
<div class="relative z-10 w-full max-w-md lg:max-w-5xl">
|
||||
<div class="grid gap-10 lg:grid-cols-[minmax(0,1fr)_26rem] lg:items-center lg:gap-14">
|
||||
<section class="hidden lg:block">
|
||||
<div class="flex items-center gap-3">
|
||||
<span
|
||||
class="flex h-11 w-11 flex-shrink-0 items-center justify-center rounded-2xl bg-primary-600 text-base font-bold text-white shadow-glow"
|
||||
>
|
||||
OA
|
||||
</span>
|
||||
<span class="text-lg font-bold text-gray-900 dark:text-white">{{ t('auth.loginTitle') }}</span>
|
||||
</div>
|
||||
<h2 class="mt-8 text-3xl font-bold leading-snug text-gray-900 dark:text-white">
|
||||
{{ t('auth.desktopHeadline') }}
|
||||
</h2>
|
||||
<p class="mt-3 text-sm leading-relaxed text-gray-500 dark:text-dark-400">{{ t('auth.loginSubtitle') }}</p>
|
||||
<ul class="mt-9 space-y-5">
|
||||
<li v-for="row in highlights" :key="row.title" class="flex gap-3">
|
||||
<span
|
||||
class="mt-0.5 flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-xl bg-primary-100 text-primary-600 dark:bg-primary-900/30 dark:text-primary-400"
|
||||
>
|
||||
<Icon :name="row.icon" class="h-4 w-4" />
|
||||
</span>
|
||||
<span class="min-w-0">
|
||||
<span class="block text-sm font-semibold text-gray-900 dark:text-white">{{ row.title }}</span>
|
||||
<span class="mt-1 block text-xs leading-relaxed text-gray-500 dark:text-dark-400">{{ row.body }}</span>
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<div class="w-full">
|
||||
<slot />
|
||||
</div>
|
||||
<div class="login-page">
|
||||
<!-- 宽屏左边这一栏只讲"这是什么系统、进来按什么顺序办事",登录本身留给右边那一栏。
|
||||
版面与配色抄统一门户那边 EDRS 的登录页(左实右磨砂两块),功能一行没动:
|
||||
原先不管多大的窗口都只有 448px 一张卡漂在留白中间,在 27 寸上不像桌面产品。 -->
|
||||
<section class="login-aside hidden lg:flex">
|
||||
<div class="flex items-center gap-2.5">
|
||||
<span
|
||||
class="flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-lg bg-gradient-primary text-base font-bold text-white"
|
||||
>
|
||||
OA
|
||||
</span>
|
||||
<span class="truncate text-xl font-semibold text-gray-800 dark:text-dark-50">{{ siteName }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-[13vh]">
|
||||
<h1 class="login-hero-title">{{ t('auth.desktopHeadline') }}</h1>
|
||||
<p class="login-hero-desc">{{ t('auth.loginSubtitle') }}</p>
|
||||
</div>
|
||||
|
||||
<div class="mt-[12vh]">
|
||||
<ol class="login-steps">
|
||||
<li v-for="(row, index) in highlights" :key="row.title" class="login-step" :title="row.body">
|
||||
<span class="login-step-index">{{ index + 1 }}</span>
|
||||
<span class="login-step-label">{{ row.title }}</span>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
<div class="login-aside-footer">
|
||||
<span>{{ t('auth.asideNote1') }}</span>
|
||||
<span class="login-aside-divider" aria-hidden="true"></span>
|
||||
<span>{{ t('auth.asideNote2') }}</span>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<main class="login-main">
|
||||
<!-- 右上角这两颗:语言与深浅。抄的那一版在这个位置放的就是「跟随系统」那颗钮,
|
||||
这套界面本来就有同一档(顶栏那颗走的是同一个 cycleTheme),顺手搬过来。 -->
|
||||
<div class="absolute right-4 top-4 z-10 flex items-center gap-1">
|
||||
<LocaleSwitcher />
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-ghost btn-icon"
|
||||
:title="themeLabel"
|
||||
:aria-label="themeLabel"
|
||||
data-test="login-theme-toggle"
|
||||
@click="cycleTheme"
|
||||
>
|
||||
<Icon :name="themeIcon" class="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="flex w-full max-w-[420px] animate-slide-up flex-col justify-center">
|
||||
<!-- 窄屏没有左边那一栏,品牌标识得自己带上;宽屏就交给左边那一份 -->
|
||||
<div class="mb-9 flex items-center gap-2.5 lg:hidden">
|
||||
<span
|
||||
class="flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-lg bg-gradient-primary text-base font-bold text-white"
|
||||
>
|
||||
OA
|
||||
</span>
|
||||
<span class="truncate text-xl font-semibold text-gray-800 dark:text-dark-50">{{ siteName }}</span>
|
||||
</div>
|
||||
|
||||
<div class="flex-1" aria-hidden="true"></div>
|
||||
<slot />
|
||||
<div class="flex-1" aria-hidden="true"></div>
|
||||
|
||||
<div class="login-caption">{{ t('auth.copyright') }}</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 登录与免登落地共用的那一层壳子。
|
||||
*
|
||||
* 这一层只管版面(左边讲系统、右边放内容、右上角两颗偏好钮、底下一行小字),
|
||||
* 内容全部由 ``<slot />`` 那一屏自己决定:登录页放表单与「其他登录方式」,
|
||||
* 免登落地页放失败的那一句话。深浅与主题色不在这里挑,样式里读的是
|
||||
* ``<html>`` 上的 class 与 ``data-accent``(utils/appearance、utils/themeColor),
|
||||
* 首屏 index.html 已经画好第一笔,所以换色之后登录页跟着一起换,不用这里操心。
|
||||
*/
|
||||
import { computed } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import Icon from '@/components/icons/Icon.vue'
|
||||
import LocaleSwitcher from '@/components/common/LocaleSwitcher.vue'
|
||||
import { useAppearance } from '@/composables/useAppearance'
|
||||
import { useAppStore } from '@/stores/app'
|
||||
import type { ThemeMode } from '@/utils/appearance'
|
||||
|
||||
type IconName = InstanceType<typeof Icon>['$props']['name']
|
||||
|
||||
const { t } = useI18n()
|
||||
const appStore = useAppStore()
|
||||
const { themeMode, cycleTheme } = useAppearance()
|
||||
|
||||
/** 三句话只讲这套系统本就在做的事,不写口号。 */
|
||||
const highlights = computed<{ icon: IconName; title: string; body: string }[]>(() => [
|
||||
{ icon: 'inbox', title: t('auth.desktopTodo'), body: t('auth.desktopTodoBody') },
|
||||
{ icon: 'plus', title: t('auth.desktopStart'), body: t('auth.desktopStartBody') },
|
||||
{ icon: 'checkCircle', title: t('auth.desktopTrace'), body: t('auth.desktopTraceBody') }
|
||||
const THEME_ICONS: Record<ThemeMode, IconName> = { light: 'sun', dark: 'moon', system: 'window' }
|
||||
const THEME_LABELS: Record<ThemeMode, string> = {
|
||||
light: 'mobile.themeLight',
|
||||
dark: 'mobile.themeDark',
|
||||
system: 'mobile.themeSystem'
|
||||
}
|
||||
const themeIcon = computed<IconName>(() => THEME_ICONS[themeMode.value] ?? 'sun')
|
||||
/** 钮上写的是"现在这一档",按下去是下一档:与顶栏那颗同一个手感。 */
|
||||
const themeLabel = computed(() => `${t('mobile.appearance')} · ${t(THEME_LABELS[themeMode.value] ?? 'mobile.themeSystem')}`)
|
||||
|
||||
const siteName = computed(() => appStore.siteName || t('auth.loginTitle'))
|
||||
|
||||
/** 左边那一栏的三步:只讲这套系统本就在做的事,不写口号。 */
|
||||
const highlights = computed<{ title: string; body: string }[]>(() => [
|
||||
{ title: t('auth.desktopTodo'), body: t('auth.desktopTodoBody') },
|
||||
{ title: t('auth.desktopStart'), body: t('auth.desktopStartBody') },
|
||||
{ title: t('auth.desktopTrace'), body: t('auth.desktopTraceBody') }
|
||||
])
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ import { errorMessage } from '@/utils/oa'
|
|||
import { canPreview, previewHint } from '@/utils/preview'
|
||||
import { formatBytes } from '@/utils/format'
|
||||
import { useAppStore } from '@/stores/app'
|
||||
import { accentColor } from '@/utils/themeColor'
|
||||
import type { PortalFile, PortalHome } from '@/types'
|
||||
|
||||
const props = defineProps<{ home: PortalHome; pageSize?: number }>()
|
||||
|
|
@ -112,7 +113,7 @@ const TINTS: Record<string, string> = {
|
|||
txt: '#64748b'
|
||||
}
|
||||
|
||||
const tint = (extension: string) => TINTS[extension?.toLowerCase()] ?? '#0d9488'
|
||||
const tint = (extension: string) => TINTS[extension?.toLowerCase()] ?? accentColor(600)
|
||||
|
||||
const viewer = ref<number | null>(null)
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
/>
|
||||
<div
|
||||
v-else
|
||||
class="flex h-full w-full items-end bg-gradient-to-br from-primary-600 via-primary-500 to-teal-400 p-3"
|
||||
class="flex h-full w-full items-end bg-gradient-to-br from-primary-600 via-primary-500 to-primary-400 p-3"
|
||||
>
|
||||
<Icon name="fire" class="absolute right-3 top-3 h-10 w-10 text-white/20" />
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -72,8 +72,8 @@
|
|||
:style="{ backgroundColor: tint(item.color) }"
|
||||
>
|
||||
<div class="flex items-center gap-1.5">
|
||||
<span class="h-2 w-2 flex-shrink-0 rounded-full" :style="{ backgroundColor: item.color || '#0d9488' }"></span>
|
||||
<span class="truncate text-[13px] font-semibold" :style="{ color: item.color || '#0d9488' }">
|
||||
<span class="h-2 w-2 flex-shrink-0 rounded-full" :style="{ backgroundColor: item.color || accentColor(600) }"></span>
|
||||
<span class="truncate text-[13px] font-semibold" :style="{ color: item.color || accentColor(600) }">
|
||||
{{ item.title }}
|
||||
</span>
|
||||
</div>
|
||||
|
|
@ -97,6 +97,7 @@ import { portalAPI } from '@/api'
|
|||
import { errorMessage } from '@/utils/oa'
|
||||
import { formatDateWithSystemLocale } from '@/utils/format'
|
||||
import { useAppStore } from '@/stores/app'
|
||||
import { accentColor, accentRgba } from '@/utils/themeColor'
|
||||
import type { PortalHome, ScheduleItem } from '@/types'
|
||||
|
||||
interface Cell {
|
||||
|
|
@ -173,8 +174,8 @@ function cellClass(cell: Cell): string {
|
|||
|
||||
/** Soft tint for the day list, mirroring the O2OA light/dark calendar colour pairs. */
|
||||
function tint(color: string): string {
|
||||
const hex = (color || '#0d9488').replace('#', '')
|
||||
if (hex.length !== 6) return 'rgba(13, 148, 136, 0.12)'
|
||||
const hex = (color || accentColor(600)).replace('#', '')
|
||||
if (hex.length !== 6) return accentRgba(600, 0.12)
|
||||
const r = parseInt(hex.slice(0, 2), 16)
|
||||
const g = parseInt(hex.slice(2, 4), 16)
|
||||
const b = parseInt(hex.slice(4, 6), 16)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
/**
|
||||
* 界面上的那几颗外观钮(深色档、字号)怎么落地:先当场生效,再悄悄存进库里。
|
||||
* 界面上的那几颗外观钮(深色档、字号、主题色)怎么落地:先当场生效,再悄悄存进库里。
|
||||
*
|
||||
* 生效一定排在存库之前——人按下那颗钮是要立刻看见结果的,网络慢半拍不能把画面卡住。
|
||||
* 存库失败也不弹错误条:本地那一份缓存还在,下一次改动或下一次登录还会带上,
|
||||
* 为一次没存上的字号打断人手里的活是本末倒置。只在完全没有登录态时不提交。
|
||||
*
|
||||
* 三处入口(顶栏那颗钮、桌面「个人设置」、手机「我的」里那一栏)都用这一个,
|
||||
* 状态取自 utils/appearance,任何一处改了另外两处当场跟着变。
|
||||
* 状态取自 utils/appearance 与 utils/themeColor,任何一处改了另外两处当场跟着变。
|
||||
*/
|
||||
import * as authAPI from '@/api/auth'
|
||||
import {
|
||||
|
|
@ -18,6 +18,7 @@ import {
|
|||
type PreferencesPayload,
|
||||
type ThemeMode
|
||||
} from '@/utils/appearance'
|
||||
import { accent, setAccentLocal, type AccentId } from '@/utils/themeColor'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
|
||||
/** 连着按多下只保留最后一次提交:库里那一份要的是最终答案,不是每一次中间态。 */
|
||||
|
|
@ -48,6 +49,13 @@ export function useAppearance() {
|
|||
save({ font: scale })
|
||||
}
|
||||
|
||||
/** 主题色:和深色档、字号一样,先当场换色,再悄悄存进账号。 */
|
||||
function setThemeColor(id: AccentId): void {
|
||||
if (id === accent.value) return
|
||||
setAccentLocal(id)
|
||||
save({ color: id })
|
||||
}
|
||||
|
||||
/** 顶栏那颗钮:浅色 → 深色 → 跟随系统 → 浅色,三档轮着走。 */
|
||||
function cycleTheme(): ThemeMode {
|
||||
const order: ThemeMode[] = ['light', 'dark', 'system']
|
||||
|
|
@ -56,5 +64,5 @@ export function useAppearance() {
|
|||
return next
|
||||
}
|
||||
|
||||
return { themeMode, fontScale, setThemeMode, setFontScale, cycleTheme }
|
||||
return { themeMode, fontScale, accent, setThemeMode, setFontScale, setThemeColor, cycleTheme }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -293,7 +293,15 @@ export default {
|
|||
themeDark: 'Dark',
|
||||
darkMode: 'Dark mode',
|
||||
// Where these live matters — that was the complaint: theme and size now follow the account
|
||||
appearanceHint: 'Theme and text size are saved to your account, so they survive a new device or a cleared cache.',
|
||||
appearanceHint: 'Theme, text size and accent color are saved to your account, so they survive a new device or a cleared cache.',
|
||||
// Accent color: buttons, links, selected states and the login backdrop all follow this one
|
||||
themeColor: 'Accent color',
|
||||
accentTeal: 'Teal',
|
||||
accentBlue: 'Blue',
|
||||
accentIndigo: 'Indigo',
|
||||
accentViolet: 'Violet',
|
||||
accentRose: 'Rose',
|
||||
accentAmber: 'Amber',
|
||||
language: 'Language',
|
||||
installApp: 'Add to Home Screen',
|
||||
// This shortcut opens the portal; the "Home" tab means the five tiles, keep them apart
|
||||
|
|
@ -351,7 +359,17 @@ export default {
|
|||
ssoErrInactive: 'This account is disabled, contact an administrator',
|
||||
ssoErrProvision: 'Your unified identity checks out but this system has no account for you; contact an administrator or enable auto provisioning',
|
||||
ssoErrHandoff: 'This sign-in redirect has expired; go back to the portal and open this app again',
|
||||
ssoFailedGeneric: 'Single sign-on did not complete; go back to the unified portal and open this app again'
|
||||
ssoFailedGeneric: 'Single sign-on did not complete; go back to the unified portal and open this app again',
|
||||
// The right-hand column of the login screen (styling copied from the portal side)
|
||||
welcome: 'Welcome back',
|
||||
altLogin: 'Other sign-in options',
|
||||
portalLogin: 'Unified portal',
|
||||
portalLoginHint: 'Click "{app}" in the portal and you are in - no second password needed',
|
||||
portalCaption: 'Accounts are issued and managed by the unified portal; this system does not register on its own.',
|
||||
portalAccountNote: 'Regular users sign in from the unified portal',
|
||||
// The two lines under the left-hand column: where accounts come from, where data lives
|
||||
asideNote1: 'Accounts come from the company portal',
|
||||
asideNote2: 'Your workflow data stays on your own server'
|
||||
},
|
||||
workbench: {
|
||||
title: 'Workbench',
|
||||
|
|
|
|||
|
|
@ -289,7 +289,15 @@ export default {
|
|||
themeDark: '深色',
|
||||
darkMode: '深色模式',
|
||||
// 桌面顶栏那一层里说清"存哪儿":这是这条反馈的关键——设一次,换设备还在
|
||||
appearanceHint: '皮肤与字号会存进你的账号,换设备、清缓存之后还是这一版。',
|
||||
appearanceHint: '皮肤、字号与主题色会存进你的账号,换设备、清缓存之后还是这一版。',
|
||||
// 主题色:一整套界面(按钮、链接、选中态、登录页底色)跟着这一档换
|
||||
themeColor: '主题色',
|
||||
accentTeal: '青',
|
||||
accentBlue: '蓝',
|
||||
accentIndigo: '靛蓝',
|
||||
accentViolet: '紫',
|
||||
accentRose: '玫红',
|
||||
accentAmber: '橙',
|
||||
language: '语言',
|
||||
installApp: '添加到主屏幕',
|
||||
// 入口里这一格指门户那一屏;底部标签栏那格「首页」指的是工作台那五张卡片,别撞名
|
||||
|
|
@ -347,7 +355,17 @@ export default {
|
|||
ssoErrInactive: '账号已停用,请联系管理员',
|
||||
ssoErrProvision: '统一身份校验已通过,但本系统还没有你的账号,请联系管理员或开启自动建号',
|
||||
ssoErrHandoff: '这次免登跳转已经失效,请回到统一门户重新点击本系统',
|
||||
ssoFailedGeneric: '免登没有成功,请回到统一门户重新点击本系统'
|
||||
ssoFailedGeneric: '免登没有成功,请回到统一门户重新点击本系统',
|
||||
// 登录页右栏那一屏(样式抄统一门户那边):标题、「其他登录方式」那一排、底下的小字
|
||||
welcome: '欢迎回来',
|
||||
altLogin: '其他登录方式',
|
||||
portalLogin: '统一门户',
|
||||
portalLoginHint: '在门户里点「{app}」就会自动登录,不用再输一次账号密码',
|
||||
portalCaption: '账号由统一门户发放与管理,本系统不再单独注册。',
|
||||
portalAccountNote: '普通用户请从统一门户免登进入',
|
||||
// 宽屏左边那一栏底下那两行:一句说账号从哪儿来,一句说数据存在哪儿
|
||||
asideNote1: '账号来自公司统一门户',
|
||||
asideNote2: '流程数据存在你自己的服务器上'
|
||||
},
|
||||
workbench: {
|
||||
title: '工作台',
|
||||
|
|
|
|||
|
|
@ -23,6 +23,101 @@
|
|||
--app-shell-max: 1720px;
|
||||
}
|
||||
|
||||
/* ============ 主题色(整体颜色) ============
|
||||
* 整套 primary-* 都由下面这十一组 RGB 三元组决定:tailwind.config.js 那一侧只写
|
||||
* rgb(var(--primary-500) / <alpha-value>),换主题色就是换这十一行。
|
||||
* 存三元组而不是整条颜色,是因为界面里到处是 primary-500/30 这种带透明度的写法,
|
||||
* 只有把 RGB 拆开交给 <alpha-value>,才能既换色又保住原来的透明度层次。
|
||||
*
|
||||
* 用哪一套由 <html data-accent="blue"> 这类属性决定(见 utils/themeColor.ts)。
|
||||
* 这里当唯一的色板出处,JS 只带一个 id:首屏 index.html 那一笔之前就照本地存的
|
||||
* 那一份把属性写上,不会先青后蓝闪一下;属性没写或认不出,就是下面这套默认青。 */
|
||||
:root {
|
||||
--app-shell-max: 1720px;
|
||||
--primary-50: 240 253 250;
|
||||
--primary-100: 204 251 241;
|
||||
--primary-200: 153 246 228;
|
||||
--primary-300: 94 234 212;
|
||||
--primary-400: 45 212 191;
|
||||
--primary-500: 20 184 166;
|
||||
--primary-600: 13 148 136;
|
||||
--primary-700: 15 118 110;
|
||||
--primary-800: 17 94 89;
|
||||
--primary-900: 19 78 74;
|
||||
--primary-950: 4 47 46;
|
||||
}
|
||||
|
||||
/* 门户蓝:与统一门户那边同一套蓝,两系统并排看着像一家 */
|
||||
html[data-accent='blue'] {
|
||||
--primary-50: 238 245 255;
|
||||
--primary-100: 220 234 255;
|
||||
--primary-200: 188 215 255;
|
||||
--primary-300: 147 192 255;
|
||||
--primary-400: 107 166 255;
|
||||
--primary-500: 63 140 255;
|
||||
--primary-600: 47 116 230;
|
||||
--primary-700: 36 96 194;
|
||||
--primary-800: 31 79 158;
|
||||
--primary-900: 27 63 121;
|
||||
--primary-950: 18 41 77;
|
||||
}
|
||||
|
||||
html[data-accent='indigo'] {
|
||||
--primary-50: 238 242 255;
|
||||
--primary-100: 224 231 255;
|
||||
--primary-200: 199 210 254;
|
||||
--primary-300: 165 180 252;
|
||||
--primary-400: 129 140 248;
|
||||
--primary-500: 99 102 241;
|
||||
--primary-600: 79 70 229;
|
||||
--primary-700: 67 56 202;
|
||||
--primary-800: 55 48 163;
|
||||
--primary-900: 49 46 129;
|
||||
--primary-950: 30 27 75;
|
||||
}
|
||||
|
||||
html[data-accent='violet'] {
|
||||
--primary-50: 245 243 255;
|
||||
--primary-100: 237 233 254;
|
||||
--primary-200: 221 214 254;
|
||||
--primary-300: 196 181 253;
|
||||
--primary-400: 167 139 250;
|
||||
--primary-500: 139 92 246;
|
||||
--primary-600: 124 58 237;
|
||||
--primary-700: 109 40 217;
|
||||
--primary-800: 91 33 182;
|
||||
--primary-900: 76 29 149;
|
||||
--primary-950: 46 16 101;
|
||||
}
|
||||
|
||||
html[data-accent='rose'] {
|
||||
--primary-50: 255 241 242;
|
||||
--primary-100: 255 228 230;
|
||||
--primary-200: 254 205 211;
|
||||
--primary-300: 253 164 175;
|
||||
--primary-400: 251 113 133;
|
||||
--primary-500: 244 63 94;
|
||||
--primary-600: 225 29 72;
|
||||
--primary-700: 190 18 60;
|
||||
--primary-800: 159 18 57;
|
||||
--primary-900: 136 19 55;
|
||||
--primary-950: 76 5 25;
|
||||
}
|
||||
|
||||
html[data-accent='amber'] {
|
||||
--primary-50: 255 251 235;
|
||||
--primary-100: 254 243 199;
|
||||
--primary-200: 253 230 138;
|
||||
--primary-300: 252 211 77;
|
||||
--primary-400: 251 191 36;
|
||||
--primary-500: 245 158 11;
|
||||
--primary-600: 217 119 6;
|
||||
--primary-700: 180 83 9;
|
||||
--primary-800: 146 64 14;
|
||||
--primary-900: 120 53 15;
|
||||
--primary-950: 69 26 3;
|
||||
}
|
||||
|
||||
.dark {
|
||||
color-scheme: dark;
|
||||
}
|
||||
|
|
@ -911,6 +1006,187 @@
|
|||
.table-wrapper thead.sticky {
|
||||
box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
|
||||
}
|
||||
|
||||
/* ============ 登录页(样式抄自统一门户那边 EDRS 的登录页) ============
|
||||
* 左边一整栏讲这是干什么的系统,右边一块半透明白磨砂只放登录本身,
|
||||
* 底下再挂一行「其他登录方式」的圆钮。原先是 448px 一张卡漂在留白中间,
|
||||
* 在宽屏上不像桌面产品;抄过来之后窄屏还是一列居中,只是不再有那张卡。
|
||||
* 底色跟着主题色走(--primary-*),换配色时登录页一起换,不用两头改。 */
|
||||
.login-page {
|
||||
@apply relative flex min-h-screen flex-col;
|
||||
background-color: #f5f6fa;
|
||||
}
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
.login-page {
|
||||
@apply flex-row;
|
||||
}
|
||||
}
|
||||
|
||||
.login-page::before {
|
||||
content: '';
|
||||
@apply pointer-events-none absolute inset-0;
|
||||
/* 透明度是量出来的:色板里 200/300 那两档原样铺满整屏太艳(抄的那一版用的是
|
||||
几乎发白的浅蓝),压成淡色才像背景而不像一块色卡,同时右栏磨砂还看得出来底下有东西。 */
|
||||
background: radial-gradient(120% 100% at 8% 0%, #fff, transparent 58%),
|
||||
linear-gradient(
|
||||
105deg,
|
||||
rgb(var(--primary-50)) 0%,
|
||||
rgb(var(--primary-100) / 0.8) 32%,
|
||||
rgb(var(--primary-200) / 0.45) 66%,
|
||||
rgb(var(--primary-300) / 0.3) 100%
|
||||
);
|
||||
}
|
||||
|
||||
.dark .login-page {
|
||||
background-color: #0d141f;
|
||||
}
|
||||
|
||||
.dark .login-page::before {
|
||||
background: radial-gradient(110% 90% at 10% 0%, rgb(var(--primary-500) / 0.18), transparent 62%),
|
||||
linear-gradient(
|
||||
105deg,
|
||||
#0b1220 0%,
|
||||
#101c30 42%,
|
||||
rgb(var(--primary-900) / 0.55) 78%,
|
||||
rgb(var(--primary-800) / 0.5) 100%
|
||||
);
|
||||
}
|
||||
|
||||
.login-aside {
|
||||
@apply relative flex flex-1 flex-col px-6 py-7 backdrop-blur-[10px];
|
||||
}
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
.login-aside {
|
||||
padding: 59px 67px;
|
||||
}
|
||||
}
|
||||
|
||||
.login-hero-title {
|
||||
@apply max-w-[680px] text-[32px] font-bold leading-[1.12] tracking-[-0.025em] text-gray-900 dark:text-white;
|
||||
}
|
||||
|
||||
@media (min-width: 1280px) {
|
||||
.login-hero-title {
|
||||
@apply text-[42px];
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 1536px) {
|
||||
.login-hero-title {
|
||||
@apply text-[50px] leading-[1.06];
|
||||
}
|
||||
}
|
||||
|
||||
.login-hero-accent {
|
||||
@apply text-primary-600 dark:text-primary-400;
|
||||
}
|
||||
|
||||
.login-hero-desc {
|
||||
@apply mt-4 max-w-[600px] text-[15px] leading-7 text-gray-500 dark:text-dark-400;
|
||||
}
|
||||
|
||||
@media (min-width: 1280px) {
|
||||
.login-hero-desc {
|
||||
@apply text-base leading-6;
|
||||
}
|
||||
}
|
||||
|
||||
/* 左边那一栏底下的三步:一句话说清进来的顺序,比三条并列的功能介绍省地方 */
|
||||
.login-steps {
|
||||
@apply flex flex-wrap items-center gap-x-7 gap-y-3;
|
||||
}
|
||||
|
||||
.login-step {
|
||||
@apply flex items-center gap-2.5;
|
||||
}
|
||||
|
||||
.login-step-index {
|
||||
@apply flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-full border text-xs font-semibold;
|
||||
border-color: rgb(var(--primary-200));
|
||||
background-color: rgb(255 255 255 / 0.7);
|
||||
color: rgb(var(--primary-600));
|
||||
}
|
||||
|
||||
.dark .login-step-index {
|
||||
border-color: rgb(var(--primary-400) / 0.3);
|
||||
background-color: rgb(var(--primary-500) / 0.1);
|
||||
color: rgb(var(--primary-300));
|
||||
}
|
||||
|
||||
.login-step-label {
|
||||
@apply whitespace-nowrap text-sm text-gray-600 dark:text-dark-300;
|
||||
}
|
||||
|
||||
.login-aside-footer {
|
||||
@apply mt-auto flex flex-wrap items-center gap-3 pt-10 text-sm text-gray-400 dark:text-dark-500;
|
||||
}
|
||||
|
||||
.login-aside-divider {
|
||||
@apply h-3 w-px bg-gray-200 dark:bg-dark-700;
|
||||
}
|
||||
|
||||
/* 右边这一栏:只有登录,压在磨砂上,宽度收在四成以内 */
|
||||
.login-main {
|
||||
@apply relative flex flex-1 justify-center bg-white/[0.85] px-6 py-12 backdrop-blur-2xl dark:bg-[#0d141f]/80;
|
||||
}
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
.login-main {
|
||||
@apply max-w-[40%] px-10 py-6;
|
||||
}
|
||||
}
|
||||
|
||||
/* 表单一律换成大号输入框:48 高、8 圆角、16 号字,和门户那边一个手感 */
|
||||
.login-form .input {
|
||||
height: 3rem;
|
||||
border-radius: 0.5rem;
|
||||
font-size: 1rem;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.login-submit {
|
||||
@apply inline-flex h-[50px] w-full items-center justify-center gap-2 rounded-lg bg-primary-600 px-4 text-base font-semibold text-white;
|
||||
@apply transition-colors duration-150 hover:bg-primary-700 active:bg-primary-800;
|
||||
@apply focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500/45 focus-visible:ring-offset-2;
|
||||
@apply disabled:pointer-events-none disabled:opacity-45 dark:bg-primary-600 dark:hover:bg-primary-500;
|
||||
box-shadow: 0 6px 16px rgb(var(--primary-600) / 0.28);
|
||||
}
|
||||
|
||||
/* 「其他登录方式」:一条细分割线 + 一排圆钮,第三方入口从这里走 */
|
||||
.login-alt {
|
||||
@apply mt-8;
|
||||
}
|
||||
|
||||
.login-divider {
|
||||
@apply h-px flex-1 bg-gray-200 dark:bg-dark-700;
|
||||
}
|
||||
|
||||
.login-alt-group {
|
||||
@apply mt-5 flex flex-wrap items-start justify-center gap-8;
|
||||
}
|
||||
|
||||
.login-alt-item {
|
||||
@apply flex w-20 flex-col items-center gap-2 rounded-lg p-1;
|
||||
@apply focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500/45;
|
||||
}
|
||||
|
||||
.login-alt-icon {
|
||||
@apply grid h-12 w-12 place-items-center rounded-full border border-gray-200 bg-white text-gray-500;
|
||||
@apply transition-colors duration-150 hover:border-primary-300 hover:bg-primary-50 hover:text-primary-600;
|
||||
@apply dark:border-dark-700 dark:bg-dark-800 dark:text-dark-300;
|
||||
@apply dark:hover:border-primary-400/50 dark:hover:bg-primary-500/10 dark:hover:text-primary-300;
|
||||
}
|
||||
|
||||
.login-alt-label {
|
||||
@apply text-xs text-gray-500 dark:text-dark-400;
|
||||
}
|
||||
|
||||
/* 右栏最底下那两行小字:账号从哪儿来、数据存在哪儿 */
|
||||
.login-caption {
|
||||
@apply pt-6 text-center text-[13px] leading-[22px] text-gray-400 dark:text-dark-500;
|
||||
}
|
||||
}
|
||||
|
||||
@layer utilities {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
.driver-active-element {
|
||||
position: relative !important;
|
||||
z-index: 99999999 !important;
|
||||
outline: 4px solid rgba(20, 184, 166, 0.2) !important;
|
||||
outline: 4px solid rgb(var(--primary-500) / 0.2) !important;
|
||||
border-radius: 4px !important;
|
||||
}
|
||||
|
||||
|
|
@ -197,11 +197,11 @@
|
|||
}
|
||||
|
||||
.theme-tour-popover .driver-popover-next-btn {
|
||||
background-color: #14b8a6 !important;
|
||||
background-color: rgb(var(--primary-500)) !important;
|
||||
color: #ffffff !important;
|
||||
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05) !important;
|
||||
}
|
||||
.theme-tour-popover .driver-popover-next-btn:hover { background-color: #0d9488 !important; }
|
||||
.theme-tour-popover .driver-popover-next-btn:hover { background-color: rgb(var(--primary-600)) !important; }
|
||||
|
||||
.theme-tour-popover .driver-popover-prev-btn {
|
||||
background-color: white !important;
|
||||
|
|
|
|||
|
|
@ -78,13 +78,15 @@ export interface User {
|
|||
*/
|
||||
hub_permission?: HubPermissionState
|
||||
/**
|
||||
* 本人界面偏好(深色档 / 字号),存 ``users.preferences``。
|
||||
* 本人界面偏好(深色档 / 字号 / 主题色),存 ``users.preferences``。
|
||||
* 只有 /auth/me 与登录返回体带这一份;从没设过是空对象。
|
||||
* 本地 localStorage 只是它的一份缓存,登录后以这里为准(utils/appearance.ts)。
|
||||
* 本地 localStorage 只是它的一份缓存,登录后以这里为准(utils/appearance.ts、
|
||||
* 主题色那一份在 utils/themeColor)。
|
||||
*/
|
||||
preferences?: {
|
||||
theme?: 'light' | 'dark' | 'system'
|
||||
font?: 'm' | 'l' | 'xl'
|
||||
color?: 'teal' | 'blue' | 'indigo' | 'violet' | 'rose' | 'amber'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* 界面偏好(深色档 + 字号):本地存一份能立刻生效的缓存,库里存权威的那一份。
|
||||
* 界面偏好(深色档 + 字号 + 主题色):本地存一份能立刻生效的缓存,库里存权威的那一份。
|
||||
*
|
||||
* 为什么要两本账:首屏 index.html 里那段脚本必须在画第一笔之前就知道该画浅色还是深色,
|
||||
* 那时候还没登录、拿不到接口,只能读本地。所以本地这一份留着当缓存,
|
||||
|
|
@ -8,9 +8,11 @@
|
|||
* 从前只有本地这一份,设置确实存了,只是存在了那一台浏览器里。
|
||||
*
|
||||
* 三个入口(顶栏那颗钮、桌面「个人设置」、手机「我的」里那一栏)都从这里读写,
|
||||
* 界面状态由 themeMode / fontScale 这两个 ref 握着,任何一处改动另外两处当场跟着变。
|
||||
* 界面状态由 themeMode / fontScale 这两个 ref 握着(主题色那一份在 utils/themeColor),
|
||||
* 任何一处改动另外两处当场跟着变。
|
||||
*/
|
||||
import { ref } from 'vue'
|
||||
import { accent, DEFAULT_ACCENT, isAccentId, setAccentLocal, type AccentId } from '@/utils/themeColor'
|
||||
|
||||
export type ThemeMode = 'light' | 'dark' | 'system'
|
||||
export type FontScale = 'm' | 'l' | 'xl'
|
||||
|
|
@ -103,10 +105,14 @@ export function isDark(): boolean {
|
|||
return isDarkOf(themeMode.value)
|
||||
}
|
||||
|
||||
/** 深色档与字号各存一处,谁先落地互不牵连(一次提交两个键也行,见 api 那一份)。 */
|
||||
/**
|
||||
* 三档偏好各存一处,谁先落地互不牵连(一次提交两个键也行,见 api 那一份)。
|
||||
* ``color`` 是主题色,色板与画法在 utils/themeColor,这里只跟着同一班车走。
|
||||
*/
|
||||
export interface PreferencesPayload {
|
||||
theme?: ThemeMode | null
|
||||
font?: FontScale | null
|
||||
color?: AccentId | null
|
||||
}
|
||||
|
||||
/** 只改本地 + 画面,不碰接口:首屏那条路径与没登录时走这一条。 */
|
||||
|
|
@ -148,9 +154,20 @@ export function adoptPreferences(preferences?: Partial<PreferencesPayload> | nul
|
|||
if (isFontScale(String(font ?? '')) && String(font) !== fontScale.value) {
|
||||
setFontScaleLocal(font as FontScale)
|
||||
}
|
||||
// 主题色显式给 null 是「回到默认青」,没给这个键才是「别动我这儿的颜色」
|
||||
if ('color' in preferences) {
|
||||
const color = preferences.color
|
||||
if (color === null) {
|
||||
if (accent.value !== DEFAULT_ACCENT) setAccentLocal(DEFAULT_ACCENT)
|
||||
} else if (isAccentId(String(color ?? '')) && String(color) !== accent.value) {
|
||||
setAccentLocal(color as AccentId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 模块加载即生效:登录页、免登落地页也该带着自己的字号,不该等进主界面才变。 */
|
||||
/** 模块加载即生效:登录页、免登落地页也该带着自己的字号,不该等进主界面才变。
|
||||
* 主题色不在这里画第一笔——它由 utils/themeColor 自己负责,加一档颜色时
|
||||
* 记得同时在 style.css 里补一份同名色板,两边对不上就会静默退回默认青。 */
|
||||
paint(themeMode.value)
|
||||
applyFontScale(fontScale.value)
|
||||
applyDesktopScale(fontScale.value)
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import { existsSync, readFileSync } from 'node:fs'
|
|||
import { dirname, join, resolve } from 'node:path'
|
||||
import { beforeEach, describe, expect, it } from 'vitest'
|
||||
import { DEFAULT_FAVICON, updateFavicon } from './branding'
|
||||
import { DEFAULT_ACCENT_RGB } from './themeColor'
|
||||
|
||||
const ROOT = resolve(dirname(new URL(import.meta.url).pathname), '../..')
|
||||
const read = (rel: string): string => readFileSync(join(ROOT, rel), 'utf-8')
|
||||
|
|
@ -65,13 +66,12 @@ describe('页签图标与站内品牌同一张图', () => {
|
|||
it('页签那一枚就是主色底上的白色粗体 "OA",与侧边栏那颗磁贴同一套', () => {
|
||||
const svg = read('public/favicon.svg')
|
||||
expect(svg).toContain('>OA</text>')
|
||||
// 底色跟着 tailwind 的 primary 走:改了主色没重生成图标,这里会红
|
||||
const tailwind = read('tailwind.config.js')
|
||||
const primary = tailwind.match(/primary:\s*\{([\s\S]*?)\}/)?.[1] ?? ''
|
||||
for (const shade of ['500', '700']) {
|
||||
const hex = primary.match(new RegExp(`${shade}:\\s*'(#[0-9a-f]{6})'`))?.[1]
|
||||
expect(hex, `tailwind.config.js 里 primary-${shade} 找不到了`).toBeTruthy()
|
||||
expect(svg, `图标还是旧主色,跑一次 python3 scripts/gen-icons.py`).toContain(hex)
|
||||
// 底色跟着默认那一档主色走:改了 style.css 的色板没重生成图标,这里会红。
|
||||
// 换成别的档时由 utils/themeColor.ts 在运行时现画一枚,静态文件只保证默认档这一份对得上。
|
||||
for (const shade of [500, 700] as const) {
|
||||
const [r, g, b] = DEFAULT_ACCENT_RGB[shade]
|
||||
const hex = `#${[r, g, b].map((n) => n.toString(16).padStart(2, '0')).join('')}`
|
||||
expect(svg, `public/favicon.svg 还是旧主色 ${hex},跑一次 python3 scripts/gen-icons.py`).toContain(hex)
|
||||
}
|
||||
// 磁贴那一边:还是那颗 teal 底白字的 "OA",字形换了同样得重生成图标
|
||||
const sidebar = read('src/components/layout/AppSidebar.vue')
|
||||
|
|
|
|||
|
|
@ -0,0 +1,216 @@
|
|||
// @vitest-environment jsdom
|
||||
/**
|
||||
* 主题色这一档该干的三件事:认档、画档、记住档。
|
||||
*
|
||||
* 钉法是照着「换色到底换了什么」来的:整套界面读的是 <html data-accent>,
|
||||
* 所以只要属性没写上、或者写上了个认不出的值,界面就会静默退回默认青——
|
||||
* 这两条都在这里钉住,免得以后加了新一档忘了在 style.css 补色板时没人拦。
|
||||
*/
|
||||
import { readFileSync, existsSync } from 'node:fs'
|
||||
import { dirname, join, resolve } from 'node:path'
|
||||
import { beforeEach, describe, expect, it } from 'vitest'
|
||||
import { DEFAULT_FAVICON } from './branding'
|
||||
import {
|
||||
ACCENT_ATTR,
|
||||
ACCENT_KEY,
|
||||
ACCENT_OPTIONS,
|
||||
DEFAULT_ACCENT,
|
||||
DEFAULT_ACCENT_RGB,
|
||||
accent,
|
||||
accentColor,
|
||||
accentDot,
|
||||
accentRgb,
|
||||
accentRgba,
|
||||
applyAccent,
|
||||
isAccentId,
|
||||
setAccentLocal,
|
||||
storedAccent,
|
||||
type AccentShade
|
||||
} from './themeColor'
|
||||
|
||||
const ROOT = resolve(dirname(new URL(import.meta.url).pathname), '../..')
|
||||
const SHADES: AccentShade[] = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950]
|
||||
|
||||
/**
|
||||
* 从 style.css 里把六套色板原样抠出来(``:root`` 那一套算默认档)。
|
||||
* 不在测试里另抄一份色值,否则改了 CSS 忘了改测试,这份测试就白写了。
|
||||
*/
|
||||
function palettesFromCss(): Map<string, Record<AccentShade, [number, number, number]>> {
|
||||
// 注释先洗掉:选择器前面那些中文说明会跟着选择器一起被抠出来
|
||||
const css = readFileSync(join(ROOT, 'src', 'style.css'), 'utf-8').replace(/\/\*[\s\S]*?\*\//g, '')
|
||||
const out = new Map<string, Record<AccentShade, [number, number, number]>>()
|
||||
for (const block of css.matchAll(/([^{}]+)\{([^{}]*)\}/g)) {
|
||||
const selector = block[1].trim().split('\n').pop()!.trim()
|
||||
const body = block[2]
|
||||
if (!/--primary-50\s*:/.test(body)) continue
|
||||
const id = selector === ':root' ? DEFAULT_ACCENT : selector.match(/data-accent=['"]([\w-]+)['"]/)?.[1]
|
||||
if (!id) continue
|
||||
const ramp = {} as Record<AccentShade, [number, number, number]>
|
||||
for (const shade of body.matchAll(/--primary-(\d+):\s*([\d.\s]+);/g)) {
|
||||
ramp[Number(shade[1]) as AccentShade] = shade[2].trim().split(/\s+/).map(Number) as [
|
||||
number,
|
||||
number,
|
||||
number
|
||||
]
|
||||
}
|
||||
out.set(id, ramp)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
const PALETTES = palettesFromCss()
|
||||
const hex = (rgb: [number, number, number]): string =>
|
||||
`#${rgb.map((n) => n.toString(16).padStart(2, '0')).join('')}`
|
||||
|
||||
beforeEach(() => {
|
||||
localStorage.clear()
|
||||
document.documentElement.removeAttribute(ACCENT_ATTR)
|
||||
})
|
||||
|
||||
describe('主题色:认档', () => {
|
||||
it('认得了的档位与色板一一对应(style.css 里少一套就会静默退回默认青)', () => {
|
||||
expect(ACCENT_OPTIONS.map((option) => option.id)).toEqual([
|
||||
'teal',
|
||||
'blue',
|
||||
'indigo',
|
||||
'violet',
|
||||
'rose',
|
||||
'amber'
|
||||
])
|
||||
// 每档都得有名字和画圆点用的色值,缺一个界面上就是一颗没标签的透明点
|
||||
ACCENT_OPTIONS.forEach((option) => {
|
||||
expect(option.nameKey).toMatch(/^mobile\.accent/)
|
||||
expect(option.dot).toMatch(/^#[0-9a-f]{6}$/i)
|
||||
})
|
||||
})
|
||||
|
||||
it('没存过、存了个认不出的值,都回到默认那一档', () => {
|
||||
expect(storedAccent()).toBe(DEFAULT_ACCENT)
|
||||
localStorage.setItem(ACCENT_KEY, 'chartreuse')
|
||||
expect(storedAccent()).toBe(DEFAULT_ACCENT)
|
||||
expect(isAccentId('chartreuse')).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('主题色:画档与记档', () => {
|
||||
it('点一档就写上属性并留在本地,下次进来还是这一档', () => {
|
||||
setAccentLocal('blue')
|
||||
expect(document.documentElement.getAttribute(ACCENT_ATTR)).toBe('blue')
|
||||
expect(localStorage.getItem(ACCENT_KEY)).toBe('blue')
|
||||
expect(accent.value).toBe('blue')
|
||||
expect(storedAccent()).toBe('blue')
|
||||
})
|
||||
|
||||
it('默认档也照样写属性:界面上要看得出当前用的是哪一套', () => {
|
||||
setAccentLocal('blue')
|
||||
setAccentLocal(DEFAULT_ACCENT)
|
||||
expect(document.documentElement.getAttribute(ACCENT_ATTR)).toBe('teal')
|
||||
})
|
||||
|
||||
it('认不出的档位不动画面也不写本地(别让脏值把人家的颜色换了)', () => {
|
||||
applyAccent('blue')
|
||||
setAccentLocal('not-a-color' as never)
|
||||
expect(document.documentElement.getAttribute(ACCENT_ATTR)).toBe('blue')
|
||||
expect(localStorage.getItem(ACCENT_KEY)).toBeNull()
|
||||
})
|
||||
|
||||
it('PWA 状态栏那条颜色跟着这一档走', () => {
|
||||
const meta = document.createElement('meta')
|
||||
meta.setAttribute('name', 'theme-color')
|
||||
document.head.appendChild(meta)
|
||||
setAccentLocal('rose')
|
||||
expect(meta.getAttribute('content')).toBe(accentDot('rose'))
|
||||
meta.remove()
|
||||
})
|
||||
})
|
||||
|
||||
describe('主题色:色板只有 style.css 那一本账', () => {
|
||||
it('CSS 里的色板与可挑的档位一一对应,谁多谁少都会红', () => {
|
||||
expect(PALETTES.size).toBeGreaterThan(0)
|
||||
expect([...PALETTES.keys()].sort()).toEqual([...ACCENT_OPTIONS.map((o) => o.id)].sort())
|
||||
})
|
||||
|
||||
it('每套色板十一档齐、都在 0~255 之间(少一档就是某个组件静默掉色)', () => {
|
||||
for (const [id, ramp] of PALETTES) {
|
||||
expect(SHADES.every((shade) => Array.isArray(ramp[shade])), id).toBe(true)
|
||||
for (const shade of SHADES) {
|
||||
for (const channel of ramp[shade]) {
|
||||
expect(Number.isInteger(channel) && channel >= 0 && channel <= 255, `${id}-${shade}`).toBe(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
it('选择器上那颗圆点就是该档 600:色块与实际按钮必须同色', () => {
|
||||
for (const option of ACCENT_OPTIONS) {
|
||||
expect(accentDot(option.id).toLowerCase()).toBe(hex(PALETTES.get(option.id)![600]))
|
||||
}
|
||||
})
|
||||
|
||||
// 这一条兜的是"JS 里那份兜底副本会不会走样":它只该在样式表还没到时用一次,
|
||||
// 用的必须是默认那一档,改 CSS 忘了改这里,这里当场报。
|
||||
it('读不到样式表时的兜底副本,就是 CSS 里默认那一档', () => {
|
||||
expect(DEFAULT_ACCENT_RGB).toEqual(PALETTES.get(DEFAULT_ACCENT))
|
||||
})
|
||||
})
|
||||
|
||||
describe('主题色:给 canvas 与页签图标要色值', () => {
|
||||
// 把真色板挂进当前文档,然后逐档逐色核对:JS 问到的必须就是 CSS 画出来的
|
||||
beforeEach(() => {
|
||||
document.head.innerHTML =
|
||||
`<style>${[...PALETTES.entries()]
|
||||
.map(
|
||||
([id, ramp]) =>
|
||||
`${id === DEFAULT_ACCENT ? ':root' : `html[data-accent='${id}']`}{${SHADES.map(
|
||||
(shade) => `--primary-${shade}:${ramp[shade].join(' ')}`,
|
||||
).join(';')}}`,
|
||||
)
|
||||
.join('')}</style><link rel="icon" type="image/svg+xml" href="${DEFAULT_FAVICON}" />`
|
||||
setAccentLocal(DEFAULT_ACCENT)
|
||||
})
|
||||
|
||||
it('accentRgb()/accentColor()/accentRgba() 现问现答,六套十一档全对上', () => {
|
||||
for (const option of ACCENT_OPTIONS) {
|
||||
applyAccent(option.id)
|
||||
const ramp = PALETTES.get(option.id)!
|
||||
for (const shade of SHADES) {
|
||||
expect(accentRgb(shade), `${option.id}-${shade}`).toEqual(ramp[shade])
|
||||
expect(accentColor(shade), `${option.id}-${shade}`).toBe(hex(ramp[shade]))
|
||||
}
|
||||
expect(accentRgba(600, 0.18)).toBe(`rgba(${ramp[600].join(', ')}, 0.18)`)
|
||||
}
|
||||
})
|
||||
|
||||
it('换档之后色值立刻跟着变(图表、逐行兜底都靠这一条实时改色)', () => {
|
||||
setAccentLocal('rose')
|
||||
const rose = accentColor(600)
|
||||
setAccentLocal('amber')
|
||||
expect(accentColor(600)).not.toBe(rose)
|
||||
expect(accentColor(600)).toBe(hex(PALETTES.get('amber')![600]))
|
||||
})
|
||||
|
||||
it('样式表还没加载时不写脏缓存:下一帧读到了就用真的', () => {
|
||||
document.head.innerHTML = ''
|
||||
setAccentLocal('blue')
|
||||
expect(accentColor(600)).toBe(hex(DEFAULT_ACCENT_RGB[600]))
|
||||
document.head.innerHTML = `<style>html[data-accent='blue']{--primary-600:1 2 3}</style>`
|
||||
expect(accentColor(600)).toBe('#010203')
|
||||
})
|
||||
|
||||
it('页签上那枚内置图标重画成当前这一档', () => {
|
||||
setAccentLocal('rose')
|
||||
const link = document.querySelector<HTMLLinkElement>("link[rel~='icon']")!
|
||||
const svg = decodeURIComponent(link.getAttribute('href')!)
|
||||
expect(link.getAttribute('href')).toMatch(/^data:image\/svg\+xml,/)
|
||||
expect(svg).toContain(`stop-color="${hex(PALETTES.get('rose')![400])}"`)
|
||||
expect(svg).toContain(`stop-color="${hex(PALETTES.get('rose')![700])}"`)
|
||||
})
|
||||
|
||||
it('没换色就不动页签,配过自己的 logo 也不抢', () => {
|
||||
const link = document.querySelector<HTMLLinkElement>("link[rel~='icon']")!
|
||||
expect(link.getAttribute('href')).toBe(DEFAULT_FAVICON)
|
||||
link.setAttribute('href', '/my-logo.png')
|
||||
setAccentLocal('violet')
|
||||
expect(link.getAttribute('href')).toBe('/my-logo.png')
|
||||
})
|
||||
})
|
||||
|
|
@ -0,0 +1,225 @@
|
|||
/**
|
||||
* 主题色("整体颜色"):整套界面的主色只有 style.css 里那十一组 ``--primary-*``,
|
||||
* 换主题色 = 换 ``<html data-accent="…">`` 这一个属性,色板本身不在 JS 里再抄一遍。
|
||||
*
|
||||
* 为什么色板写在 CSS 而 JS 只带 id:首屏 index.html 那一笔必须在下 Vue 之前就画对颜色,
|
||||
* 那边能跑的只有几行 ES5,把六套色板复制过去等于埋一份会走样的第二本账;
|
||||
* 属性名则天生自带兜底——没写、写错、样式表还没下载,落到的都是 :root 那一套默认青。
|
||||
*
|
||||
* 但有一类地方 CSS 变量到不了:Chart.js 画在 canvas 上、页签那枚图标是另一份 SVG,
|
||||
* 它们要的是**具体色值**。所以文件末尾有 accentColor()/accentRgba()——它们不抄色板,
|
||||
* 而是回头问浏览器「现在 <html> 上那一条规则把 --primary-600 算成了什么」,
|
||||
* 账本仍然只有一本。唯一抄下来的一份是默认那档(FALLBACK_RGB),
|
||||
* 用在样式表还没加载、以及单测这类读不到样式的地方,由 themeColor.spec.ts 钉住它对齐 style.css。
|
||||
*
|
||||
* 与深色档、字号同一套规矩(见 utils/appearance.ts):本地存一份能立刻生效的缓存,
|
||||
* 库里 ``users.preferences.color`` 才是权威那一份,登录之后由它覆盖回来,
|
||||
* 换设备、清缓存、从企业微信换个入口进来都还是自己调好的那一版颜色。
|
||||
*/
|
||||
import { ref } from 'vue'
|
||||
import { DEFAULT_FAVICON } from './branding'
|
||||
|
||||
export type AccentId = 'teal' | 'blue' | 'indigo' | 'violet' | 'rose' | 'amber'
|
||||
|
||||
/** 本地缓存的键,以及挂在 ``<html>`` 上那个属性名。 */
|
||||
export const ACCENT_KEY = 'oa.accent'
|
||||
export const ACCENT_ATTR = 'data-accent'
|
||||
/** 没设过 / 认不出时用的那一档,与 style.css 里 ``:root`` 那一份一致。 */
|
||||
export const DEFAULT_ACCENT: AccentId = 'teal'
|
||||
|
||||
export interface AccentOption {
|
||||
id: AccentId
|
||||
/** 界面上的名字(i18n 里 mobile.accentXxx) */
|
||||
nameKey: string
|
||||
/** 色板上那颗圆点,同时也是 PWA 状态栏那条的颜色:取各自的 600 档,与按钮实际用的同色 */
|
||||
dot: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 可挑的几套。色值本身以 style.css 为准,这里两份副本是有用途的:
|
||||
* ``dot`` 要脱离当前色板画别的颜色的圆点,只能自己带一个数。
|
||||
*/
|
||||
export const ACCENT_OPTIONS: AccentOption[] = [
|
||||
{ id: 'teal', nameKey: 'mobile.accentTeal', dot: '#0d9488' },
|
||||
{ id: 'blue', nameKey: 'mobile.accentBlue', dot: '#2f74e6' },
|
||||
{ id: 'indigo', nameKey: 'mobile.accentIndigo', dot: '#4f46e5' },
|
||||
{ id: 'violet', nameKey: 'mobile.accentViolet', dot: '#7c3aed' },
|
||||
{ id: 'rose', nameKey: 'mobile.accentRose', dot: '#e11d48' },
|
||||
{ id: 'amber', nameKey: 'mobile.accentAmber', dot: '#d97706' }
|
||||
]
|
||||
|
||||
export const ACCENTS: AccentId[] = ACCENT_OPTIONS.map((option) => option.id)
|
||||
|
||||
/** 这一档名字认不认:库里、地址上、别人提交来的字符串都先过这一关。 */
|
||||
export function isAccentId(value: string): value is AccentId {
|
||||
return (ACCENTS as string[]).includes(value)
|
||||
}
|
||||
|
||||
function read(): string {
|
||||
try {
|
||||
return window.localStorage.getItem(ACCENT_KEY) ?? ''
|
||||
} catch {
|
||||
// 无痕模式里 localStorage 会抛:照默认那一套画就是,不该连带整块界面起不来
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
function write(value: string | null): void {
|
||||
try {
|
||||
if (value === null) window.localStorage.removeItem(ACCENT_KEY)
|
||||
else window.localStorage.setItem(ACCENT_KEY, value)
|
||||
} catch {
|
||||
/* 写不进去只是下次进来回默认,不影响这一次的使用 */
|
||||
}
|
||||
}
|
||||
|
||||
/** 本地缓存的那一档;没存过或存了个认不出的值都回到默认青。 */
|
||||
export function storedAccent(): AccentId {
|
||||
const value = read()
|
||||
return isAccentId(value) ? value : DEFAULT_ACCENT
|
||||
}
|
||||
|
||||
/**
|
||||
* 把某一档真正画出去:换 <html> 上的属性,顺手把 PWA 状态栏与页签图标都对上。
|
||||
* 默认档照样写属性(不靠"删掉属性退回 :root"),这样在界面上看得见当前是哪一套。
|
||||
*/
|
||||
export function applyAccent(id: AccentId): void {
|
||||
if (typeof document === 'undefined') return
|
||||
document.documentElement.setAttribute(ACCENT_ATTR, id)
|
||||
// 换档之后画面上读到的色值就变了,之前问过的那一色板一律作废
|
||||
rampCache = new Map()
|
||||
const dot = ACCENT_OPTIONS.find((option) => option.id === id)?.dot
|
||||
const meta = document.querySelector<HTMLMetaElement>('meta[name="theme-color"]')
|
||||
if (dot && meta) meta.setAttribute('content', dot)
|
||||
applyAccentFavicon()
|
||||
}
|
||||
|
||||
/** 当前这一档主题色。初值取本地缓存——index.html 已经照它把属性写好了。 */
|
||||
export const accent = ref<AccentId>(storedAccent())
|
||||
|
||||
/** 只改本地 + 画面,不碰接口:首屏那条路径与没登录时走这一条。 */
|
||||
export function setAccentLocal(id: AccentId): void {
|
||||
if (!isAccentId(id)) return
|
||||
accent.value = id
|
||||
write(id)
|
||||
applyAccent(id)
|
||||
}
|
||||
|
||||
/** 界面问「这一档是什么颜色」时用它画圆点,别让调用方自己记色值。 */
|
||||
export function accentDot(id: AccentId): string {
|
||||
return ACCENT_OPTIONS.find((option) => option.id === id)?.dot || ''
|
||||
}
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* 给"拿不到 CSS 变量"的地方用:canvas、页签图标、以及数据没配颜色时的兜底。
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
/** 色板上的十一档,与 style.css 里的 ``--primary-N`` 同名。 */
|
||||
export type AccentShade = 50 | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 950
|
||||
|
||||
/**
|
||||
* 默认那一档的色板副本:只在读不到 style.css 时兜底(样式表还没下载、jsdom、
|
||||
* 以及单测里那种没有样式的场景)。它会不会走样由 themeColor.spec.ts 对着
|
||||
* style.css 的 :root 逐档比,改 CSS 忘了改这里就会红。
|
||||
*/
|
||||
export const DEFAULT_ACCENT_RGB: Record<AccentShade, [number, number, number]> = {
|
||||
50: [240, 253, 250],
|
||||
100: [204, 251, 241],
|
||||
200: [153, 246, 228],
|
||||
300: [94, 234, 212],
|
||||
400: [45, 212, 191],
|
||||
500: [20, 184, 166],
|
||||
600: [13, 148, 136],
|
||||
700: [15, 118, 110],
|
||||
800: [17, 94, 89],
|
||||
900: [19, 78, 74],
|
||||
950: [4, 47, 46]
|
||||
}
|
||||
|
||||
/** 已经问到的色值:一趟渲染里同一个色号会被问很多次(列表逐行兜底),别每次都去问浏览器。 */
|
||||
let rampCache = new Map<AccentShade, [number, number, number]>()
|
||||
|
||||
function clampByte(value: number): number {
|
||||
return Math.min(255, Math.max(0, Math.round(value)))
|
||||
}
|
||||
|
||||
/** ``--primary-600`` 在画面上算出来到底是哪三个数:``"13 148 136"`` → [13,148,136]。 */
|
||||
function readShadeRgb(shade: AccentShade): [number, number, number] | null {
|
||||
if (typeof document === 'undefined' || typeof getComputedStyle !== 'function') return null
|
||||
const raw = getComputedStyle(document.documentElement).getPropertyValue(`--primary-${shade}`)
|
||||
// 色板写的是裸三元组,写成 rgb(...) 或逗号分隔也不算读错,一并认了
|
||||
const parts = raw.trim().split(/[\s,/]+/).map(Number)
|
||||
if (parts.length < 3) return null
|
||||
const [r, g, b] = parts
|
||||
if (![r, g, b].every((n) => Number.isFinite(n))) return null
|
||||
return [clampByte(r), clampByte(g), clampByte(b)]
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前这一档某一色的 RGB。读得到就以 style.css 为准,读不到才落到副本上——
|
||||
* 后者不写进缓存,样式表下载完下一帧自然就读对了。
|
||||
*/
|
||||
export function accentRgb(shade: AccentShade = 600): [number, number, number] {
|
||||
// 这一句不是多余的:色值本身没有响应性,读了 accent 这一档,
|
||||
// 调用方那些 computed 与模板才会跟着换档重算,图表才会在换色的那一刻当场改颜色。
|
||||
void accent.value
|
||||
const cached = rampCache.get(shade)
|
||||
if (cached) return cached
|
||||
const rgb = readShadeRgb(shade)
|
||||
if (!rgb) return DEFAULT_ACCENT_RGB[shade] ?? DEFAULT_ACCENT_RGB[600]
|
||||
rampCache.set(shade, rgb)
|
||||
return rgb
|
||||
}
|
||||
|
||||
/** 当前这一档某一色的 #rrggbb:给 canvas、SVG、以及"这条数据没配颜色"的兜底用。 */
|
||||
export function accentColor(shade: AccentShade = 600): string {
|
||||
const [r, g, b] = accentRgb(shade)
|
||||
return `#${[r, g, b].map((n) => n.toString(16).padStart(2, '0')).join('')}`
|
||||
}
|
||||
|
||||
/** 同一色的半透明版(图表面积、色块底纹那一类)。 */
|
||||
export function accentRgba(shade: AccentShade, alpha: number): string {
|
||||
const [r, g, b] = accentRgb(shade)
|
||||
return `rgba(${r}, ${g}, ${b}, ${alpha})`
|
||||
}
|
||||
|
||||
/** 是不是本模块自己生成的那枚图标(换档时要在两枚内置图之间来回切)。 */
|
||||
function isGeneratedIcon(href: string): boolean {
|
||||
return href.startsWith('data:image/svg+xml,')
|
||||
}
|
||||
|
||||
/** 内置那枚 "OA" 磁贴照着当前这一档重画:渐变 400 → 700,与 public/favicon.svg 同一份形状。 */
|
||||
function accentFaviconDataUri(): string {
|
||||
const svg =
|
||||
'<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 512 512">' +
|
||||
'<defs><linearGradient id="oa-tile" x1="0" y1="0" x2="512" y2="512" gradientUnits="userSpaceOnUse">' +
|
||||
`<stop offset="0" stop-color="${accentColor(400)}"/><stop offset="1" stop-color="${accentColor(700)}"/>` +
|
||||
'</linearGradient></defs>' +
|
||||
'<rect width="512" height="512" rx="171" fill="url(#oa-tile)"/>' +
|
||||
'<text x="256" y="336" fill="#ffffff" font-size="215" font-weight="700" ' +
|
||||
'font-family="Arial, \'Helvetica Neue\', Helvetica, sans-serif" text-anchor="middle" ' +
|
||||
'text-rendering="geometricPrecision">OA</text></svg>'
|
||||
return `data:image/svg+xml,${encodeURIComponent(svg)}`
|
||||
}
|
||||
|
||||
/**
|
||||
* 页签上那一枚也跟着换色:界面全蓝、页签还是青,是这一轮最扎眼的一处不一致。
|
||||
*
|
||||
* 只动内置那一张图。管理员在「站点信息」里配过自己的 logo 时,href 已经是别的地址,
|
||||
* 让开——那是他明确指定的东西,不是一档主题色。默认档直接把地址还给 /favicon.svg,
|
||||
* 这样没换过色的人一行代码都没多跑。
|
||||
*/
|
||||
function applyAccentFavicon(): void {
|
||||
const link = document.querySelector<HTMLLinkElement>("link[rel~='icon']:not([rel~='alternate'])")
|
||||
if (!link) return
|
||||
const href = link.getAttribute('href') ?? ''
|
||||
if (href && href !== DEFAULT_FAVICON && !isGeneratedIcon(href)) return
|
||||
const next = accent.value === DEFAULT_ACCENT ? DEFAULT_FAVICON : accentFaviconDataUri()
|
||||
if (href === next) return
|
||||
link.href = next
|
||||
link.setAttribute('type', 'image/svg+xml')
|
||||
}
|
||||
|
||||
/** 模块加载即生效:登录页也该带着自己那一份颜色,不该等进主界面才换。 */
|
||||
applyAccent(accent.value)
|
||||
|
|
@ -1,18 +1,13 @@
|
|||
<template>
|
||||
<AuthLayout>
|
||||
<!-- 宽屏时这块品牌区挪到 AuthLayout 左边那一栏,卡片里就只留登录本身 -->
|
||||
<div class="mb-8 text-center lg:hidden">
|
||||
<div
|
||||
class="mx-auto flex h-14 w-14 items-center justify-center rounded-2xl bg-primary-600 text-lg font-bold text-white shadow-glow"
|
||||
>
|
||||
OA
|
||||
</div>
|
||||
<h1 class="mt-5 text-2xl font-bold text-gray-900 dark:text-white">{{ t('auth.loginTitle') }}</h1>
|
||||
<p class="mt-2 text-sm text-gray-500 dark:text-dark-400">{{ t('auth.loginSubtitle') }}</p>
|
||||
</div>
|
||||
<!-- 这一屏的标题与说明(品牌标识与底下那行版权在 AuthLayout 那一层) -->
|
||||
<h2 class="text-[28px] font-bold leading-9 tracking-tight text-gray-900 dark:text-white">
|
||||
{{ t('auth.welcome') }}
|
||||
</h2>
|
||||
<p class="mt-2 text-[15px] leading-6 text-gray-500 dark:text-dark-400">{{ t('auth.loginSubtitle') }}</p>
|
||||
|
||||
<!-- 只允许统一门户免登:本系统不再收账号密码,这一屏要么正在跳,要么留两颗按钮 -->
|
||||
<div v-if="deciding || ssoOnly" class="card p-6 text-center sm:p-8">
|
||||
<!-- 只允许统一门户免登:本系统不再收账号密码,这一屏要么正在跳,要么留一颗回门户的钮 -->
|
||||
<div v-if="deciding || ssoOnly" class="mt-10 text-center">
|
||||
<template v-if="deciding || jumping">
|
||||
<Icon name="refresh" class="mx-auto h-8 w-8 animate-spin text-primary-600" />
|
||||
<p v-if="jumping" class="mt-4 text-sm leading-6 text-gray-600 dark:text-dark-200">{{ t('auth.ssoJumping') }}</p>
|
||||
|
|
@ -21,18 +16,19 @@
|
|||
<template v-else>
|
||||
<Icon name="shield" class="mx-auto h-8 w-8 text-primary-600" />
|
||||
<p class="mt-4 text-sm leading-6 text-gray-600 dark:text-dark-200">{{ t('auth.ssoEntryHint') }}</p>
|
||||
<button type="button" class="btn btn-primary mt-6 w-full" @click="toPortal">
|
||||
<Icon name="externalLink" class="mr-1 h-4 w-4" />
|
||||
<button type="button" class="login-submit mt-8" @click="toPortal">
|
||||
<Icon name="externalLink" class="h-4 w-4" />
|
||||
{{ t('auth.ssoEnter') }}
|
||||
</button>
|
||||
<p v-if="portalUrl" class="mt-4 text-xs text-gray-400">{{ t('auth.ssoAutoJump') }}</p>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<form v-else class="card p-6 sm:p-8" @submit.prevent="submit">
|
||||
<form v-else class="login-form mt-8 space-y-4" @submit.prevent="submit">
|
||||
<Input
|
||||
v-model="account"
|
||||
:label="t('auth.account')"
|
||||
hide-label
|
||||
:placeholder="t('auth.accountPlaceholder')"
|
||||
:error="accountError"
|
||||
autocomplete="username"
|
||||
|
|
@ -42,74 +38,94 @@
|
|||
</template>
|
||||
</Input>
|
||||
|
||||
<div class="mt-4">
|
||||
<Input
|
||||
v-model="password"
|
||||
type="password"
|
||||
:label="t('auth.password')"
|
||||
:placeholder="t('auth.passwordPlaceholder')"
|
||||
:error="passwordError"
|
||||
autocomplete="current-password"
|
||||
>
|
||||
<template #prefix>
|
||||
<Icon name="lock" class="h-4 w-4" />
|
||||
</template>
|
||||
</Input>
|
||||
</div>
|
||||
<Input
|
||||
v-model="password"
|
||||
type="password"
|
||||
:label="t('auth.password')"
|
||||
hide-label
|
||||
:placeholder="t('auth.passwordPlaceholder')"
|
||||
:error="passwordError"
|
||||
autocomplete="current-password"
|
||||
>
|
||||
<template #prefix>
|
||||
<Icon name="lock" class="h-4 w-4" />
|
||||
</template>
|
||||
</Input>
|
||||
|
||||
<div v-if="captchaVisible" class="mt-4">
|
||||
<div class="flex items-end gap-2">
|
||||
<div class="min-w-0 flex-1">
|
||||
<Input
|
||||
v-model="captchaAnswer"
|
||||
:label="t('auth.captcha')"
|
||||
:placeholder="t('auth.captchaPlaceholder')"
|
||||
:error="captchaError"
|
||||
autocomplete="one-time-code"
|
||||
@enter="submit"
|
||||
>
|
||||
<template #prefix>
|
||||
<Icon name="shield" class="h-4 w-4" />
|
||||
</template>
|
||||
</Input>
|
||||
</div>
|
||||
<!-- 验证码仍留在输入框右边,只是把格子加宽、去掉上下内边距,让图等比铺满:
|
||||
原先这张图被 flex 挤成 67×20,现在桌面 130×39、手机 106×32,够看清也不额外占版面。
|
||||
底色恒定白:Hub 的验证码图带透明背景,深色模式下深字会贴脸消失 -->
|
||||
<button
|
||||
type="button"
|
||||
class="input flex h-[42px] w-[132px] flex-shrink-0 items-center justify-center overflow-hidden !bg-white !px-3 !py-0 text-center sm:w-[156px]"
|
||||
:title="t('auth.captchaRefresh')"
|
||||
@click="loadCaptcha"
|
||||
<div v-if="captchaVisible" class="flex items-end gap-2">
|
||||
<div class="min-w-0 flex-1">
|
||||
<Input
|
||||
v-model="captchaAnswer"
|
||||
:label="t('auth.captcha')"
|
||||
hide-label
|
||||
:placeholder="t('auth.captchaPlaceholder')"
|
||||
:error="captchaError"
|
||||
autocomplete="one-time-code"
|
||||
@enter="submit"
|
||||
>
|
||||
<img
|
||||
v-if="captchaImage"
|
||||
:src="captchaImage"
|
||||
:alt="t('auth.captcha')"
|
||||
draggable="false"
|
||||
class="h-full max-h-full w-full max-w-full object-contain"
|
||||
/>
|
||||
<span v-else class="select-none break-all font-mono text-sm font-semibold text-gray-800">
|
||||
{{ captchaQuestion || t('auth.captchaRefresh') }}
|
||||
</span>
|
||||
</button>
|
||||
<template #prefix>
|
||||
<Icon name="shield" class="h-4 w-4" />
|
||||
</template>
|
||||
</Input>
|
||||
</div>
|
||||
<!-- 验证码仍留在输入框右边,只是把格子加宽、去掉上下内边距,让图等比铺满:
|
||||
原先这张图被 flex 挤成 67×20,现在桌面 130×39、手机 106×32,够看清也不额外占版面。
|
||||
底色恒定白:Hub 的验证码图带透明背景,深色模式下深字会贴脸消失 -->
|
||||
<button
|
||||
type="button"
|
||||
class="flex h-12 w-[132px] flex-shrink-0 items-center justify-center overflow-hidden rounded-lg border border-gray-200 bg-white !px-3 !py-0 text-center dark:border-dark-600 sm:w-[156px]"
|
||||
:title="t('auth.captchaRefresh')"
|
||||
:aria-label="t('auth.captchaRefresh')"
|
||||
@click="loadCaptcha"
|
||||
>
|
||||
<img
|
||||
v-if="captchaImage"
|
||||
:src="captchaImage"
|
||||
:alt="t('auth.captcha')"
|
||||
draggable="false"
|
||||
class="h-full max-h-full w-full max-w-full object-contain"
|
||||
/>
|
||||
<span v-else class="select-none break-all font-mono text-sm font-semibold text-gray-800">
|
||||
{{ captchaQuestion || t('auth.captchaRefresh') }}
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary mt-6 w-full" :disabled="submitting">
|
||||
<Icon v-if="submitting" name="refresh" class="mr-1 h-4 w-4 animate-spin" />
|
||||
<Icon v-else name="login" class="mr-1 h-4 w-4" />
|
||||
<button type="submit" class="login-submit" :disabled="submitting">
|
||||
<Icon v-if="submitting" name="refresh" class="h-4 w-4 animate-spin" />
|
||||
<Icon v-else name="login" class="h-4 w-4" />
|
||||
{{ t('auth.loginBtn') }}
|
||||
</button>
|
||||
|
||||
<p class="mt-4 rounded-xl bg-gray-50 px-3 py-2 text-center text-xs text-gray-500 dark:bg-dark-900/60 dark:text-dark-400">
|
||||
<p class="rounded-xl bg-gray-50 px-3 py-2 text-center text-xs text-gray-500 dark:bg-dark-900/60 dark:text-dark-400">
|
||||
{{ emergencyOnly ? t('auth.ssoLocalOnlyHint') : t('auth.demoHint') }}
|
||||
</p>
|
||||
</form>
|
||||
|
||||
<div class="mt-6 flex items-center justify-center gap-3">
|
||||
<LocaleSwitcher />
|
||||
<p class="text-xs text-gray-400">{{ t('auth.copyright') }}</p>
|
||||
<!-- 第三方登录:抄统一门户那一版底下的「其他登录方式」。
|
||||
走的是本来就有的一条路(先让后端写 state,再整页跳门户),只是把它摆成一颗圆钮:
|
||||
免登开着的时候,这一屏除了本地口令还认得回门户这条路。 -->
|
||||
<div v-if="showAltLogin" class="login-alt">
|
||||
<div class="flex items-center gap-3">
|
||||
<span class="login-divider" aria-hidden="true"></span>
|
||||
<span class="text-xs text-gray-400 dark:text-dark-500">{{ t('auth.altLogin') }}</span>
|
||||
<span class="login-divider" aria-hidden="true"></span>
|
||||
</div>
|
||||
<div class="login-alt-group">
|
||||
<button
|
||||
type="button"
|
||||
class="login-alt-item"
|
||||
:title="t('auth.portalLoginHint', { app: siteName })"
|
||||
data-test="login-alt-portal"
|
||||
@click="toPortal"
|
||||
>
|
||||
<span class="login-alt-icon">
|
||||
<Icon name="globe" class="h-5 w-5" />
|
||||
</span>
|
||||
<span class="login-alt-label">{{ t('auth.portalLogin') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<p v-if="emergencyOnly" class="login-caption">{{ t('auth.portalCaption') }}</p>
|
||||
</div>
|
||||
</AuthLayout>
|
||||
</template>
|
||||
|
|
@ -121,7 +137,6 @@ import { useI18n } from 'vue-i18n'
|
|||
import AuthLayout from '@/components/layout/AuthLayout.vue'
|
||||
import Input from '@/components/common/Input.vue'
|
||||
import Icon from '@/components/icons/Icon.vue'
|
||||
import LocaleSwitcher from '@/components/common/LocaleSwitcher.vue'
|
||||
import { captcha as fetchCaptcha, ssoBegin, type LoginCaptcha } from '@/api/auth'
|
||||
import { autoJumpToPortal, canAutoJump, resetAutoJumpBudget } from '@/utils/ssoJump'
|
||||
import { leaveToPortal } from '@/utils/portal'
|
||||
|
|
@ -161,6 +176,9 @@ const portalUrl = computed(() => String(hub.value.portal_url || ''))
|
|||
const ssoOnly = computed(() => emergencyOnly.value && !forceLocal.value && !!portalUrl.value)
|
||||
// 已经把人送出去了:这一屏换成"正在跳转",别再闪一张没人填的表单
|
||||
const jumping = ref(false)
|
||||
// 「其他登录方式」那一排:只有问得出门户地址才画,而且免登那一屏自己已经有钮了,不重复摆
|
||||
const showAltLogin = computed(() => !!portalUrl.value && !ssoOnly.value && !deciding.value && !jumping.value)
|
||||
const siteName = computed(() => appStore.siteName || t('auth.loginTitle'))
|
||||
|
||||
const accountError = computed(() => (touched.value && !account.value.trim() ? t('auth.accountRequired') : ''))
|
||||
const passwordError = computed(() => (touched.value && !password.value ? t('auth.passwordRequired') : ''))
|
||||
|
|
|
|||
|
|
@ -16,18 +16,13 @@
|
|||
</div>
|
||||
|
||||
<AuthLayout v-else>
|
||||
<div class="mb-8 text-center">
|
||||
<div
|
||||
class="mx-auto flex h-14 w-14 items-center justify-center rounded-2xl bg-primary-600 text-lg font-bold text-white shadow-glow lg:hidden"
|
||||
>
|
||||
OA
|
||||
</div>
|
||||
<h1 class="mt-5 text-2xl font-bold text-gray-900 dark:text-white lg:hidden">{{ t('auth.loginTitle') }}</h1>
|
||||
<!-- 宽屏时品牌区在左边那一栏,这一句是这一页自己的状态说明,留着 -->
|
||||
<p class="mt-2 text-sm text-gray-500 dark:text-dark-400 lg:mt-0">{{ t('auth.ssoSubtitle') }}</p>
|
||||
</div>
|
||||
<!-- 品牌标识与底下那行版权都在 AuthLayout 那一层了,这里只留本页的状态说明 -->
|
||||
<h2 class="text-[28px] font-bold leading-9 tracking-tight text-gray-900 dark:text-white">
|
||||
{{ t('auth.ssoSubtitle') }}
|
||||
</h2>
|
||||
<p class="mt-2 text-[15px] leading-6 text-gray-500 dark:text-dark-400">{{ t('auth.portalAccountNote') }}</p>
|
||||
|
||||
<div class="card p-6 text-center sm:p-8">
|
||||
<div class="card mt-8 p-6 text-center sm:p-8">
|
||||
<Icon name="exclamationTriangle" class="mx-auto h-7 w-7 text-amber-500" />
|
||||
<p class="mt-4 text-sm font-medium text-gray-800 dark:text-dark-100">{{ message }}</p>
|
||||
<p class="mt-2 text-xs leading-5 text-gray-500 dark:text-dark-400">{{ t('auth.ssoRetryHint') }}</p>
|
||||
|
|
@ -46,11 +41,6 @@
|
|||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-6 flex items-center justify-center gap-3">
|
||||
<LocaleSwitcher />
|
||||
<p class="text-xs text-gray-400">{{ t('auth.copyright') }}</p>
|
||||
</div>
|
||||
</AuthLayout>
|
||||
</template>
|
||||
|
||||
|
|
@ -78,7 +68,6 @@ import { useRoute, useRouter } from 'vue-router'
|
|||
import { useI18n } from 'vue-i18n'
|
||||
import AuthLayout from '@/components/layout/AuthLayout.vue'
|
||||
import Icon from '@/components/icons/Icon.vue'
|
||||
import LocaleSwitcher from '@/components/common/LocaleSwitcher.vue'
|
||||
import { ssoBegin } from '@/api/auth'
|
||||
import { ssoErrorKey } from '@/views/auth/ssoErrors'
|
||||
import { leaveToPortal } from '@/utils/portal'
|
||||
|
|
|
|||
|
|
@ -110,6 +110,11 @@
|
|||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center gap-3 border-t border-gray-50 px-4 py-3 dark:border-dark-700/40">
|
||||
<Icon name="palette" class="h-[18px] w-[18px] flex-shrink-0 text-gray-500 dark:text-dark-400" />
|
||||
<span class="min-w-0 flex-1 truncate text-[14px] text-gray-900 dark:text-white">{{ t('mobile.themeColor') }}</span>
|
||||
<AccentColorPicker class="flex-shrink-0" test-prefix="m" />
|
||||
</div>
|
||||
<div class="flex items-center gap-3 border-t border-gray-50 px-4 py-3 dark:border-dark-700/40">
|
||||
<Icon name="globe" class="h-[18px] w-[18px] flex-shrink-0 text-gray-500 dark:text-dark-400" />
|
||||
<span class="min-w-0 flex-1 truncate text-[14px] text-gray-900 dark:text-white">{{ t('mobile.language') }}</span>
|
||||
|
|
@ -192,8 +197,8 @@
|
|||
</section>
|
||||
|
||||
<!-- 桌面上从前没有这一栏:皮肤只在顶栏那颗钮上切一下、字号压根没处调,
|
||||
而且两处都只写本机浏览器,换台电脑就又回到默认。这一栏把两件事摆齐,
|
||||
改完直接存进账号(utils/appearance + PUT /auth/me/preferences)。 -->
|
||||
而且两处都只写本机浏览器,换台电脑就又回到默认。这一栏把几件事摆齐,
|
||||
改完直接存进账号(utils/appearance、utils/themeColor + PUT /auth/me/preferences)。 -->
|
||||
<section class="card p-5" data-test="oa-appearance">
|
||||
<h3 class="mb-1 text-sm font-semibold text-gray-900 dark:text-white">{{ t('mobile.appearance') }}</h3>
|
||||
<p class="mb-3 text-xs text-gray-500 dark:text-dark-400">{{ t('mobile.appearanceHint') }}</p>
|
||||
|
|
@ -239,6 +244,10 @@
|
|||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<p class="input-label">{{ t('mobile.themeColor') }}</p>
|
||||
<AccentColorPicker test-prefix="oa" />
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
|
@ -277,6 +286,7 @@ import { useI18n } from 'vue-i18n'
|
|||
import Input from '@/components/common/Input.vue'
|
||||
import Icon from '@/components/icons/Icon.vue'
|
||||
import LocaleSwitcher from '@/components/common/LocaleSwitcher.vue'
|
||||
import AccentColorPicker from '@/components/common/AccentColorPicker.vue'
|
||||
import MobileNotificationSheet from '@/components/oa/mobile/MobileNotificationSheet.vue'
|
||||
import MobileSheet from '@/components/oa/mobile/MobileSheet.vue'
|
||||
import { authAPI } from '@/api'
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
<span
|
||||
class="flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-xl text-white"
|
||||
:style="{ backgroundColor: detail?.color || '#0d9488' }"
|
||||
:style="{ backgroundColor: detail?.color || accentColor(600) }"
|
||||
>
|
||||
<Icon :name="processIconName(detail?.icon || '')" class="h-5 w-5" />
|
||||
</span>
|
||||
|
|
@ -359,6 +359,7 @@ import { useStartForm } from '@/composables/useStartForm'
|
|||
import { useCloseTabOnLeave } from '@/composables/useCloseTabOnLeave'
|
||||
import { useAppStore } from '@/stores/app'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { accentColor } from '@/utils/themeColor'
|
||||
import type { EmbedActionRequest } from '@/utils/embedBridge'
|
||||
import { getStoredFormWide, processIconName, setStoredFormWide } from '@/utils/startPage'
|
||||
import { ccRuleBrief, ccRulesOfConfig } from '@/utils/flowCc'
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
>
|
||||
<span
|
||||
class="flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-xl text-white"
|
||||
:style="{ backgroundColor: process.color || '#0d9488' }"
|
||||
:style="{ backgroundColor: process.color || accentColor(600) }"
|
||||
>
|
||||
<Icon :name="processIconName(process.icon)" class="h-5 w-5" />
|
||||
</span>
|
||||
|
|
@ -73,6 +73,7 @@ import { useAppStore } from '@/stores/app'
|
|||
import { useAuthStore } from '@/stores/auth'
|
||||
import { startFormLocation, processIconName } from '@/utils/startPage'
|
||||
import { runAction } from '@/utils/oa'
|
||||
import { accentColor } from '@/utils/themeColor'
|
||||
import type { DraftItem, ProcessDef } from '@/types'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
|
|
|||
|
|
@ -101,6 +101,7 @@ import StatCard from '@/components/common/StatCard.vue'
|
|||
import Icon from '@/components/icons/Icon.vue'
|
||||
import { designAPI, supportAPI } from '@/api'
|
||||
import { runAction } from '@/utils/oa'
|
||||
import { accentColor, accentRgba } from '@/utils/themeColor'
|
||||
import type { OverviewStats, ProcessDef } from '@/types'
|
||||
import type { ProcessStatItem } from '@/api/support'
|
||||
|
||||
|
|
@ -150,8 +151,8 @@ const trendData = computed(() => ({
|
|||
datasets: [
|
||||
{
|
||||
data: (stats.value?.trend ?? []).map((item) => item.count),
|
||||
borderColor: '#0d9488',
|
||||
backgroundColor: 'rgba(13, 148, 136, 0.18)',
|
||||
borderColor: accentColor(600),
|
||||
backgroundColor: accentRgba(600, 0.18),
|
||||
fill: true,
|
||||
tension: 0.35,
|
||||
pointRadius: 3
|
||||
|
|
@ -162,7 +163,7 @@ const trendData = computed(() => ({
|
|||
function barData(items: { name: string; count: number }[]) {
|
||||
return {
|
||||
labels: items.map((item) => item.name),
|
||||
datasets: [{ data: items.map((item) => item.count), backgroundColor: '#14b8a6', borderRadius: 6, barThickness: 14 }]
|
||||
datasets: [{ data: items.map((item) => item.count), backgroundColor: accentColor(500), borderRadius: 6, barThickness: 14 }]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@
|
|||
>
|
||||
<span
|
||||
class="flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg text-white"
|
||||
:style="{ backgroundColor: process.color || '#0d9488' }"
|
||||
:style="{ backgroundColor: process.color || accentColor(600) }"
|
||||
>
|
||||
<Icon name="plus" class="h-4 w-4" />
|
||||
</span>
|
||||
|
|
@ -203,6 +203,7 @@ import { useAuthStore } from '@/stores/auth'
|
|||
import { formatRelativeTime } from '@/utils/format'
|
||||
import { runAction } from '@/utils/oa'
|
||||
import { startFormLocation } from '@/utils/startPage'
|
||||
import { accentColor } from '@/utils/themeColor'
|
||||
import type { NotificationItem, ProcessDef, TaskItem, WorkbenchStats } from '@/types'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
<div class="flex items-center gap-2.5">
|
||||
<span
|
||||
class="flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg text-white"
|
||||
:style="{ backgroundColor: row.color || '#0d9488' }"
|
||||
:style="{ backgroundColor: row.color || accentColor(600) }"
|
||||
>
|
||||
<Icon name="sync" class="h-4 w-4" />
|
||||
</span>
|
||||
|
|
@ -101,7 +101,7 @@
|
|||
<Select v-model="form.category" :options="categoryOptions" :placeholder="t('process.category')" />
|
||||
<TextArea v-model="form.description" :label="t('common.description')" :rows="3" />
|
||||
<div class="grid grid-cols-2 gap-3">
|
||||
<Input v-model="form.color" label="主题色" placeholder="#0d9488" />
|
||||
<Input v-model="form.color" label="主题色" :placeholder="accentColor(600)" />
|
||||
<Input v-model.number="form.order_number" type="number" :label="t('common.order')" />
|
||||
</div>
|
||||
<div class="flex items-center justify-between rounded-xl border border-gray-200 px-3 py-2.5 dark:border-dark-600">
|
||||
|
|
@ -165,6 +165,7 @@ import Select from '@/components/common/Select.vue'
|
|||
import SearchInput from '@/components/common/SearchInput.vue'
|
||||
import Toggle from '@/components/common/Toggle.vue'
|
||||
import Icon from '@/components/icons/Icon.vue'
|
||||
import { accentColor } from '@/utils/themeColor'
|
||||
import type { Column } from '@/components/common/types'
|
||||
import { designAPI } from '@/api'
|
||||
import { runAction } from '@/utils/oa'
|
||||
|
|
@ -190,7 +191,7 @@ const form = reactive({
|
|||
alias: '',
|
||||
description: '',
|
||||
category: '',
|
||||
color: '#0d9488',
|
||||
color: accentColor(600),
|
||||
order_number: 0,
|
||||
open_create: true,
|
||||
// 建流程这一刻定下的默认表单;空串 = 让后端现建一张起手表单
|
||||
|
|
@ -244,7 +245,7 @@ async function load() {
|
|||
|
||||
async function openCreate() {
|
||||
Object.assign(form, {
|
||||
name: '', alias: '', description: '', category: '', color: '#0d9488', order_number: 0, open_create: true, latest_form: ''
|
||||
name: '', alias: '', description: '', category: '', color: accentColor(600), order_number: 0, open_create: true, latest_form: ''
|
||||
})
|
||||
formMode.value = 'new'
|
||||
createShow.value = true
|
||||
|
|
|
|||
|
|
@ -185,6 +185,7 @@ import { formatBytes, formatDateTimeToMinute } from '@/utils/format'
|
|||
import { errorMessage, runAction } from '@/utils/oa'
|
||||
import { canPreview, previewHint } from '@/utils/preview'
|
||||
import { personText } from '@/utils/personLabel'
|
||||
import { accentColor } from '@/utils/themeColor'
|
||||
import type { Column } from '@/components/common/types'
|
||||
import type { PortalFile } from '@/types'
|
||||
|
||||
|
|
@ -231,7 +232,7 @@ const TINTS: Record<string, string> = {
|
|||
txt: '#64748b'
|
||||
}
|
||||
|
||||
const tint = (extension: string) => TINTS[extension?.toLowerCase()] ?? '#0d9488'
|
||||
const tint = (extension: string) => TINTS[extension?.toLowerCase()] ?? accentColor(600)
|
||||
|
||||
function setScope(value: string) {
|
||||
params.scope = value
|
||||
|
|
|
|||
|
|
@ -97,6 +97,11 @@ onMounted(load)
|
|||
.portal-hero {
|
||||
background:
|
||||
radial-gradient(circle at 88% -30%, rgba(255, 255, 255, 0.28), transparent 55%),
|
||||
linear-gradient(118deg, #0f766e 0%, #0d9488 45%, #115e59 100%);
|
||||
linear-gradient(
|
||||
118deg,
|
||||
rgb(var(--primary-700)) 0%,
|
||||
rgb(var(--primary-600)) 45%,
|
||||
rgb(var(--primary-800)) 100%
|
||||
);
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@
|
|||
</div>
|
||||
<ul v-else class="divide-y divide-gray-100 dark:divide-dark-700/60">
|
||||
<li v-for="item in items" :key="item.id" class="flex items-start gap-3 px-5 py-4">
|
||||
<span class="mt-1 h-9 w-1 flex-shrink-0 rounded-full" :style="{ backgroundColor: item.color || '#0d9488' }"></span>
|
||||
<span class="mt-1 h-9 w-1 flex-shrink-0 rounded-full" :style="{ backgroundColor: item.color || accentColor(600) }"></span>
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<p class="text-sm font-medium text-gray-900 dark:text-dark-100">{{ item.title }}</p>
|
||||
|
|
@ -162,12 +162,17 @@ import { useAuthStore } from '@/stores/auth'
|
|||
import { badgeClass, runAction } from '@/utils/oa'
|
||||
import { formatDateWithSystemLocale } from '@/utils/format'
|
||||
import { personText } from '@/utils/personLabel'
|
||||
import { accentColor } from '@/utils/themeColor'
|
||||
import type { ScheduleItem } from '@/types'
|
||||
|
||||
const { t } = useI18n()
|
||||
const authStore = useAuthStore()
|
||||
|
||||
const COLORS = ['#0d9488', '#2563eb', '#f59e0b', '#e11d48', '#7c3aed', '#0891b2', '#65a30d', '#db2777']
|
||||
/**
|
||||
* 新建日程那八颗色片。第一颗是当前主题色——默认值就该是界面此刻的颜色,
|
||||
* 不然整套都换成蓝的了,新建一条日程还是青的;后面七颗是固定分类色板。
|
||||
*/
|
||||
const PALETTE = ['#2563eb', '#f59e0b', '#e11d48', '#7c3aed', '#0891b2', '#65a30d', '#db2777']
|
||||
|
||||
const now = new Date()
|
||||
const todayKey = isoKey(now)
|
||||
|
|
@ -179,14 +184,14 @@ const loading = ref(false)
|
|||
const dialogShow = ref(false)
|
||||
const removing = ref<ScheduleItem | null>(null)
|
||||
const editing = ref('')
|
||||
const colors = COLORS
|
||||
const colors = computed(() => [accentColor(600), ...PALETTE])
|
||||
const form = reactive({
|
||||
title: '',
|
||||
content: '',
|
||||
location: '',
|
||||
start_time: '',
|
||||
end_time: '',
|
||||
color: COLORS[0],
|
||||
color: accentColor(600),
|
||||
all_day: false,
|
||||
remind: 0,
|
||||
shared_identities: [] as string[]
|
||||
|
|
@ -295,7 +300,7 @@ function openCreate() {
|
|||
location: '',
|
||||
start_time: base,
|
||||
end_time: `${selected.value}T10:00`,
|
||||
color: COLORS[0],
|
||||
color: accentColor(600),
|
||||
all_day: false,
|
||||
remind: 0,
|
||||
shared_identities: []
|
||||
|
|
@ -311,7 +316,7 @@ function edit(item: ScheduleItem) {
|
|||
location: item.location,
|
||||
start_time: (item.start_time ?? '').replace(' ', 'T').slice(0, 16),
|
||||
end_time: (item.end_time ?? '').replace(' ', 'T').slice(0, 16),
|
||||
color: item.color || COLORS[0],
|
||||
color: item.color || accentColor(600),
|
||||
all_day: item.all_day,
|
||||
remind: item.remind,
|
||||
shared_identities: [...(item.shared_identities ?? [])]
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
// 主色调改成运行时可换:色值本身住在 style.css 的 --primary-* 里(一套 RGB 三元组),
|
||||
// 这里只负责把 <alpha-value> 交给 Tailwind,bg-primary-500/30 这类带透明度的写法照旧生效。
|
||||
// 默认那一套是 Teal/Cyan 青色系,用户在「外观」里换配色时由 utils/themeColor.ts 换 <html> 上的属性。
|
||||
const primaryShade = (shade) => `rgb(var(--primary-${shade}) / <alpha-value>)`
|
||||
|
||||
/** @type {import('tailwindcss').Config} */
|
||||
export default {
|
||||
content: ['./index.html', './src/**/*.{vue,js,ts,jsx,tsx}'],
|
||||
|
|
@ -5,19 +10,19 @@ export default {
|
|||
theme: {
|
||||
extend: {
|
||||
colors: {
|
||||
// 主色调 - Teal/Cyan 青色系
|
||||
// 主色调 - 跟随主题色(style.css 里的 --primary-*)
|
||||
primary: {
|
||||
50: '#f0fdfa',
|
||||
100: '#ccfbf1',
|
||||
200: '#99f6e4',
|
||||
300: '#5eead4',
|
||||
400: '#2dd4bf',
|
||||
500: '#14b8a6',
|
||||
600: '#0d9488',
|
||||
700: '#0f766e',
|
||||
800: '#115e59',
|
||||
900: '#134e4a',
|
||||
950: '#042f2e'
|
||||
50: primaryShade(50),
|
||||
100: primaryShade(100),
|
||||
200: primaryShade(200),
|
||||
300: primaryShade(300),
|
||||
400: primaryShade(400),
|
||||
500: primaryShade(500),
|
||||
600: primaryShade(600),
|
||||
700: primaryShade(700),
|
||||
800: primaryShade(800),
|
||||
900: primaryShade(900),
|
||||
950: primaryShade(950)
|
||||
},
|
||||
// 辅助色 - 深蓝灰
|
||||
accent: {
|
||||
|
|
@ -67,20 +72,20 @@ export default {
|
|||
boxShadow: {
|
||||
glass: '0 8px 32px rgba(0, 0, 0, 0.08)',
|
||||
'glass-sm': '0 4px 16px rgba(0, 0, 0, 0.06)',
|
||||
glow: '0 0 20px rgba(20, 184, 166, 0.25)',
|
||||
'glow-lg': '0 0 40px rgba(20, 184, 166, 0.35)',
|
||||
glow: '0 0 20px rgb(var(--primary-500) / 0.25)',
|
||||
'glow-lg': '0 0 40px rgb(var(--primary-500) / 0.35)',
|
||||
card: '0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06)',
|
||||
'card-hover': '0 10px 40px rgba(0, 0, 0, 0.08)',
|
||||
'inner-glow': 'inset 0 1px 0 rgba(255, 255, 255, 0.1)'
|
||||
},
|
||||
backgroundImage: {
|
||||
'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))',
|
||||
'gradient-primary': 'linear-gradient(135deg, #14b8a6 0%, #0d9488 100%)',
|
||||
'gradient-primary': 'linear-gradient(135deg, rgb(var(--primary-500)) 0%, rgb(var(--primary-600)) 100%)',
|
||||
'gradient-dark': 'linear-gradient(135deg, #1e293b 0%, #0f172a 100%)',
|
||||
'gradient-glass':
|
||||
'linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.05) 100%)',
|
||||
'mesh-gradient':
|
||||
'radial-gradient(at 40% 20%, rgba(20, 184, 166, 0.12) 0px, transparent 50%), radial-gradient(at 80% 0%, rgba(6, 182, 212, 0.08) 0px, transparent 50%), radial-gradient(at 0% 50%, rgba(20, 184, 166, 0.08) 0px, transparent 50%)'
|
||||
'radial-gradient(at 40% 20%, rgb(var(--primary-500) / 0.12) 0px, transparent 50%), radial-gradient(at 80% 0%, rgb(var(--primary-400) / 0.08) 0px, transparent 50%), radial-gradient(at 0% 50%, rgb(var(--primary-500) / 0.08) 0px, transparent 50%)'
|
||||
},
|
||||
animation: {
|
||||
'fade-in': 'fadeIn 0.3s ease-out',
|
||||
|
|
@ -118,8 +123,8 @@ export default {
|
|||
'100%': { backgroundPosition: '200% 0' }
|
||||
},
|
||||
glow: {
|
||||
'0%': { boxShadow: '0 0 20px rgba(20, 184, 166, 0.25)' },
|
||||
'100%': { boxShadow: '0 0 30px rgba(20, 184, 166, 0.4)' }
|
||||
'0%': { boxShadow: '0 0 20px rgb(var(--primary-500) / 0.25)' },
|
||||
'100%': { boxShadow: '0 0 30px rgb(var(--primary-500) / 0.4)' }
|
||||
}
|
||||
},
|
||||
backdropBlur: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue