feat(desktop): 完善灵动岛设计令牌与外观配置
发布官网与文档站 / build (push) Waiting to run

This commit is contained in:
LoveChengke committed 2026-11-17 18:57:32 +08:00
1 parent 195ee3b90a
commit 4449fbd0a1
37 files changed
+1639 -339

No files matched your search

+2 -1
View File
@@ -50,7 +50,8 @@ description: 经典提醒、自定义常驻方案、课程与课件传输。
## 外观、位置与输入 ## 外观、位置与输入
经典模式可调宽高、字号、主题色、黑色/半透明/渐变、停靠与边距;自定义内容根据实际测量适配工作区。 经典模式可调宽高、字号、主题色、黑色/半透明/渐变、停靠与边距;自定义内容根据实际测量适配工作区。
自定义方案可配置缩放、圆角、颜色和行间距,默认值与范围在 shared/island-layout.ts。外观页的圆角滑块同步修改当前自定义方案的常态圆角,与编辑器设置一致。 自定义方案可配置缩放、四档字号、字重、圆角、背景/前景色和行间距,默认值与范围在 shared/island-layout.ts。四档字号输入范围是 1–40px,可按组件或单行覆盖;关闭行级覆盖后只回落该行,不影响其他行。
强调色支持自定义、壁纸调色板、跟随系统和屏幕调色板四种来源;自定义背景与前景可分别关闭,关闭后回落当前亮/暗主题。前景色会派生 100% / 85.5% / 77.3% / 52.9% / 36.5% 五级文字 alpha。外观页的圆角滑块同步修改当前自定义方案的常态圆角,与编辑器设置一致。
左右边距只在左/右停靠时生效,居中锚点仍在屏幕中线。 左右边距只在左/右停靠时生效,居中锚点仍在屏幕中线。
触摸屏自动进入触摸模式,保留触摸命中和失焦宽限;鼠标模式按光标控制输入穿透。 触摸屏自动进入触摸模式,保留触摸命中和失焦宽限;鼠标模式按光标控制输入穿透。
自定义常驻内容支持鼠标避让淡化及反转,交互入口、展开/编辑和触摸操作按实现暂停避让。 自定义常驻内容支持鼠标避让淡化及反转,交互入口、展开/编辑和触摸操作按实现暂停避让。
+45 -1
View File
@@ -11,14 +11,16 @@ description: 本地经典/自定义岛的几何、外观与动画入口。
## 经典几何与外观 ## 经典几何与外观
| 来源 | 内容 | | 来源 | 内容 |
| ---------------------------------------------------- | ----------------------------------------------------- | | ---------------------------------------------------- | --------------------------------------------------------------------- |
| shared/src/constants.ts 的 DEFAULT_ISLAND_APPEARANCE | 默认宽 268、高 44、圆角 20、字号 13、边距 8,顶部居中 | | shared/src/constants.ts 的 DEFAULT_ISLAND_APPEARANCE | 默认宽 268、高 44、圆角 20、字号 13、边距 8,顶部居中 |
| shared/src/constants.ts 的 CLASSISLAND_TOKENS | 岛层颜色、字体、字号、圆角、间距、阴影、层级与 DPI 的 TypeScript 来源 |
| ISLAND_APPEARANCE_RANGES | 滑块与主进程归一化共用的范围 | | ISLAND_APPEARANCE_RANGES | 滑块与主进程归一化共用的范围 |
| ISLAND_SIZE_DELTA | 展开、紧急与叫人相对尺寸 | | ISLAND_SIZE_DELTA | 展开、紧急与叫人相对尺寸 |
| ISLAND_SHADOW_PAD | 窗口边界的透明留白 | | ISLAND_SHADOW_PAD | 窗口边界的透明留白 |
| ISLAND_LIST_METRICS / islandListLayout | 主进程和渲染层共用列表度量,控制行数与工作区高度 | | ISLAND_LIST_METRICS / islandListLayout | 主进程和渲染层共用列表度量,控制行数与工作区高度 |
| desktop-client/src/island/squircle.ts | 超椭圆路径 | | desktop-client/src/island/squircle.ts | 超椭圆路径 |
| desktop-client/src/island/classic-island.css | 经典底色、文字、图形与状态样式 | | desktop-client/src/island/classic-island.css | 经典底色、文字、图形与状态样式 |
| ui/src/tokens.css | `--ci-*` 亮/暗两套 CSS 变量,以及五级文字工具类 |
classic 的 black/glass/tinted 是本地 CSS 外观;glass 使用半透明色,不采样桌面模糊。 classic 的 black/glass/tinted 是本地 CSS 外观;glass 使用半透明色,不采样桌面模糊。
不要对透明岛调用 setBackgroundMaterial:系统材质作用于整窗矩形,可能破坏逐像素透明。 不要对透明岛调用 setBackgroundMaterial:系统材质作用于整窗矩形,可能破坏逐像素透明。
@@ -41,6 +43,47 @@ CLASSISLAND_ISLAND_METRICS 位于 shared/src/island-layout.ts:
方案有常态 rows 和无通知展开 expandedRows,运行时由 CustomIslandRuntime.vue 测量自然内容, 方案有常态 rows 和无通知展开 expandedRows,运行时由 CustomIslandRuntime.vue 测量自然内容,
再按屏幕工作区与方案缩放适配。字体与外观覆盖按组件契约生效,不能拿经典固定宽高解释自定义内容尺寸。 再按屏幕工作区与方案缩放适配。字体与外观覆盖按组件契约生效,不能拿经典固定宽高解释自定义内容尺寸。
自定义岛默认使用 CSS `border-radius`;经典岛继续保留连续圆角。圆角同时作用于自绘背景与内容裁切,
默认 8px、范围 0–20px、步进 0.5px。背景色只通过 `--resident-background` 派生,背景 alpha 与整行
`opacity` 分开计算,避免整行不透明度连带淡化投影和覆盖层。
### ClassIsland token 层
`CLASSISLAND_TOKENS` 与 `--ci-*` 一一对应,应用外壳继续使用 `--ch-*` / `--ch-ui-*`。
ClassIsland 源值中的颜色采用 Avalonia `AARRGGBB`,写入 CSS 时统一转换为
`RRGGBBAA`,alpha 数值不变。
| 类别 | 关键值 |
| -------- | ------------------------------------------------------------------------ |
| 强调色 | PrimaryColor / DeepSkyBlue、SecondaryColor / Aquamarine、DodgerBlue 兜底 |
| 五级前景 | 100% / 85.5% / 77.3% / 52.9% / 36.5%,开启自定义前景时写进颜色 alpha |
| 四档字号 | 14 / 16 / 18 / 20px,设置范围 1–40px,步进 0.5px |
| 字重 | 100–900 逐值映射,默认 500;其他值回落 400 |
| 圆角 | 岛 8、弹窗 6、卡片与控件 4、抽屉 8 8 0 0、胶囊 999px |
| 间距 | 行高 40、左右 12、组件间距 12、行距 5、进度条 3px |
| 层级 | 遮罩/拖拽 1、抽屉 10、时间轴装饰 9999、哨兵 2147483647 |
| DPI | 96 DPI 基准、缩放 0.75–2.5、Fluent 竖直安全区 20px |
四档字号可写在组件自身、单个行或方案根元素。行级与组件级都通过 CSS 变量覆盖;关闭覆盖时删除
对应内联变量并回落到方案或 `:root`。自定义前景关闭时同样删除行内五级变量,由 `html.dark` 切换
主题默认值。
强调色来源严格区分自定义、壁纸调色板、跟随系统与屏幕调色板;主进程输出 `resolvedAccent`,设置页
仍保留用户选择的 `accent`,避免切换来源时覆盖原自定义色。主题切换通过岛桥接的 `island:theme`
事件实时同步 `html.dark`,不依赖主窗口的 DOM。
### 主界面对照
| ClassIsland 概念 | ClassHelper 实体 |
| ----------------------- | ------------------------------------------------------------------ |
| MainWindow | 独立 `island.html` + 主进程透明 `BrowserWindow` |
| MainWindowLine | `CustomIslandRuntime.vue` 的 `.layout-row` 与行级 CSS 变量 |
| ComponentPresenter | `ComponentNode.vue` 根节点的宽高、透明度、隐藏与裁剪 |
| 日期/时钟/天气/课程组件 | `ComponentNode.vue`、`WeatherBrief.vue` 等共享组件 |
| Fluent/Classic 主题 | `custom-runtime.css` / `custom-island.css` / `classic-island.css` |
| 编辑模式视图 | 主窗口 `IslandEditorView.vue`、`IslandEditorNode.vue` 与右侧检查器 |
| 提醒宿主 | `ClassicNotifications.vue`,嵌入自定义岛或经典岛 |
## 动画与命中 ## 动画与命中
经典与自定义岛的形变都使用 src/island/spring.ts 的 SpringValue;默认 stiffness=0.10、damping=0.68, 经典与自定义岛的形变都使用 src/island/spring.ts 的 SpringValue;默认 stiffness=0.10、damping=0.68,
@@ -56,4 +99,5 @@ CLASSISLAND_ISLAND_METRICS 位于 shared/src/island-layout.ts:
外观范围改 shared,经典样式改 classic-island.css,自定义样式改 custom-runtime.css 和 custom-island.css, 外观范围改 shared,经典样式改 classic-island.css,自定义样式改 custom-runtime.css 和 custom-island.css,
原生窗口与命中改 main/island.ts。组件结构/设置改 shared/island-layout.ts 并同步编辑器和运行时。 原生窗口与命中改 main/island.ts。组件结构/设置改 shared/island-layout.ts 并同步编辑器和运行时。
改 token 后运行 `pnpm check:design-tokens`,它会校验亮/暗键集合、必备 token、kebab-case 与岛内裸颜色。
展示行为见[灵动岛](../app/island.md),测试见[验收与测试](testing.md)。 展示行为见[灵动岛](../app/island.md),测试见[验收与测试](testing.md)。
Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

After

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 77 KiB

After

Width:  |  Height:  |  Size: 84 KiB

+2 -1
View File
@@ -16,8 +16,9 @@
"build": "pnpm build:shared && pnpm --filter @classhelper/server build && pnpm --filter @classhelper/web-admin build && pnpm --filter @classhelper/desktop-client build", "build": "pnpm build:shared && pnpm --filter @classhelper/server build && pnpm --filter @classhelper/web-admin build && pnpm --filter @classhelper/desktop-client build",
"build:desktop": "pnpm build:shared && pnpm --filter @classhelper/desktop-client build", "build:desktop": "pnpm build:shared && pnpm --filter @classhelper/desktop-client build",
"check:icons": "node scripts/check-icons.mjs", "check:icons": "node scripts/check-icons.mjs",
"check:design-tokens": "node scripts/check-design-tokens.mjs",
"typecheck": "pnpm build:shared && pnpm -r --workspace-concurrency=1 --no-bail typecheck", "typecheck": "pnpm build:shared && pnpm -r --workspace-concurrency=1 --no-bail typecheck",
"lint": "node scripts/check-authz.mjs && eslint .", "lint": "node scripts/check-authz.mjs && node scripts/check-design-tokens.mjs && eslint .",
"lint:fix": "eslint . --fix", "lint:fix": "eslint . --fix",
"format": "prettier --write \"**/*.{ts,js,mjs,cjs,vue,json,md,yaml,yml,css,scss,html}\"", "format": "prettier --write \"**/*.{ts,js,mjs,cjs,vue,json,md,yaml,yml,css,scss,html}\"",
"format:check": "prettier --check \"**/*.{ts,js,mjs,cjs,vue,json,md,yaml,yml,css,scss,html}\"", "format:check": "prettier --check \"**/*.{ts,js,mjs,cjs,vue,json,md,yaml,yml,css,scss,html}\"",
@@ -180,11 +180,18 @@ const style = computed<CSSProperties>(() => {
const n = props.node, const n = props.node,
a = n.appearance, a = n.appearance,
override = a.resourceOverridingEnabled; override = a.resourceOverridingEnabled;
const color = const alpha = a.customBackgroundOpacityEnabled ? a.backgroundOpacity : 1;
a.background + const color = `color-mix(in srgb, ${a.background} ${alpha * 100}%, transparent)`;
Math.round((a.customBackgroundOpacityEnabled ? a.backgroundOpacity : 1) * 255) const customText: Record<string, string> =
.toString(16) override && a.customForegroundEnabled
.padStart(2, '0'); ? {
'--ci-text-1': a.foreground,
'--ci-text-2': `color-mix(in srgb, ${a.foreground} 85.5%, transparent)`,
'--ci-text-3': `color-mix(in srgb, ${a.foreground} 77.3%, transparent)`,
'--ci-text-4': `color-mix(in srgb, ${a.foreground} 52.9%, transparent)`,
'--ci-text-5': `color-mix(in srgb, ${a.foreground} 36.5%, transparent)`,
}
: {};
return { return {
opacity: a.opacity, opacity: a.opacity,
width: n.advanced.width ? `${n.advanced.width}px` : undefined, width: n.advanced.width ? `${n.advanced.width}px` : undefined,
@@ -195,17 +202,19 @@ const style = computed<CSSProperties>(() => {
n.advanced.align n.advanced.align
], ],
textAlign: n.advanced.align === 'start' ? 'start' : n.advanced.align === 'end' ? 'end' : 'center', textAlign: n.advanced.align === 'start' ? 'start' : n.advanced.align === 'end' ? 'end' : 'center',
color: override && a.customForegroundEnabled ? a.foreground : undefined, color: 'var(--ci-text-1)',
background: override && a.customBackgroundEnabled ? color : undefined, background: override && a.customBackgroundEnabled ? color : undefined,
borderRadius: override && a.customCornerRadiusEnabled ? `${a.cornerRadius}px` : undefined, borderRadius: override && a.customCornerRadiusEnabled ? `${a.cornerRadius}px` : undefined,
fontSize: override ? `${a.bodyFontSize}px` : undefined, fontSize: override ? `${a.bodyFontSize}px` : undefined,
'--secondary': override ? `${a.secondaryFontSize}px` : undefined, '--ci-fs-secondary': override ? `${a.secondaryFontSize}px` : undefined,
'--emphasized': override ? `${a.emphasizedFontSize}px` : undefined, '--ci-fs-body': override ? `${a.bodyFontSize}px` : undefined,
'--large': override ? `${a.largeFontSize}px` : undefined, '--ci-fs-emphasized': override ? `${a.emphasizedFontSize}px` : undefined,
'--ci-fs-large': override ? `${a.largeFontSize}px` : undefined,
'--rolling-duration': `${Math.max(1, 200 / n.settings.speed)}s`, '--rolling-duration': `${Math.max(1, 200 / n.settings.speed)}s`,
flexDirection: container.value ? (n.settings.direction === 'vertical' ? 'column' : 'row') : undefined, flexDirection: container.value ? (n.settings.direction === 'vertical' ? 'column' : 'row') : undefined,
gap: container.value ? `${n.settings.gap}px` : undefined, gap: container.value ? `${n.settings.gap}px` : undefined,
display: container.value ? 'flex' : undefined, display: container.value ? 'flex' : undefined,
...customText,
}; };
}); });
</script> </script>
@@ -298,9 +307,10 @@ const style = computed<CSSProperties>(() => {
padding: 6px; padding: 6px;
flex-shrink: 0; flex-shrink: 0;
position: relative; position: relative;
color: var(--ci-text-1);
} }
.component-node:not(.node-editing) { .component-node:not(.node-editing) {
line-height: 1.4; line-height: var(--ci-line-height-body);
} }
.clock { .clock {
font-variant-numeric: tabular-nums; font-variant-numeric: tabular-nums;
@@ -316,7 +326,7 @@ const style = computed<CSSProperties>(() => {
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
gap: 6px; gap: calc(var(--ci-component-gap) / 2);
padding-bottom: 3px; padding-bottom: 3px;
} }
.lesson-line strong { .lesson-line strong {
@@ -326,10 +336,10 @@ const style = computed<CSSProperties>(() => {
white-space: nowrap; white-space: nowrap;
} }
.lesson-line.current strong { .lesson-line.current strong {
color: #fff; color: var(--ci-text-1);
} }
.lesson-line.break { .lesson-line.break {
opacity: 0.86; color: var(--ci-text-3);
} }
.time-divider { .time-divider {
display: block; display: block;
@@ -344,19 +354,21 @@ const style = computed<CSSProperties>(() => {
flex-shrink: 0; flex-shrink: 0;
font-variant-numeric: tabular-nums; font-variant-numeric: tabular-nums;
white-space: nowrap; white-space: nowrap;
color: var(--ci-text-3);
font-size: var(--ci-fs-secondary);
} }
.lesson-progress { .lesson-progress {
position: absolute; position: absolute;
inset: auto 0 0; inset: auto 0 0;
height: 2px; height: var(--ci-progress-height);
background: #ffffff24; background: var(--ci-fill-strong);
overflow: hidden; overflow: hidden;
border-radius: 1px; border-radius: calc(var(--ci-progress-height) / 3);
} }
.lesson-progress i { .lesson-progress i {
display: block; display: block;
height: 100%; height: 100%;
background: var(--island-accent, #60a5fa); background: var(--island-accent, var(--ci-accent));
transform-origin: left; transform-origin: left;
transition: transform 1s linear; transition: transform 1s linear;
} }
@@ -391,28 +403,26 @@ const style = computed<CSSProperties>(() => {
animation: none; animation: none;
} }
.selected { .selected {
outline: 2px solid #85aaff; outline: 2px solid var(--ci-stroke-drag);
border-radius: 8px; border-radius: var(--ci-radius-island);
background: #759cff14; background: var(--ci-accent-fill-tertiary);
} }
.node-handle { .node-handle {
touch-action: none; touch-action: none;
cursor: grab; cursor: grab;
display: block; display: block;
font: font: var(--ci-fw-normal) var(--ci-fs-version) / 1.2 var(--ci-font);
10px 'Microsoft YaHei',
sans-serif;
padding: 3px 6px; padding: 3px 6px;
border: 0; border: 0;
border-radius: 4px; border-radius: var(--ci-radius-control);
min-height: 24px; min-height: 24px;
margin-bottom: 4px; margin-bottom: 4px;
color: #ffffff80; color: var(--ci-text-3);
background: #ffffff0d; background: var(--ci-fill-secondary);
} }
.node-handle:hover { .node-handle:hover {
background: #ffffff20; background: var(--ci-accent-soft);
color: #fff; color: var(--ci-text-1);
} }
.notification, .notification,
.homework, .homework,
@@ -429,19 +439,19 @@ const style = computed<CSSProperties>(() => {
cursor: pointer; cursor: pointer;
} }
.node-editing:hover { .node-editing:hover {
box-shadow: inset 0 0 0 1px #ffffff28; box-shadow: inset 0 0 0 var(--ci-stroke-island-w) var(--ci-stroke-control);
border-radius: 8px; border-radius: var(--ci-radius-island);
} }
small { small {
font-size: var(--secondary, 12px); color: var(--ci-text-3);
opacity: 0.7; font-size: var(--ci-fs-secondary);
} }
strong, strong,
.emphasized { .emphasized {
font-size: var(--emphasized, 20px); font-size: var(--ci-fs-emphasized);
} }
.large { .large {
font-size: var(--large, 28px); font-size: var(--ci-fs-large);
} }
@keyframes rolling { @keyframes rolling {
from { from {
@@ -453,4 +463,3 @@ strong,
} }
</style> </style>
<style src="./lesson-ending.css"></style> <style src="./lesson-ending.css"></style>
<style src="./lesson-ending.css"></style>
@@ -20,7 +20,8 @@ const style = computed(() => {
: position.endsWith('right') : position.endsWith('right')
? { right: `${ISLAND_SHADOW_PAD}px` } ? { right: `${ISLAND_SHADOW_PAD}px` }
: { left: '50%', transform: 'translateX(-50%)' }), : { left: '50%', transform: 'translateX(-50%)' }),
'--transfer-accent': props.appearance.accent, '--ci-accent': props.appearance.resolvedAccent ?? props.appearance.accent,
'--transfer-accent': 'var(--ci-accent)',
}; };
}); });
const status = computed( const status = computed(
@@ -68,15 +69,12 @@ onUnmounted(() => window.removeEventListener('resize', report));
.courseware-transfer { .courseware-transfer {
position: fixed; position: fixed;
box-sizing: border-box; box-sizing: border-box;
padding: 17px 24px; padding: calc(var(--ci-popup-pad) + var(--ci-line-gap)) calc(var(--ci-popup-pad) * 2);
border-radius: 24px; border-radius: var(--ci-radius-oobe-btn);
color: white; color: var(--ci-text-1);
background: rgba(20, 20, 24, 0.97); background: color-mix(in srgb, var(--ci-bg-secondary) 97%, transparent);
box-shadow: 0 2px 8px #0004; box-shadow: var(--ci-shadow-island);
font: font: var(--ci-fw-normal) var(--ci-fs-control-base) / 1.4 var(--ci-font);
13px/1.4 'Segoe UI',
'Microsoft YaHei',
sans-serif;
overflow: hidden; overflow: hidden;
pointer-events: none; pointer-events: none;
} }
@@ -84,26 +82,26 @@ header,
.metadata { .metadata {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
gap: 10px; gap: calc(var(--ci-component-gap) * 0.8);
} }
header { header {
color: #ffffffb8; color: var(--ci-text-2);
font-size: 12px; font-size: var(--ci-fs-caption);
} }
header strong { header strong {
color: var(--transfer-accent); color: var(--transfer-accent);
} }
.filename { .filename {
font-weight: 600; font-weight: var(--ci-fw-semi-bold);
font-size: 16px; font-size: var(--ci-fs-title);
margin: 5px 0; margin: 5px 0;
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
.metadata { .metadata {
color: #ffffffb8; color: var(--ci-text-2);
font-size: 12px; font-size: var(--ci-fs-caption);
} }
progress { progress {
display: block; display: block;
@@ -111,20 +109,20 @@ progress {
height: 5px; height: 5px;
margin-top: 11px; margin-top: 11px;
border: 0; border: 0;
border-radius: 8px; border-radius: var(--ci-radius-island);
overflow: hidden; overflow: hidden;
accent-color: var(--transfer-accent); accent-color: var(--transfer-accent);
} }
progress::-webkit-progress-bar { progress::-webkit-progress-bar {
background: #ffffff30; background: var(--ci-fill-strong);
} }
progress::-webkit-progress-value { progress::-webkit-progress-value {
background: var(--transfer-accent); background: var(--transfer-accent);
} }
p { p {
margin: 3px 0; margin: 3px 0;
font-size: 11px; font-size: var(--ci-fs-caption);
color: #ffb4ab; color: var(--ci-warning-critical);
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
@@ -4,6 +4,7 @@ import {
ISLAND_SHADOW_PAD, ISLAND_SHADOW_PAD,
PRIORITY_RANK, PRIORITY_RANK,
type IslandAppearance, type IslandAppearance,
type IslandLayoutRow,
type IslandLayoutSettings, type IslandLayoutSettings,
type IslandState, type IslandState,
type IslandTimePointDto, type IslandTimePointDto,
@@ -13,7 +14,6 @@ import {
import ComponentNode from './ComponentNode.vue'; import ComponentNode from './ComponentNode.vue';
import ComponentIcon from './ComponentIcon.vue'; import ComponentIcon from './ComponentIcon.vue';
import ClassicNotifications from './ClassicNotifications.vue'; import ClassicNotifications from './ClassicNotifications.vue';
import { squirclePath } from './squircle.js';
import { SpringValue } from './spring.js'; import { SpringValue } from './spring.js';
import LessonReminderContent from './LessonReminderContent.vue'; import LessonReminderContent from './LessonReminderContent.vue';
@@ -78,6 +78,33 @@ function fitted(size: { width: number; height: number }) {
); );
return { scale, width: Math.ceil(size.width * scale), height: Math.ceil(size.height * scale) }; return { scale, width: Math.ceil(size.width * scale), height: Math.ceil(size.height * scale) };
} }
/** 页面配置里的十六进制颜色转成背景 alpha;输入已由 shared 归一化。 */
function withAlpha(hex: string, alpha: number): string {
return `color-mix(in srgb, ${hex} ${Math.min(1, Math.max(0, alpha)) * 100}%, transparent)`;
}
/** 自定义前景色必须写进颜色 alpha,不能用 opacity 连带淡化子元素与阴影。 */
function foregroundVars(hex: string): Record<string, string> {
return {
'--ci-text-1': hex,
'--ci-text-2': `color-mix(in srgb, ${hex} 85.5%, transparent)`,
'--ci-text-3': `color-mix(in srgb, ${hex} 77.3%, transparent)`,
'--ci-text-4': `color-mix(in srgb, ${hex} 52.9%, transparent)`,
'--ci-text-5': `color-mix(in srgb, ${hex} 36.5%, transparent)`,
};
}
function rowStyle(row: IslandLayoutRow): Record<string, string> {
const style: Record<string, string> = {
'--row-gap': `${row.gap}px`,
opacity: String(row.opacity),
};
if (row.fontOverridesEnabled) {
style['--ci-fs-secondary'] = `${row.secondaryFontSize}px`;
style['--ci-fs-body'] = `${row.bodyFontSize}px`;
style['--ci-fs-emphasized'] = `${row.emphasizedFontSize}px`;
style['--ci-fs-large'] = `${row.largeFontSize}px`;
}
return style;
}
const compactFit = computed(() => fitted(natural.value.compact)); const compactFit = computed(() => fitted(natural.value.compact));
const detailsFit = computed(() => fitted(natural.value.details)); const detailsFit = computed(() => fitted(natural.value.details));
const lessonFit = computed(() => fitted(natural.value.lesson)); const lessonFit = computed(() => fitted(natural.value.lesson));
@@ -98,30 +125,44 @@ const progress = ref(0);
const lessonProgress = ref(0); const lessonProgress = ref(0);
const compactAlpha = computed(() => Math.max(0, 1 - progress.value * 1.5) * (1 - lessonProgress.value)); const compactAlpha = computed(() => Math.max(0, 1 - progress.value * 1.5) * (1 - lessonProgress.value));
const detailsAlpha = computed(() => progress.value * progress.value * (1 - lessonProgress.value)); const detailsAlpha = computed(() => progress.value * progress.value * (1 - lessonProgress.value));
const path = computed(() => squirclePath(morph.value.width, morph.value.height, morph.value.radius)); const style = computed<CSSProperties>(() => {
const style = computed<CSSProperties>(() => ({ const current = scheme.value;
const background = lesson.value
? 'transparent'
: expanded.value && messages.value.length
? current.customForegroundEnabled
? 'var(--ci-brand-dark)'
: 'var(--ci-bg-base)'
: current.customBackgroundEnabled
? withAlpha(current.color, current.opacity)
: 'var(--ci-bg-secondary)';
return {
width: `${morph.value.width}px`, width: `${morph.value.width}px`,
height: `${morph.value.height}px`, height: `${morph.value.height}px`,
'--card-path': `path("${path.value}")`, '--island-font': `${current.bodyFontSize}px`,
'--island-font': `${props.appearance.fontSize}px`, '--ci-fs-secondary': `${current.secondaryFontSize}px`,
'--island-accent': props.appearance.accent, '--ci-fs-body': `${current.bodyFontSize}px`,
'--ci-fs-emphasized': `${current.emphasizedFontSize}px`,
'--ci-fs-large': `${current.largeFontSize}px`,
'--ci-font-weight': String(current.fontWeight),
'--ci-scale': String(current.scale),
'--ci-accent': props.appearance.resolvedAccent ?? props.appearance.accent,
'--state-color': '--state-color':
props.state.active?.priority === 'URGENT' props.state.active?.priority === 'URGENT'
? '#ff453a' ? 'var(--ci-danger)'
: props.state.active?.kind === 'call' : props.state.active?.kind === 'call'
? '#ff9f0a' ? 'var(--ci-warning-caution)'
: props.appearance.accent, : 'var(--ci-accent)',
'--resident-background': 'var(--wn-bg)', '--resident-background': background,
'--resident-radius': `${morph.value.radius}px`, '--resident-radius': `${morph.value.radius}px`,
'--resident-scale': fit.value.scale, '--resident-scale': fit.value.scale,
'--custom-row-gap': `${scheme.value.spacing}px`, '--custom-row-gap': `${current.spacing}px`,
'--resident-row-width': `${Math.max(60, available.value.width / scheme.value.scale - 58)}px`, '--resident-row-width': `${Math.max(60, available.value.width / current.scale - 58)}px`,
'--secondary': `${(props.appearance.fontSize / 13) * 14}px`, '--ci-body-font': `${current.bodyFontSize}px`,
'--emphasized': `${(props.appearance.fontSize / 13) * 18}px`,
'--large': `${(props.appearance.fontSize / 13) * 20}px`,
'--ci-body-font': `${(props.appearance.fontSize / 13) * 16}px`,
'--resident-fade-duration': motion.value ? `${200 / props.appearance.speed}ms` : '0ms', '--resident-fade-duration': motion.value ? `${200 / props.appearance.speed}ms` : '0ms',
})); ...(current.customForegroundEnabled ? foregroundVars(current.foreground) : {}),
};
});
let morphFrame = 0; let morphFrame = 0;
let morphFallback: ReturnType<typeof setTimeout> | undefined; let morphFallback: ReturnType<typeof setTimeout> | undefined;
function animate() { function animate() {
@@ -342,6 +383,16 @@ onUnmounted(() => {
:data-bottom="appearance.position.startsWith('bottom')" :data-bottom="appearance.position.startsWith('bottom')"
@pointerdown.capture="pointer" @pointerdown.capture="pointer"
> >
<span
class="resident-shadow"
:class="{ 'resident-shadow-hidden': lesson || (scheme.separated && !expanded) }"
:style="{
width: `${morph.width}px`,
height: `${morph.height}px`,
borderRadius: `${morph.radius}px`,
}"
aria-hidden="true"
/>
<section <section
ref="shell" ref="shell"
class="custom-card resident-card island-card" class="custom-card resident-card island-card"
@@ -371,16 +422,6 @@ onUnmounted(() => {
@keydown="key" @keydown="key"
@transitionend.self="reportHit" @transitionend.self="reportHit"
> >
<svg
class="shape"
:width="morph.width"
:height="morph.height"
:viewBox="`0 0 ${morph.width} ${morph.height}`"
preserveAspectRatio="none"
aria-hidden="true"
>
<path :d="path" />
</svg>
<span class="tint" aria-hidden="true" /> <span class="tint" aria-hidden="true" />
<div <div
class="resident-page resident-compact-page" class="resident-page resident-compact-page"
@@ -400,7 +441,7 @@ onUnmounted(() => {
:key="row.id" :key="row.id"
class="layout-row" class="layout-row"
:data-row="row.id" :data-row="row.id"
:style="{ '--row-gap': `${row.gap}px` }" :style="rowStyle(row)"
> >
<div class="row-components"> <div class="row-components">
<ComponentNode <ComponentNode
@@ -482,7 +523,7 @@ onUnmounted(() => {
:key="row.id" :key="row.id"
class="layout-row" class="layout-row"
:data-row="row.id" :data-row="row.id"
:style="{ '--row-gap': `${row.gap}px` }" :style="rowStyle(row)"
> >
<div class="row-components"> <div class="row-components">
<ComponentNode <ComponentNode
@@ -29,10 +29,10 @@ onUnmounted(() => clearInterval(clock));
* - 造型:**连续圆角(超椭圆 squircle)**而不是 border-radius(WinIsland `utils/shape.rs`); * - 造型:**连续圆角(超椭圆 squircle)**而不是 border-radius(WinIsland `utils/shape.rs`);
* 展开卡半径取 `min(48 * 圆角系数, w/2, h/2)`,胶囊半径取 `h/2`(满圆角); * 展开卡半径取 `min(48 * 圆角系数, w/2, h/2)`,胶囊半径取 `h/2`(满圆角);
* - 底色:默认纯黑(WinIsland `default` 风格),可选半透明毛玻璃(`glass`; * - 底色:默认纯黑(WinIsland `default` 风格),可选半透明毛玻璃(`glass`;
* **纯 CSS 实现**,取 WinIsland 拿不到 host backdrop 时的降级色 `rgba(32,32,36,.804)`—— * **纯 CSS 实现**,取 WinIsland 拿不到 host backdrop 时的 80.4% 深色降级底——
* Electron 的 `setBackgroundMaterial()` 不能用在逐像素透明窗口上,原因见 `main/island.ts`); * Electron 的 `setBackgroundMaterial()` 不能用在逐像素透明窗口上,原因见 `main/island.ts`);
* - 描边:1px 白、alpha 30(纯黑)/ 40(玻璃、主题色),与 WinIsland `BORDER_*_ALPHA` 同值; * - 描边:1px 白、alpha 30(纯黑)/ 40(玻璃、主题色),与 WinIsland `BORDER_*_ALPHA` 同值;
* - 阴影:只在展开态,`0 2px 3px rgba(0,0,0,.11)`(WinIsland `draw_expanded_shadow`); * - 阴影:只在展开态,2px 偏移、3px 模糊、11% 黑(WinIsland `draw_expanded_shadow`);
* - 排版:白字 + alpha 分级(.92/.72/.58),**所有文本 = 基础字号 × 排版系数**, * - 排版:白字 + alpha 分级(.92/.72/.58),**所有文本 = 基础字号 × 排版系数**,
* 因此「字号」设置一改,岛内文字整体等比缩放(WinIsland `font_size` 模型); * 因此「字号」设置一改,岛内文字整体等比缩放(WinIsland `font_size` 模型);
* - 动效:**单调缓动(无过冲、无回弹)**,只有淡入淡出与窗口形变,符合"开合不震动"。 * - 动效:**单调缓动(无过冲、无回弹)**,只有淡入淡出与窗口形变,符合"开合不震动"。
@@ -150,8 +150,8 @@ const showAfterClassHint = computed(() => state.value.reason === 'after-class' &
/** 状态色(WinIsland 资源占用色板同源):危险红 / 警告橙 / 强调蓝 */ /** 状态色(WinIsland 资源占用色板同源):危险红 / 警告橙 / 强调蓝 */
const stateColor = computed(() => { const stateColor = computed(() => {
if (isUrgent.value) return '#ff453a'; if (isUrgent.value) return 'var(--ci-danger)';
if (isCall.value) return '#ff9f0a'; if (isCall.value) return 'var(--ci-warning-caution)';
if (isHomework.value) return appearance.value.accent; if (isHomework.value) return appearance.value.accent;
return ''; return '';
}); });
@@ -519,7 +519,8 @@ function applyAppearance(next: IslandAppearance | null | undefined): void {
if (!next) return; if (!next) return;
appearance.value = next; appearance.value = next;
const style = document.documentElement.style; const style = document.documentElement.style;
style.setProperty('--island-accent', next.accent); style.setProperty('--ci-accent', next.resolvedAccent ?? next.accent);
style.setProperty('--ci-accent-fill', 'var(--ci-accent)');
style.setProperty('--island-radius', `${next.radius}px`); style.setProperty('--island-radius', `${next.radius}px`);
style.setProperty('--island-font', `${next.fontSize}px`); style.setProperty('--island-font', `${next.fontSize}px`);
style.setProperty('--island-w', `${next.width}px`); style.setProperty('--island-w', `${next.width}px`);
@@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { nextTick, onMounted, onUnmounted, ref } from 'vue'; import { nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
import { import {
defaultIslandLayouts, defaultIslandLayouts,
DEFAULT_ISLAND_APPEARANCE, DEFAULT_ISLAND_APPEARANCE,
@@ -18,6 +18,7 @@ const schedules = ref<ScheduleDto[]>([]);
const timePoints = ref<IslandTimePointDto[]>([]); const timePoints = ref<IslandTimePointDto[]>([]);
const appearance = ref<IslandAppearance>({ ...DEFAULT_ISLAND_APPEARANCE }); const appearance = ref<IslandAppearance>({ ...DEFAULT_ISLAND_APPEARANCE });
const nativeVisible = ref(false); const nativeVisible = ref(false);
const theme = ref<'light' | 'dark'>('light');
const resident = () => settings.value.layout === 'custom'; const resident = () => settings.value.layout === 'custom';
const state = ref<IslandState>({ const state = ref<IslandState>({
mode: 'hidden', mode: 'hidden',
@@ -31,11 +32,15 @@ const state = ref<IslandState>({
updatedAt: 0, updatedAt: 0,
}); });
let heartbeat: ReturnType<typeof setInterval>; let heartbeat: ReturnType<typeof setInterval>;
watch(theme, (value) => document.documentElement.classList.toggle('dark', value === 'dark'), {
immediate: true,
});
onUnmounted(() => clearInterval(heartbeat)); onUnmounted(() => clearInterval(heartbeat));
onMounted(async () => { onMounted(async () => {
heartbeat = setInterval(() => window.island?.alive(), 5000); heartbeat = setInterval(() => window.island?.alive(), 5000);
const bridge = window.island; const bridge = window.island;
if (bridge) { if (bridge) {
bridge.onTheme((value) => (theme.value = value));
bridge.onLayout((value) => (settings.value = value)); bridge.onLayout((value) => (settings.value = value));
bridge.onSchedules((value) => (schedules.value = value)); bridge.onSchedules((value) => (schedules.value = value));
bridge.onTimePoints((value) => (timePoints.value = value)); bridge.onTimePoints((value) => (timePoints.value = value));
@@ -43,6 +48,7 @@ onMounted(async () => {
bridge.onAppearance((value) => (appearance.value = value)); bridge.onAppearance((value) => (appearance.value = value));
bridge.onVisibility((value) => (nativeVisible.value = value)); bridge.onVisibility((value) => (nativeVisible.value = value));
nativeVisible.value = await bridge.getVisible(); nativeVisible.value = await bridge.getVisible();
theme.value = await bridge.getTheme();
appearance.value = await bridge.getAppearance(); appearance.value = await bridge.getAppearance();
settings.value = await bridge.getLayout(); settings.value = await bridge.getLayout();
schedules.value = await bridge.getSchedules(); schedules.value = await bridge.getSchedules();
@@ -198,20 +198,20 @@ onUnmounted(() => {
width: max-content; width: max-content;
min-width: 300px; min-width: 300px;
max-width: 800px; max-width: 800px;
height: 40px; height: var(--ci-island-height);
overflow: hidden; overflow: hidden;
color: #fff; color: var(--ci-text-1);
font-size: 16px; font-size: var(--ci-fs-body);
line-height: 1; line-height: 1;
border-radius: 8px; border-radius: var(--ci-radius-island);
background: #20202080; background: color-mix(in srgb, var(--ci-bg-base) 50%, transparent);
} }
.ci-lesson-info { .ci-lesson-info {
height: 40px; height: var(--ci-island-height);
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
gap: 12px; gap: var(--ci-component-gap);
padding: 0 14px; padding: 0 14px;
white-space: nowrap; white-space: nowrap;
transition: opacity var(--ci-duration) ease-in; transition: opacity var(--ci-duration) ease-in;
@@ -230,25 +230,26 @@ onUnmounted(() => {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
gap: 6px; gap: calc(var(--ci-component-gap) / 2);
} }
.ci-lesson-course strong { .ci-lesson-course strong {
font-size: 20px; font-size: var(--ci-fs-large);
min-width: 0; min-width: 0;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
.ci-lesson-course small { .ci-lesson-course small {
flex-shrink: 0; flex-shrink: 0;
font-size: 14px; color: var(--ci-text-3);
font-size: var(--ci-fs-secondary);
font-variant-numeric: tabular-nums; font-variant-numeric: tabular-nums;
} }
.ci-mask { .ci-mask {
position: absolute; position: absolute;
inset: 0; inset: 0;
width: 100%; width: 100%;
height: 40px; height: var(--ci-island-height);
fill: var(--island-accent, #60a5fa); fill: var(--island-accent, var(--ci-accent));
pointer-events: none; pointer-events: none;
} }
.ci-mask-title { .ci-mask-title {
@@ -257,9 +258,9 @@ onUnmounted(() => {
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
gap: 8px; gap: calc(var(--ci-component-gap) * 0.67);
opacity: 0; opacity: 0;
font-size: 18px; font-size: var(--ci-fs-emphasized);
transform: scale(1.1); transform: scale(1.1);
transition: transition:
opacity var(--ci-duration) linear, opacity var(--ci-duration) linear,
@@ -309,8 +310,8 @@ onUnmounted(() => {
bottom: 0; bottom: 0;
left: 0; left: 0;
width: 100%; width: 100%;
height: 2px; height: var(--ci-progress-height);
background: var(--island-accent, #60a5fa); background: var(--island-accent, var(--ci-accent));
transform-origin: left; transform-origin: left;
transition: transform 50ms linear; transition: transform 50ms linear;
} }
@@ -86,6 +86,7 @@ const advice = computed(() => {
} }
small { small {
display: block; display: block;
font-size: var(--secondary, 12px); color: var(--ci-text-3);
font-size: var(--ci-fs-secondary);
} }
</style> </style>
@@ -18,10 +18,13 @@ body,
user-select: none; user-select: none;
} }
:root {
/* 经典岛沿用历史变量名,但颜色唯一来源仍是 --ci-accent。 */
--island-accent: var(--ci-accent);
}
body { body {
font-family: font-family: var(--ci-font-island);
-apple-system, 'Segoe UI Variable Display', 'Segoe UI', 'Microsoft YaHei', 'PingFang SC',
'Helvetica Neue', sans-serif;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
} }
@@ -53,36 +56,38 @@ body {
margin: 0; margin: 0;
border: none; border: none;
background: none; background: none;
color: rgba(255, 255, 255, 0.92); color: var(--ci-text-on-accent);
font-family: var(--ci-font-island);
font-size: var(--island-font, 13px); font-size: var(--island-font, 13px);
font-weight: var(--ci-font-weight);
text-align: left; text-align: left;
cursor: pointer; cursor: pointer;
/* 配色 token(默认:WinIsland 纯黑风格) */ /* 配色 token(默认:WinIsland 纯黑风格) */
--wn-bg: #000000; --wn-bg: var(--ci-island-bg-custom);
--wn-border: rgba(255, 255, 255, 0.118); --wn-border: var(--ci-stroke-island);
--wn-text-1: rgba(255, 255, 255, 0.92); --wn-text-1: var(--ci-text-on-accent);
--wn-text-2: rgba(255, 255, 255, 0.72); --wn-text-2: color-mix(in srgb, var(--ci-text-on-accent) 85.5%, transparent);
--wn-text-3: rgba(255, 255, 255, 0.58); --wn-text-3: color-mix(in srgb, var(--ci-text-on-accent) 77.3%, transparent);
--wn-surface: rgba(255, 255, 255, 0.1); --wn-surface: var(--ci-fill-secondary);
--wn-surface-hover: rgba(255, 255, 255, 0.18); --wn-surface-hover: var(--ci-accent-soft);
--wn-divider: rgba(255, 255, 255, 0.09); --wn-divider: var(--ci-stroke-divider);
} }
.island-card[data-style='glass'] { .island-card[data-style='glass'] {
/* WinIsland「glass 无 host backdrop」降级色:比纯黑透一点,但保证任何桌面下都不是白底 */ /* WinIsland「glass 无 host backdrop」降级色:比纯黑透一点,但保证任何桌面下都不是白底 */
--wn-bg: rgba(32, 32, 36, 0.804); --wn-bg: color-mix(in srgb, var(--ci-bg-base) 80.4%, transparent);
--wn-border: rgba(255, 255, 255, 0.157); --wn-border: var(--ci-stroke-control);
--wn-surface: rgba(255, 255, 255, 0.14); --wn-surface: var(--ci-fill-secondary);
--wn-surface-hover: rgba(255, 255, 255, 0.22); --wn-surface-hover: var(--ci-accent-fill-tertiary);
} }
.island-card[data-style='tinted'] { .island-card[data-style='tinted'] {
--wn-bg: #0b0b0f; --wn-bg: color-mix(in srgb, var(--ci-island-bg-custom) 88%, var(--ci-accent));
--wn-border: rgba(255, 255, 255, 0.14); --wn-border: var(--ci-stroke-control);
} }
/* 阅读老师消息时使用实色底,玻璃风格也不透出桌面。 */ /* 阅读老师消息时使用实色底,玻璃风格也不透出桌面。 */
.island-card.message-surface { .island-card.message-surface {
--wn-bg: #202020; --wn-bg: var(--ci-brand-dark);
} }
.island-card.hidden-placeholder { .island-card.hidden-placeholder {
@@ -120,7 +125,9 @@ body {
胶囊态用 0 0 0:硬轮廓投影正好压在路径底下,肉眼等同无投影,与 WinIsland 胶囊态用 0 0 0:硬轮廓投影正好压在路径底下,肉眼等同无投影,与 WinIsland
"只有展开态有投影"的观感一致。 "只有展开态有投影"的观感一致。
*/ */
filter: drop-shadow(0 var(--card-shadow-y, 0px) var(--card-shadow-blur, 0px) rgba(0, 0, 0, 0.11)); filter: drop-shadow(
0 var(--card-shadow-y, 0px) var(--card-shadow-blur, 0px) color-mix(in srgb, black 11%, transparent)
);
} }
/* 内容层裁切到同一形状内;内部两层(胶囊层 / 展开层)交叉淡入 */ /* 内容层裁切到同一形状内;内部两层(胶囊层 / 展开层)交叉淡入 */
@@ -145,7 +152,7 @@ body {
pointer-events: auto; pointer-events: auto;
} }
/* 展开态投影(WinIsland: rgba(0,0,0,.11)、y+2、σ=3 → CSS 0 2px 3px)。 /* 展开态投影(WinIsland: 11% 黑、y+2、σ=3 → CSS 0 2px 3px)。
只改参数、不动 filter 声明本身,理由见上面的 .shape path。 */ 只改参数、不动 filter 声明本身,理由见上面的 .shape path。 */
.island-card.expanded .shape path { .island-card.expanded .shape path {
--card-shadow-y: 2px; --card-shadow-y: 2px;
@@ -155,7 +162,7 @@ body {
/* 状态色:只做"内层微染 + 描边",不外溢(保持桌面干净,也不会有光晕硬边) */ /* 状态色:只做"内层微染 + 描边",不外溢(保持桌面干净,也不会有光晕硬边) */
.island-card.urgent .shape path, .island-card.urgent .shape path,
.island-card.call .shape path { .island-card.call .shape path {
stroke: color-mix(in srgb, var(--state-color) 62%, rgba(255, 255, 255, 0.2)); stroke: color-mix(in srgb, var(--state-color) 62%, var(--ci-stroke-control));
} }
.island-card .tint { .island-card .tint {
@@ -167,12 +174,20 @@ body {
.island-card.urgent .tint { .island-card.urgent .tint {
opacity: 1; opacity: 1;
background: radial-gradient(120% 90% at 50% 0%, rgba(255, 69, 58, 0.22), transparent 68%); background: radial-gradient(
120% 90% at 50% 0%,
color-mix(in srgb, var(--ci-danger) 22%, transparent),
transparent 68%
);
} }
.island-card.call .tint { .island-card.call .tint {
opacity: 1; opacity: 1;
background: radial-gradient(120% 90% at 50% 0%, rgba(255, 159, 10, 0.2), transparent 68%); background: radial-gradient(
120% 90% at 50% 0%,
color-mix(in srgb, var(--ci-warning-caution) 20%, transparent),
transparent 68%
);
} }
.island-card[data-style='tinted'] .tint { .island-card[data-style='tinted'] .tint {
@@ -242,7 +257,7 @@ body {
flex: 0 0 auto; flex: 0 0 auto;
width: calc(var(--island-font, 13px) * 1.24); width: calc(var(--island-font, 13px) * 1.24);
height: calc(var(--island-font, 13px) * 1.24); height: calc(var(--island-font, 13px) * 1.24);
border-radius: 50%; border-radius: var(--ci-radius-pill);
background: var(--wn-surface); background: var(--wn-surface);
color: var(--wn-text-1); color: var(--wn-text-1);
} }
@@ -253,11 +268,11 @@ body {
} }
.pill-icon.call { .pill-icon.call {
color: #ff9f0a; color: var(--ci-warning-caution);
} }
.pill-icon.urgent { .pill-icon.urgent {
color: #ff453a; color: var(--ci-danger);
} }
.pill-icon.homework { .pill-icon.homework {
@@ -305,8 +320,8 @@ body {
font-size: calc(var(--island-font, 13px) * 0.6); font-size: calc(var(--island-font, 13px) * 0.6);
line-height: 1.4; line-height: 1.4;
padding: 0 calc(var(--island-font, 13px) * 0.36); padding: 0 calc(var(--island-font, 13px) * 0.36);
border-radius: 999px; border-radius: var(--ci-radius-pill);
background: rgba(255, 255, 255, 0.12); background: var(--ci-fill-secondary);
color: var(--wn-text-2); color: var(--wn-text-2);
white-space: nowrap; white-space: nowrap;
} }
@@ -314,7 +329,7 @@ body {
.pill-chevron { .pill-chevron {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
color: rgba(255, 255, 255, 0.34); color: var(--ci-text-5);
flex: 0 0 auto; flex: 0 0 auto;
} }
@@ -386,7 +401,7 @@ body {
padding: 0 calc(var(--island-font, 13px) * 0.6); padding: 0 calc(var(--island-font, 13px) * 0.6);
border: none; border: none;
border-radius: calc(var(--island-font, 13px) * 0.5); border-radius: calc(var(--island-font, 13px) * 0.5);
background: rgba(255, 255, 255, 0.045); background: var(--ci-accent-soft);
color: var(--wn-text-1); color: var(--wn-text-1);
text-align: left; text-align: left;
cursor: pointer; cursor: pointer;
@@ -411,7 +426,7 @@ body {
} }
.row-icon.call { .row-icon.call {
color: #ff9f0a; color: var(--ci-warning-caution);
} }
.row-icon.homework { .row-icon.homework {
@@ -451,11 +466,11 @@ body {
flex: 0 0 auto; flex: 0 0 auto;
height: calc(var(--island-font, 13px) * 1.25); height: calc(var(--island-font, 13px) * 1.25);
padding: 0 calc(var(--island-font, 13px) * 0.5); padding: 0 calc(var(--island-font, 13px) * 0.5);
border-radius: 999px; border-radius: var(--ci-radius-pill);
font-size: calc(var(--island-font, 13px) * 0.68); font-size: calc(var(--island-font, 13px) * 0.68);
font-weight: 600; font-weight: 600;
background: rgba(255, 255, 255, 0.12); background: var(--ci-fill-secondary);
color: rgba(255, 255, 255, 0.78); color: var(--ci-text-3);
} }
/* 列表底部的提示行:能展开时是按钮,屏幕到任务栏了就是一句"去应用里看" */ /* 列表底部的提示行:能展开时是按钮,屏幕到任务栏了就是一句"去应用里看" */
@@ -511,13 +526,13 @@ body {
} }
.head-icon.urgent { .head-icon.urgent {
background: rgba(255, 69, 58, 0.2); background: color-mix(in srgb, var(--ci-danger) 20%, transparent);
color: #ff453a; color: var(--ci-danger);
} }
.head-icon.call { .head-icon.call {
background: rgba(255, 159, 10, 0.2); background: color-mix(in srgb, var(--ci-warning-caution) 20%, transparent);
color: #ff9f0a; color: var(--ci-warning-caution);
} }
.head-icon.homework { .head-icon.homework {
@@ -538,39 +553,39 @@ body {
align-items: center; align-items: center;
height: calc(var(--island-font, 13px) * 1.5); height: calc(var(--island-font, 13px) * 1.5);
padding: 0 calc(var(--island-font, 13px) * 0.62); padding: 0 calc(var(--island-font, 13px) * 0.62);
border-radius: 999px; border-radius: var(--ci-radius-pill);
font-size: calc(var(--island-font, 13px) * 0.76); font-size: calc(var(--island-font, 13px) * 0.76);
font-weight: 600; font-weight: 600;
letter-spacing: 0.02em; letter-spacing: 0.02em;
background: color-mix(in srgb, var(--island-accent) 26%, transparent); background: color-mix(in srgb, var(--island-accent) 26%, transparent);
color: color-mix(in srgb, var(--island-accent) 70%, #ffffff); color: color-mix(in srgb, var(--island-accent) 70%, var(--ci-text-1));
flex: 0 0 auto; flex: 0 0 auto;
} }
.badge-urgent { .badge-urgent {
background: rgba(255, 69, 58, 0.24); background: color-mix(in srgb, var(--ci-danger) 24%, transparent);
color: #ff6961; color: var(--ci-danger);
} }
.badge-high { .badge-high {
background: rgba(255, 159, 10, 0.22); background: color-mix(in srgb, var(--ci-warning-caution) 22%, transparent);
color: #ffb340; color: var(--ci-warning-caution);
} }
.badge-low, .badge-low,
.badge-normal { .badge-normal {
background: rgba(255, 255, 255, 0.12); background: var(--ci-fill-secondary);
color: rgba(255, 255, 255, 0.78); color: var(--ci-text-3);
} }
.badge-call { .badge-call {
background: rgba(255, 159, 10, 0.24); background: color-mix(in srgb, var(--ci-warning-caution) 24%, transparent);
color: #ffb340; color: var(--ci-warning-caution);
} }
.badge-homework { .badge-homework {
background: color-mix(in srgb, var(--island-accent) 26%, transparent); background: color-mix(in srgb, var(--island-accent) 26%, transparent);
color: color-mix(in srgb, var(--island-accent) 72%, #ffffff); color: color-mix(in srgb, var(--island-accent) 72%, var(--ci-text-1));
} }
.live-dot { .live-dot {
@@ -578,12 +593,12 @@ body {
align-items: center; align-items: center;
gap: calc(var(--island-font, 13px) * 0.32); gap: calc(var(--island-font, 13px) * 0.32);
font-size: calc(var(--island-font, 13px) * 0.76); font-size: calc(var(--island-font, 13px) * 0.76);
color: #ff6961; color: var(--ci-danger);
white-space: nowrap; white-space: nowrap;
} }
.live-dot.call { .live-dot.call {
color: #ffb340; color: var(--ci-warning-caution);
} }
.live-dot.muted { .live-dot.muted {
@@ -605,9 +620,9 @@ body {
width: calc(var(--island-font, 13px) * 1.7); width: calc(var(--island-font, 13px) * 1.7);
height: calc(var(--island-font, 13px) * 1.7); height: calc(var(--island-font, 13px) * 1.7);
border: none; border: none;
border-radius: 50%; border-radius: var(--ci-radius-pill);
background: var(--wn-surface); background: var(--wn-surface);
color: rgba(255, 255, 255, 0.72); color: var(--ci-text-3);
cursor: pointer; cursor: pointer;
flex: 0 0 auto; flex: 0 0 auto;
transition: transition:
@@ -625,7 +640,7 @@ body {
font-size: calc(var(--island-font, 13px) * 1.08); font-size: calc(var(--island-font, 13px) * 1.08);
font-weight: 700; font-weight: 700;
line-height: 1.3; line-height: 1.3;
color: #fff; color: var(--ci-text-1);
flex: 0 0 auto; flex: 0 0 auto;
display: -webkit-box; display: -webkit-box;
-webkit-line-clamp: 2; -webkit-line-clamp: 2;
@@ -654,7 +669,7 @@ body {
margin: 0; margin: 0;
font-size: calc(var(--island-font, 13px) * 0.85); font-size: calc(var(--island-font, 13px) * 0.85);
line-height: 1.4; line-height: 1.4;
color: color-mix(in srgb, var(--state-color) 66%, #ffffff); color: color-mix(in srgb, var(--state-color) 66%, var(--ci-text-1));
word-break: break-word; word-break: break-word;
} }
@@ -691,7 +706,7 @@ body {
height: calc(var(--island-font, 13px) * 2.05); height: calc(var(--island-font, 13px) * 2.05);
padding: 0 calc(var(--island-font, 13px) * 0.9); padding: 0 calc(var(--island-font, 13px) * 0.9);
border: none; border: none;
border-radius: 999px; border-radius: var(--ci-radius-pill);
font-size: calc(var(--island-font, 13px) * 0.76); font-size: calc(var(--island-font, 13px) * 0.76);
font-weight: 600; font-weight: 600;
cursor: pointer; cursor: pointer;
@@ -707,18 +722,18 @@ body {
} }
.solid-btn { .solid-btn {
background: #ffffff; background: var(--ci-text-1);
color: #0b0b0f; color: var(--ci-bg-base);
} }
.island-card.call .solid-btn { .island-card.call .solid-btn {
background: #ff9f0a; background: var(--ci-warning-caution);
color: #1a1205; color: var(--ci-brand-dark);
} }
.island-card.urgent .solid-btn { .island-card.urgent .solid-btn {
background: #ff453a; background: var(--ci-danger);
color: #ffffff; color: var(--ci-text-on-accent);
} }
.ghost-btn:active, .ghost-btn:active,
@@ -745,7 +760,7 @@ body {
.icon-btn:hover { .icon-btn:hover {
background: var(--wn-surface-hover); background: var(--wn-surface-hover);
color: #ffffff; color: var(--ci-text-1);
} }
} }
@@ -7,11 +7,12 @@
box-sizing: border-box; box-sizing: border-box;
padding: 12px; padding: 12px;
overflow: hidden; overflow: hidden;
background: var(--custom-color); background: var(--resident-background, var(--ci-island-bg-custom));
border-radius: var(--custom-radius); color: var(--ci-text-1);
border-radius: var(--resident-radius, var(--ci-radius-island));
box-shadow: box-shadow:
inset 0 0 0 1px #ffffff1e, inset 0 0 0 var(--ci-stroke-island-w) var(--ci-stroke-island),
0 2px 3px #0000001c; var(--ci-shadow-island);
} }
.custom-inner { .custom-inner {
width: max-content; width: max-content;
@@ -63,7 +64,7 @@
cursor: pointer; cursor: pointer;
} }
.custom-card[role='button']:focus-visible { .custom-card[role='button']:focus-visible {
outline: 2px solid #8dafff; outline: 2px solid var(--ci-stroke-drag);
outline-offset: -3px; outline-offset: -3px;
} }
.custom-card .resident-bell { .custom-card .resident-bell {
@@ -76,16 +77,16 @@
margin: 0; margin: 0;
padding: 4px; padding: 4px;
border: 0; border: 0;
border-radius: 6px; border-radius: var(--ci-radius-popup);
background: transparent; background: transparent;
color: #ffda8b; color: var(--ci-warning-caution);
cursor: pointer; cursor: pointer;
} }
.custom-card .resident-bell:hover { .custom-card .resident-bell:hover {
background: #ffffff1a; background: var(--ci-fill-secondary);
} }
.custom-card .resident-bell.bell-empty { .custom-card .resident-bell.bell-empty {
color: #ffffff60; color: var(--ci-text-3);
} }
.custom-card .resident-bell svg { .custom-card .resident-bell svg {
width: 18px; width: 18px;
@@ -100,13 +101,11 @@
min-width: 14px; min-width: 14px;
height: 14px; height: 14px;
padding: 0 3px; padding: 0 3px;
border-radius: 7px; border-radius: var(--ci-radius-pill);
background: #f45b58; background: var(--ci-danger);
color: white; color: var(--ci-text-on-accent);
font: font: var(--ci-fw-semi-bold) var(--ci-fs-version) / 1 var(--ci-font);
600 9px/1 'Segoe UI', box-shadow: 0 0 0 2px var(--resident-background, var(--ci-island-bg-custom));
sans-serif;
box-shadow: 0 0 0 2px var(--custom-color);
} }
.custom-card .resident-panel-heading { .custom-card .resident-panel-heading {
display: flex; display: flex;
@@ -114,17 +113,17 @@
justify-content: space-between; justify-content: space-between;
gap: 24px; gap: 24px;
padding: 4px 6px 12px; padding: 4px 6px 12px;
border-bottom: 1px solid #ffffff1a; border-bottom: var(--ci-stroke-island-w) solid var(--ci-stroke-divider);
margin-bottom: 4px; margin-bottom: 4px;
color: #ffffff94; color: var(--ci-text-2);
font-size: 12px; font-size: var(--ci-fs-caption);
} }
.custom-card .resident-panel-heading button { .custom-card .resident-panel-heading button {
min-height: 30px; min-height: 30px;
padding: 4px 10px; padding: 4px 10px;
border: 0; border: 0;
border-radius: 8px; border-radius: var(--ci-radius-control);
background: #ffffff0d; background: var(--ci-fill-secondary);
color: inherit; color: inherit;
font: inherit; font: inherit;
cursor: pointer; cursor: pointer;
@@ -135,12 +134,12 @@
gap: 6px; gap: 6px;
} }
.layout-editor .surface-tabs button { .layout-editor .surface-tabs button {
font-size: 12px; font-size: var(--ci-fs-caption);
} }
.layout-editor .surface-tabs button.active { .layout-editor .surface-tabs button.active {
color: var(--editor-accent); color: var(--ci-accent-text);
background: #edf2ff; background: var(--ci-accent-fill-tertiary);
border-color: #b6c8f0; border-color: var(--ci-stroke-drag);
} }
.custom-card .layout-row { .custom-card .layout-row {
display: flex; display: flex;
@@ -168,8 +167,8 @@
} }
.custom-card.has-alert { .custom-card.has-alert {
box-shadow: box-shadow:
inset 0 0 0 1px #ffffff2b, inset 0 0 0 var(--ci-stroke-island-w) var(--ci-stroke-control),
0 2px 3px #0000001c; var(--ci-shadow-mask);
} }
.custom-card.separated { .custom-card.separated {
background: transparent; background: transparent;
@@ -177,10 +176,10 @@
padding: 0; padding: 0;
} }
.custom-card.separated .layout-row { .custom-card.separated .layout-row {
background: var(--custom-color); background: var(--resident-background, var(--ci-island-bg-custom));
border-radius: var(--custom-radius); border-radius: var(--resident-radius, var(--ci-radius-island));
padding: 12px; padding: var(--ci-island-pad-x);
box-shadow: inset 0 0 0 1px #ffffff1e; box-shadow: inset 0 0 0 var(--ci-stroke-island-w) var(--ci-stroke-island);
} }
/* 自定义模式只保留一个岛壳。原提醒渲染器继续负责内容、动画和按钮。 */ /* 自定义模式只保留一个岛壳。原提醒渲染器继续负责内容、动画和按钮。 */
.custom-card .island-root.embedded .shape, .custom-card .island-root.embedded .shape,
@@ -198,7 +197,7 @@
justify-content: flex-start; justify-content: flex-start;
} }
.custom-card .island-root.embedded { .custom-card .island-root.embedded {
border-top: 1px solid #ffffff1a; border-top: var(--ci-stroke-island-w) solid var(--ci-stroke-divider);
} }
.custom-window .preview-stage { .custom-window .preview-stage {
width: max-content; width: max-content;
@@ -16,14 +16,48 @@
max-width: none; max-width: none;
max-height: none; max-height: none;
overflow: hidden; overflow: hidden;
clip-path: var(--card-path);
isolation: isolate; isolation: isolate;
pointer-events: auto; pointer-events: auto;
background: none; background: var(--resident-background);
border: var(--ci-stroke-island-w) solid var(--ci-stroke-island);
border-radius: var(--resident-radius); border-radius: var(--resident-radius);
color: var(--ci-text-1);
font-family: var(--ci-font-island);
font-size: var(--island-font); font-size: var(--island-font);
font-weight: var(--ci-font-weight);
line-height: 1.4; line-height: 1.4;
box-shadow: none; box-shadow: none;
z-index: var(--ci-z-content);
transition: background-color var(--ci-duration) linear;
}
.resident-window .resident-shadow {
position: absolute;
left: 50%;
top: 0;
transform: translateX(-50%);
pointer-events: none;
box-shadow: var(--ci-shadow-island);
z-index: var(--ci-z-window);
transition: opacity var(--ci-duration) linear;
}
.resident-window[data-anchor='left'] .resident-shadow {
left: 0;
transform: none;
}
.resident-window[data-anchor='right'] .resident-shadow {
left: auto;
right: 0;
transform: none;
}
.resident-window[data-bottom='true'] .resident-shadow {
top: auto;
bottom: 0;
}
.resident-window .resident-shadow-hidden {
opacity: 0;
}
.resident-window .resident-card > .shape {
display: none;
} }
.resident-window[data-anchor='left'] .resident-card { .resident-window[data-anchor='left'] .resident-card {
left: 0; left: 0;
@@ -72,10 +106,10 @@
.resident-card .resident-compact { .resident-card .resident-compact {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 6px; gap: calc(var(--ci-component-gap) / 2);
padding: 0 12px; padding: 0 var(--ci-island-pad-x);
min-height: max(40px, calc(var(--island-font) * 2.5)); min-height: var(--ci-island-height);
font-size: var(--ci-body-font, 16px); font-size: var(--ci-fs-body);
} }
.resident-window .resident-card.resident-separated { .resident-window .resident-card.resident-separated {
background: transparent; background: transparent;
@@ -88,7 +122,7 @@
align-items: center; align-items: center;
} }
.resident-separated .resident-compact .layout-row { .resident-separated .resident-compact .layout-row {
padding: 0 12px; padding: 0 var(--ci-island-pad-x);
background: var(--resident-background); background: var(--resident-background);
border-radius: var(--resident-radius); border-radius: var(--resident-radius);
} }
@@ -107,10 +141,10 @@
align-items: center; align-items: center;
justify-content: center; justify-content: center;
gap: 0; gap: 0;
min-height: max(40px, calc(var(--island-font) * 2.5)); min-height: var(--ci-island-height);
} }
.resident-card .resident-compact .component-node:not(.container) { .resident-card .resident-compact .component-node:not(.container) {
min-height: max(40px, calc(var(--island-font) * 2.5)); min-height: var(--ci-island-height);
display: flex; display: flex;
align-items: center; align-items: center;
@@ -129,7 +163,7 @@
} }
.resident-card .resident-compact .schedule { .resident-card .resident-compact .schedule {
flex-direction: row; flex-direction: row;
gap: 12px; gap: var(--ci-component-gap);
} }
.resident-card .resident-compact .schedule > div + div { .resident-card .resident-compact .schedule > div + div {
margin-top: 0; margin-top: 0;
@@ -142,14 +176,14 @@
color: inherit; color: inherit;
} }
.resident-card .resident-bell.bell-empty { .resident-card .resident-bell.bell-empty {
color: #ffffff80; color: var(--ci-text-3);
} }
.resident-card .resident-bell span { .resident-card .resident-bell span {
animation: resident-indicator-in var(--resident-fade-duration) cubic-bezier(0.25, 1, 0.5, 1); animation: resident-indicator-in var(--resident-fade-duration) cubic-bezier(0.25, 1, 0.5, 1);
} }
.resident-card .resident-details { .resident-card .resident-details {
min-width: 160px; min-width: 160px;
padding: 0 12px 12px; padding: 0 var(--ci-island-pad-x) var(--ci-island-pad-x);
text-align: center; text-align: center;
} }
.resident-card .resident-panel-heading { .resident-card .resident-panel-heading {
@@ -157,12 +191,12 @@
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
gap: 24px; gap: 24px;
height: 40px; height: var(--ci-island-height);
padding: 0 6px; padding: 0 6px;
margin: 0; margin: 0;
border: 0; border: 0;
color: #ffffff94; color: var(--ci-text-2);
font-size: 12px; font-size: var(--ci-fs-caption);
} }
.resident-card .resident-panel-heading .icon-btn { .resident-card .resident-panel-heading .icon-btn {
min-height: 28px; min-height: 28px;
@@ -176,24 +210,25 @@
display: block; display: block;
} }
.resident-card .resident-expanded-rows { .resident-card .resident-expanded-rows {
font-size: var(--ci-body-font, 16px); font-size: var(--ci-fs-body);
border-top: 1px solid #ffffff1a; border-top: var(--ci-stroke-island-w) solid var(--ci-stroke-divider);
padding-top: 8px; padding-top: calc(var(--ci-component-gap) / 2);
} }
.resident-card .resident-expanded-rows .row-components { .resident-card .resident-expanded-rows .row-components {
gap: var(--row-gap, 12px); gap: var(--row-gap, var(--ci-component-gap));
} }
.resident-card #custom-alert-host { .resident-card #custom-alert-host {
width: 100%; width: 100%;
max-width: 100%; max-width: 100%;
} }
.resident-card button:focus-visible { .resident-card button:focus-visible {
outline: 2px solid #adc4ff; outline: 2px solid var(--ci-stroke-drag);
outline-offset: -2px; outline-offset: -2px;
} }
@media (hover: hover) and (pointer: fine) { @media (hover: hover) and (pointer: fine) {
.resident-card button:hover { .resident-card button:hover {
filter: brightness(1.18); background: var(--ci-accent-soft);
color: var(--ci-text-1);
} }
} }
@keyframes resident-indicator-in { @keyframes resident-indicator-in {
@@ -240,8 +275,14 @@
} }
/* ClassIsland Fluent MainWindowLine:半透明底、1px 边框,强调遮罩只在提醒时播放。 */ /* ClassIsland Fluent MainWindowLine:半透明底、1px 边框,强调遮罩只在提醒时播放。 */
.resident-window .resident-card { .resident-window .resident-card {
--wn-bg: #20202080; --wn-bg: var(--resident-background);
--wn-border: #ffffff26; --wn-border: var(--ci-stroke-island);
--wn-text-1: var(--ci-text-1);
--wn-text-2: var(--ci-text-2);
--wn-text-3: var(--ci-text-3);
--wn-surface: var(--ci-fill-secondary);
--wn-surface-hover: var(--ci-accent-soft);
--wn-divider: var(--ci-stroke-divider);
} }
.resident-window .resident-card > .tint { .resident-window .resident-card > .tint {
display: none; display: none;
@@ -250,6 +291,9 @@
fill: transparent; fill: transparent;
stroke: none; stroke: none;
} }
.resident-window .resident-card.message-surface { .resident-card.resident-lesson {
--wn-bg: #202020; border-color: transparent;
}
.resident-window .resident-card.message-surface {
--resident-background: var(--ci-brand-dark);
} }
@@ -6,11 +6,11 @@
flex: 0 0 auto; flex: 0 0 auto;
width: 30px; width: 30px;
height: 30px; height: 30px;
border-radius: 50%; border-radius: var(--ci-radius-pill);
color: #fff; color: var(--ci-text-on-accent);
background: #0a84ff; background: var(--ci-accent-fill);
font-size: 12px; font-size: var(--ci-fs-caption);
font-weight: 600; font-weight: var(--ci-fw-semi-bold);
font-variant-numeric: tabular-nums; font-variant-numeric: tabular-nums;
line-height: 1; line-height: 1;
} }
@@ -136,6 +136,14 @@ function normalizeIslandAppearance(input?: Partial<IslandAppearance>): IslandApp
'bottom-right', 'bottom-right',
]; ];
const styles: IslandAppearance['style'][] = ['black', 'glass', 'tinted']; const styles: IslandAppearance['style'][] = ['black', 'glass', 'tinted'];
const accentPalette = Array.isArray(input?.accentPalette)
? input.accentPalette
.filter((value): value is string => typeof value === 'string' && /^#[0-9a-fA-F]{6}$/.test(value))
.slice(0, 32)
: [...DEFAULT_ISLAND_APPEARANCE.accentPalette];
const accentSource = [0, 1, 2, 3].includes(input?.accentSource as number)
? (input?.accentSource as IslandAppearance['accentSource'])
: DEFAULT_ISLAND_APPEARANCE.accentSource;
return { return {
height: clamp(input?.height, 36, 72, DEFAULT_ISLAND_APPEARANCE.height), height: clamp(input?.height, 36, 72, DEFAULT_ISLAND_APPEARANCE.height),
width: clamp(input?.width, 220, 420, DEFAULT_ISLAND_APPEARANCE.width), width: clamp(input?.width, 220, 420, DEFAULT_ISLAND_APPEARANCE.width),
@@ -145,6 +153,11 @@ function normalizeIslandAppearance(input?: Partial<IslandAppearance>): IslandApp
typeof input?.accent === 'string' && /^#[0-9a-fA-F]{6}$/.test(input.accent) typeof input?.accent === 'string' && /^#[0-9a-fA-F]{6}$/.test(input.accent)
? input.accent ? input.accent
: DEFAULT_ISLAND_APPEARANCE.accent, : DEFAULT_ISLAND_APPEARANCE.accent,
accentSource,
accentPalette: accentPalette.length ? accentPalette : [...DEFAULT_ISLAND_APPEARANCE.accentPalette],
accentPaletteIndex: Math.round(
clamp(input?.accentPaletteIndex, 0, Math.max(0, accentPalette.length - 1), 0),
),
fontSize: clamp(input?.fontSize, 11, 20, DEFAULT_ISLAND_APPEARANCE.fontSize), fontSize: clamp(input?.fontSize, 11, 20, DEFAULT_ISLAND_APPEARANCE.fontSize),
animations: input?.animations !== false, animations: input?.animations !== false,
speed: clamp(input?.speed, 0.5, 2, DEFAULT_ISLAND_APPEARANCE.speed), speed: clamp(input?.speed, 0.5, 2, DEFAULT_ISLAND_APPEARANCE.speed),
+1
View File
@@ -40,6 +40,7 @@ export function registerIpcHandlers(): void {
delete allowed.pendingUpdateVersion; delete allowed.pendingUpdateVersion;
const saved = saveConfig(allowed); const saved = saveConfig(allowed);
if (allowed.islandLayout) island.syncCustomLayout(); if (allowed.islandLayout) island.syncCustomLayout();
if (allowed.theme !== undefined) island.syncTheme();
return saved; return saved;
}, },
); );
+67 -7
View File
@@ -4,9 +4,10 @@ import type {
} from '@classhelper/shared'; } from '@classhelper/shared';
import path from 'node:path'; import path from 'node:path';
import { pathToFileURL } from 'node:url'; import { pathToFileURL } from 'node:url';
import { BrowserWindow, ipcMain, screen } from 'electron'; import { BrowserWindow, ipcMain, screen, systemPreferences } from 'electron';
import { import {
COURSEWARE_ISLAND_SIZE, COURSEWARE_ISLAND_SIZE,
CLASSISLAND_TOKENS,
type CoursewareTransfer, type CoursewareTransfer,
DEFAULT_ISLAND_APPEARANCE, DEFAULT_ISLAND_APPEARANCE,
CLASSISLAND_ISLAND_METRICS, CLASSISLAND_ISLAND_METRICS,
@@ -336,6 +337,13 @@ class IslandController {
this.syncResidentShape(true); this.syncResidentShape(true);
this.syncWindow(); this.syncWindow();
} }
/** 主题独立于外观补丁,主窗口切肤时实时同步给岛渲染进程。 */
syncTheme(): void {
if (!this.win || this.win.isDestroyed()) return;
this.win.webContents.send('island:theme', getConfig().theme);
}
/** 仅用于首次切换布局、启动与退出编辑;日常常驻岛开合保持窗口可见。 */ /** 仅用于首次切换布局、启动与退出编辑;日常常驻岛开合保持窗口可见。 */
private settleCustomLayout(): void { private settleCustomLayout(): void {
if (this.layoutSettleTimer) clearTimeout(this.layoutSettleTimer); if (this.layoutSettleTimer) clearTimeout(this.layoutSettleTimer);
@@ -623,6 +631,7 @@ class IslandController {
} }
// 首次进入时同步一次外观与状态,保证渲染进程不会停在初始默认值 // 首次进入时同步一次外观与状态,保证渲染进程不会停在初始默认值
this.emitAppearance(); this.emitAppearance();
this.syncTheme();
this.win?.webContents.send('island:schedules', this.schedules); this.win?.webContents.send('island:schedules', this.schedules);
this.win?.webContents.send('island:time-points', this.timePoints); this.win?.webContents.send('island:time-points', this.timePoints);
this.emit(); this.emit();
@@ -774,7 +783,7 @@ class IslandController {
private refreshViewport(): void { private refreshViewport(): void {
const area = this.targetDisplay().workArea; const area = this.targetDisplay().workArea;
const anchor = this.resolveAnchor(); const anchor = this.resolveAnchor();
const marginY = Math.round(this.appearance.marginY ?? ISLAND_MARGIN); const marginY = this.verticalMargin();
const available = const available =
anchor.vMode === 'bottom' anchor.vMode === 'bottom'
? anchor.vValue - (area.y + marginY) ? anchor.vValue - (area.y + marginY)
@@ -1333,7 +1342,7 @@ class IslandController {
const display = this.targetDisplay(); const display = this.targetDisplay();
const area = display.workArea; const area = display.workArea;
const marginX = Math.round(this.appearance.marginX ?? ISLAND_MARGIN); const marginX = Math.round(this.appearance.marginX ?? ISLAND_MARGIN);
const marginY = Math.round(this.appearance.marginY ?? ISLAND_MARGIN); const marginY = this.verticalMargin();
const center = Math.round(area.x + area.width / 2); const center = Math.round(area.x + area.width / 2);
// 6 个停靠位置(顶/底 × 左/中/右),与 WinIsland 的 DockPosition 一一对应 // 6 个停靠位置(顶/底 × 左/中/右),与 WinIsland 的 DockPosition 一一对应
@@ -1350,6 +1359,12 @@ class IslandController {
return { hMode, hValue, vMode, vValue }; return { hMode, hValue, vMode, vValue };
} }
/** 自定义岛遵循 ClassIsland Fluent 的 20px 竖直安全区;经典岛保留原有外观边距。 */
private verticalMargin(): number {
const configured = Math.round(this.appearance.marginY ?? ISLAND_MARGIN);
return this.customLayout ? Math.max(configured, CLASSISLAND_TOKENS.dpi.verticalSafeArea) : configured;
}
/** 当前应该把岛放在哪块屏上:跟随鼠标时用光标所在屏,否则用主屏 */ /** 当前应该把岛放在哪块屏上:跟随鼠标时用光标所在屏,否则用主屏 */
private targetDisplay(cursor?: { x: number; y: number } | null): Electron.Display { private targetDisplay(cursor?: { x: number; y: number } | null): Electron.Display {
return this.appearance.followCursorDisplay return this.appearance.followCursorDisplay
@@ -1524,7 +1539,7 @@ class IslandController {
// 与 ClassIsland 一样,让背景/内容在固定画布内过渡。预留一帧绘制边界,避免过冲裁切。 // 与 ClassIsland 一样,让背景/内容在固定画布内过渡。预留一帧绘制边界,避免过冲裁切。
return { return {
width: Math.min(960, area.width), width: Math.min(960, area.width),
height: Math.min(640, Math.max(60, area.height - this.appearance.marginY)), height: Math.min(640, Math.max(60, area.height - this.verticalMargin())),
}; };
} }
if (this.customLayout) if (this.customLayout)
@@ -1735,14 +1750,14 @@ class IslandController {
* 2. 材质的明暗跟随**应用主题**:本客户端是浅色 Fluent 主题,亚克力必然是浅色, * 2. 材质的明暗跟随**应用主题**:本客户端是浅色 Fluent 主题,亚克力必然是浅色,
* 无法像 WinIsland 那样自带深色 tint(`Color::from_argb(150, 10, 10, 14)`)。 * 无法像 WinIsland 那样自带深色 tint(`Color::from_argb(150, 10, 10, 14)`)。
* 3. 更糟的是:只要调用过一次(**包括 `'none'`**),窗口就再也不是逐像素透明的了 —— * 3. 更糟的是:只要调用过一次(**包括 `'none'`**),窗口就再也不是逐像素透明的了 ——
* Electron 会让它回落到默认不透明底色(`backgroundColor` 默认 `#FFF`), * Electron 会让它回落到默认不透明白色底,
* 于是从 `glass` 切到 `black` / `tinted` 之后,卡片周围会永久留一圈**纯白**。 * 于是从 `glass` 切到 `black` / `tinted` 之后,卡片周围会永久留一圈**纯白**。
* 这正好对应"毛玻璃和主题色渐变会出现白底"的现象。 * 这正好对应"毛玻璃和主题色渐变会出现白底"的现象。
* 4. CSS `backdrop-filter: blur()` 也不能替代:透明窗口里 Chromium 采样不到窗口之后的桌面, * 4. CSS `backdrop-filter: blur()` 也不能替代:透明窗口里 Chromium 采样不到窗口之后的桌面,
* 真机实测与不加模糊的像素完全一致(卡片区域离散度都是 12.7)。 * 真机实测与不加模糊的像素完全一致(卡片区域离散度都是 12.7)。
* *
* 结论:`glass` 风格改为**纯 CSS 半透明深色卡片**(取 WinIsland 拿不到 host backdrop 时的 * 结论:`glass` 风格改为**纯 CSS 半透明深色卡片**(取 WinIsland 拿不到 host backdrop 时的
* 官方降级色 `rgba(32,32,36,0.804)`,见 `docs/dev/winisland-design-tokens.md`), * 官方 80.4% 深色降级底,见 `docs/dev/winisland-design-tokens.md`),
* 桌面透过率由卡片自身 alpha 决定,窗口始终保持 `transparent: true` 的逐像素透明。 * 桌面透过率由卡片自身 alpha 决定,窗口始终保持 `transparent: true` 的逐像素透明。
* 回归用例:「个性设置:卡片外圈透出桌面(三种风格都没有白底面板)」。 * 回归用例:「个性设置:卡片外圈透出桌面(三种风格都没有白底面板)」。
*/ */
@@ -2173,7 +2188,40 @@ class IslandController {
} }
getAppearance(): IslandAppearance { getAppearance(): IslandAppearance {
return { ...this.appearance }; return { ...this.appearance, resolvedAccent: this.effectiveAccent() };
}
/** ClassIsland ColorSource 分支;1/3 取已选调色板,2 取系统强调色。 */
private effectiveAccent(): string {
const fallback = CLASSISLAND_TOKENS.colors.light.accentPaletteFallback;
const { accentSource, accent, accentPalette, accentPaletteIndex } = this.appearance;
if (accentSource === 0) return accent || fallback;
if (accentSource === 1 || accentSource === 3) {
return accentPalette[accentPaletteIndex] ?? fallback;
}
if (accentSource === 2) {
try {
let value: string | boolean | undefined;
try {
value = systemPreferences.getAccentColor?.();
} catch {
// Windows 旧系统可能只在窗口 API 暴露系统强调色。
}
if (typeof value !== 'string' && process.platform === 'win32') value = this.win?.getAccentColor();
if (typeof value === 'string') {
const hex = value.replace('#', '');
return `#${hex.length === 8 ? hex.slice(0, 6) : hex.slice(-6)}`;
}
} catch {
// 平台不提供系统强调色时走 ClassIsland 的 DodgerBlue 兜底。
}
}
return fallback;
}
/** 系统强调色变化时仅刷新“跟随系统”来源,不影响自定义色和其他来源。 */
syncSystemAccent(): void {
if (this.appearance.accentSource === 2) this.emitAppearance();
} }
/** 把外观同步给灵动岛渲染进程(CSS 变量) */ /** 把外观同步给灵动岛渲染进程(CSS 变量) */
@@ -2243,12 +2291,22 @@ const clamp = (value: number, min: number, max: number, fallback: number): numbe
/** 夹紧外观取值(越界值直接收敛,避免用户配置破坏布局) */ /** 夹紧外观取值(越界值直接收敛,避免用户配置破坏布局) */
export function normalizeAppearance(input: IslandAppearance): IslandAppearance { export function normalizeAppearance(input: IslandAppearance): IslandAppearance {
const fallbackOf = DEFAULT_ISLAND_APPEARANCE; const fallbackOf = DEFAULT_ISLAND_APPEARANCE;
const accentPalette = Array.isArray(input.accentPalette)
? input.accentPalette
.filter((value) => typeof value === 'string' && /^#[0-9a-fA-F]{6}$/.test(value))
.slice(0, 32)
: [...fallbackOf.accentPalette];
return { return {
height: clamp(input.height, 36, 72, fallbackOf.height), height: clamp(input.height, 36, 72, fallbackOf.height),
width: clamp(input.width, 220, 420, fallbackOf.width), width: clamp(input.width, 220, 420, fallbackOf.width),
radius: clamp(input.radius, 8, 32, fallbackOf.radius), radius: clamp(input.radius, 8, 32, fallbackOf.radius),
opacity: clamp(input.opacity, 0.4, 1, fallbackOf.opacity), opacity: clamp(input.opacity, 0.4, 1, fallbackOf.opacity),
accent: /^#[0-9a-fA-F]{6}$/.test(input.accent) ? input.accent : DEFAULT_ISLAND_APPEARANCE.accent, accent: /^#[0-9a-fA-F]{6}$/.test(input.accent) ? input.accent : DEFAULT_ISLAND_APPEARANCE.accent,
accentSource: [0, 1, 2, 3].includes(input.accentSource) ? input.accentSource : fallbackOf.accentSource,
accentPalette: accentPalette.length ? accentPalette : [...fallbackOf.accentPalette],
accentPaletteIndex: Math.round(
clamp(input.accentPaletteIndex, 0, Math.max(0, accentPalette.length - 1), 0),
),
fontSize: clamp(input.fontSize, 11, 20, fallbackOf.fontSize), fontSize: clamp(input.fontSize, 11, 20, fallbackOf.fontSize),
animations: input.animations !== false, animations: input.animations !== false,
speed: clamp(input.speed, 0.5, 2, fallbackOf.speed), speed: clamp(input.speed, 0.5, 2, fallbackOf.speed),
@@ -2336,6 +2394,8 @@ export const island = new IslandController();
/** 注册灵动岛相关 IPC(主窗口渲染进程 -> 主进程;灵动岛渲染进程 -> 主进程) */ /** 注册灵动岛相关 IPC(主窗口渲染进程 -> 主进程;灵动岛渲染进程 -> 主进程) */
export function registerIslandIpc(): void { export function registerIslandIpc(): void {
systemPreferences.on('accent-color-changed', () => island.syncSystemAccent());
ipcMain.handle('island:get-theme', () => getConfig().theme);
ipcMain.handle('island:get-schedules', (event) => ipcMain.handle('island:get-schedules', (event) =>
event.sender === island.getWindow()?.webContents ? island.getSchedules() : [], event.sender === island.getWindow()?.webContents ? island.getSchedules() : [],
); );
@@ -403,8 +403,10 @@ export async function verifyLayoutSmoke(
await pause(); await pause();
const result = await win.webContents.executeJavaScript(`(() => { const result = await win.webContents.executeJavaScript(`(() => {
const card=document.querySelector('.resident-card'), content=card?.querySelector('.classic-notifications'),r=card?.getBoundingClientRect(),c=content?.getBoundingClientRect(); const card=document.querySelector('.resident-card'), content=card?.querySelector('.classic-notifications'),r=card?.getBoundingClientRect(),c=content?.getBoundingClientRect();
const valid=Boolean(content&&content.textContent.includes('组件化提醒验收')&&card.querySelectorAll('.shape').length===1&&c.left>=r.left-1&&c.right<=r.right+1&&c.bottom<=r.bottom+1); const shape=card?.querySelectorAll('.shape').length;
return {valid,card:r?.toJSON(),content:c?.toJSON(),shape:card?.querySelectorAll('.shape').length}; const radius=parseFloat(card ? getComputedStyle(card).borderTopLeftRadius : '0');
const valid=Boolean(content&&content.textContent.includes('组件化提醒验收')&&shape===0&&radius>0&&c.left>=r.left-1&&c.right<=r.right+1&&c.bottom<=r.bottom+1);
return {valid,card:r?.toJSON(),content:c?.toJSON(),shape,radius};
})()`); })()`);
if (!result.valid) throw Error(JSON.stringify(result)); if (!result.valid) throw Error(JSON.stringify(result));
return island.getState().mode === 'expanded'; return island.getState().mode === 'expanded';
@@ -910,9 +910,12 @@ export async function verifyResidentSmoke(
const solid = await win.webContents.executeJavaScript(`(() => { const solid = await win.webContents.executeJavaScript(`(() => {
const card=document.querySelector('${layout === 'custom' ? '.resident-card' : '.island-card'}'); const card=document.querySelector('${layout === 'custom' ? '.resident-card' : '.island-card'}');
if (!card?.classList.contains('message-surface')) return false; if (!card?.classList.contains('message-surface')) return false;
let color=getComputedStyle(card).backgroundColor;
if (${JSON.stringify(layout)} === 'fixed') {
const probe=document.createElement('span');probe.style.background='var(--wn-bg)';card.append(probe); const probe=document.createElement('span');probe.style.background='var(--wn-bg)';card.append(probe);
const color=getComputedStyle(probe).backgroundColor;probe.remove(); color=getComputedStyle(probe).backgroundColor;probe.remove();
return color==='rgb(32, 32, 32)'&&!!card.querySelector('.classic-notifications'); }
return color!=='transparent'&&!color.includes('rgba')&&!!card.querySelector('.classic-notifications');
})()`); })()`);
if (!solid || Math.abs(win.getOpacity() - 1) > 0.01 || island.getAppearance().opacity !== 0.45) if (!solid || Math.abs(win.getOpacity() - 1) > 0.01 || island.getAppearance().opacity !== 0.45)
return false; return false;
@@ -933,12 +936,15 @@ export async function verifyResidentSmoke(
island.setClassState({ inClass: false, currentPeriodEnd: null, week: 1 }); island.setClassState({ inClass: false, currentPeriodEnd: null, week: 1 });
saveConfig({ islandLayout: defaultIslandLayouts() }); saveConfig({ islandLayout: defaultIslandLayouts() });
island.syncCustomLayout(); island.syncCustomLayout();
await pause(); await pause(400);
return ( const visible = win.isVisible();
!win.isVisible() && const residentEnabled = getConfig().islandLayout.residentEnabled;
!getConfig().islandLayout.residentEnabled && const customDom = await win.webContents.executeJavaScript(
(await win.webContents.executeJavaScript(`!document.querySelector('.custom-card')`)) `Boolean(document.querySelector('.custom-card'))`,
); );
if (visible || residentEnabled || customDom)
throw new Error(JSON.stringify({ visible, residentEnabled, customDom }));
return true;
}); });
island.setHitTestCursor(null); island.setHitTestCursor(null);
island.setTouchMode(originalTouchMode); island.setTouchMode(originalTouchMode);
+4 -4
View File
@@ -2659,7 +2659,7 @@ async function runIslandChecks(
h: style.getPropertyValue('--island-h').trim(), h: style.getPropertyValue('--island-h').trim(),
w: style.getPropertyValue('--island-w').trim(), w: style.getPropertyValue('--island-w').trim(),
font: style.getPropertyValue('--island-font').trim(), font: style.getPropertyValue('--island-font').trim(),
accent: style.getPropertyValue('--island-accent').trim(), accent: style.getPropertyValue('--ci-accent').trim(),
}; };
})()`, })()`,
) )
@@ -2716,7 +2716,7 @@ async function runIslandChecks(
w: style.getPropertyValue('--island-w').trim(), w: style.getPropertyValue('--island-w').trim(),
radius: style.getPropertyValue('--island-radius').trim(), radius: style.getPropertyValue('--island-radius').trim(),
font: style.getPropertyValue('--island-font').trim(), font: style.getPropertyValue('--island-font').trim(),
accent: style.getPropertyValue('--island-accent').trim(), accent: style.getPropertyValue('--ci-accent').trim(),
cardHeight: card ? Math.round(card.getBoundingClientRect().height) : 0, cardHeight: card ? Math.round(card.getBoundingClientRect().height) : 0,
}; };
})()`, })()`,
@@ -3302,9 +3302,9 @@ async function runIslandChecks(
island.setAppearance({ ...appearanceBefore, accent: '#ff7043' }); island.setAppearance({ ...appearanceBefore, accent: '#ff7043' });
await sleep(200); await sleep(200);
const accentVar = await islandWindow?.webContents.executeJavaScript( const accentVar = await islandWindow?.webContents.executeJavaScript(
`getComputedStyle(document.documentElement).getPropertyValue('--island-accent').trim()`, `getComputedStyle(document.documentElement).getPropertyValue('--ci-accent').trim()`,
); );
record('个性设置:主题色生效(CSS 变量)', accentVar === '#ff7043', `CSS --island-accent=${accentVar}`); record('个性设置:主题色生效(CSS 变量)', accentVar === '#ff7043', `CSS --ci-accent=${accentVar}`);
// 11.2b) 三种视觉风格的**底色**:黑 / 毛玻璃 / 主题色渐变都必须是深色卡片 // 11.2b) 三种视觉风格的**底色**:黑 / 毛玻璃 / 主题色渐变都必须是深色卡片
// 并且卡片**外面那一圈**必须完全透明(用户反馈:毛玻璃与主题色渐变会出现白底 —— // 并且卡片**外面那一圈**必须完全透明(用户反馈:毛玻璃与主题色渐变会出现白底 ——
@@ -12,6 +12,8 @@ import type { IslandAppearance, IslandState } from '@classhelper/shared';
* 只暴露「订阅状态/外观」与「发送用户操作」两件事,渲染进程不接触任何 Node 能力。 * 只暴露「订阅状态/外观」与「发送用户操作」两件事,渲染进程不接触任何 Node 能力。
*/ */
export interface IslandBridge { export interface IslandBridge {
getTheme(): Promise<'light' | 'dark'>;
onTheme(handler: (theme: 'light' | 'dark') => void): void;
getIslandWeather(coordinates: { latitude: number; longitude: number }): Promise<IslandWeather>; getIslandWeather(coordinates: { latitude: number; longitude: number }): Promise<IslandWeather>;
getLayout(): Promise<ContractIslandLayoutSettings>; getLayout(): Promise<ContractIslandLayoutSettings>;
saveLayout(value: ContractIslandLayoutSettings): Promise<ContractIslandLayoutSettings>; saveLayout(value: ContractIslandLayoutSettings): Promise<ContractIslandLayoutSettings>;
@@ -62,6 +64,10 @@ export interface IslandBridge {
} }
const bridge: IslandBridge = { const bridge: IslandBridge = {
getTheme: () => ipcRenderer.invoke('island:get-theme'),
onTheme: (handler) => {
ipcRenderer.on('island:theme', (_event, theme: 'light' | 'dark') => handler(theme));
},
getIslandWeather: (coordinates) => ipcRenderer.invoke('island:weather', coordinates), getIslandWeather: (coordinates) => ipcRenderer.invoke('island:weather', coordinates),
getLayout: () => ipcRenderer.invoke('island:get-layout'), getLayout: () => ipcRenderer.invoke('island:get-layout'),
saveLayout: (value) => ipcRenderer.invoke('island:save-layout', value), saveLayout: (value) => ipcRenderer.invoke('island:save-layout', value),
@@ -1,6 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, ref, watch } from 'vue'; import { computed, ref, watch } from 'vue';
import { import {
CLASSISLAND_TOKENS,
ISLAND_COMPONENT_LABELS, ISLAND_COMPONENT_LABELS,
type IslandComponentNode, type IslandComponentNode,
type IslandComponentKind, type IslandComponentKind,
@@ -180,8 +181,9 @@ const containers = ['group', 'stack', 'slide', 'rolling'] as const;
<el-input-number <el-input-number
v-model="node.appearance[key]" v-model="node.appearance[key]"
:disabled="!node.appearance.resourceOverridingEnabled" :disabled="!node.appearance.resourceOverridingEnabled"
:min="8" :min="CLASSISLAND_TOKENS.fontSizes.inputMin"
:max="96" :max="CLASSISLAND_TOKENS.fontSizes.inputMax"
:step="CLASSISLAND_TOKENS.fontSizes.inputStep"
@change="emit('change')" @change="emit('change')"
/> />
</el-form-item> </el-form-item>
@@ -234,7 +236,8 @@ const containers = ['group', 'stack', 'slide', 'rolling'] as const;
v-if="node.appearance.customCornerRadiusEnabled" v-if="node.appearance.customCornerRadiusEnabled"
v-model="node.appearance.cornerRadius" v-model="node.appearance.cornerRadius"
:min="0" :min="0"
:max="100" :max="CLASSISLAND_TOKENS.radii.islandMax"
:step="CLASSISLAND_TOKENS.radii.islandStep"
@change="emit('change')" @change="emit('change')"
/> />
</el-form-item> </el-form-item>
@@ -195,10 +195,12 @@
flex-direction: column; flex-direction: column;
gap: var(--preview-gap); gap: var(--preview-gap);
width: max-content; width: max-content;
color: #ffffffeb; color: var(--ci-text-1);
padding: 12px; padding: var(--ci-island-pad-x);
border-radius: var(--preview-radius); border-radius: var(--preview-radius);
background: #202024; background: var(--preview-background);
font-family: var(--ci-font-island);
font-weight: var(--ci-font-weight);
} }
.preview-row { .preview-row {
display: flex; display: flex;
@@ -212,14 +214,14 @@
padding: 0; padding: 0;
} }
.separated .preview-row { .separated .preview-row {
padding: 12px; padding: var(--ci-island-pad-x);
background: #202024; background: var(--preview-background);
} }
.empty-preview { .empty-preview {
color: #ffffffb8; color: var(--ci-text-2);
background: transparent; background: transparent;
border: 1px dashed #ffffff60; border: var(--ci-stroke-island-w) dashed var(--ci-stroke-control);
border-radius: 5px; border-radius: var(--ci-radius-control);
padding: 10px 20px; padding: 10px 20px;
cursor: pointer; cursor: pointer;
font: inherit; font: inherit;
@@ -246,6 +248,19 @@
line-height: 1.6; line-height: 1.6;
font-size: 12px; font-size: 12px;
} }
.font-preview {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: calc(var(--ci-line-gap) * 2);
margin: 0 0 18px;
padding: var(--ci-popup-pad);
border: var(--ci-stroke-island-w) solid var(--ci-stroke-island);
border-radius: var(--ci-radius-card);
background: var(--ci-island-bg-custom);
line-height: var(--ci-line-height-body);
overflow: auto;
}
.component-library { .component-library {
border-top: 1px solid var(--ch-border); border-top: 1px solid var(--ch-border);
margin: 0 -24px; margin: 0 -24px;
@@ -4,6 +4,7 @@ import { onBeforeRouteLeave, useRouter } from 'vue-router';
import { ElMessage, ElMessageBox } from 'element-plus'; import { ElMessage, ElMessageBox } from 'element-plus';
import { import {
CLASSISLAND_ISLAND_METRICS as METRICS, CLASSISLAND_ISLAND_METRICS as METRICS,
CLASSISLAND_TOKENS,
DEFAULT_ISLAND_APPEARANCE, DEFAULT_ISLAND_APPEARANCE,
ISLAND_COMPONENT_LABELS, ISLAND_COMPONENT_LABELS,
defaultIslandLayouts, defaultIslandLayouts,
@@ -44,6 +45,63 @@ const scheme = computed(() =>
); );
const rows = computed(() => (surface.value === 'expanded' ? scheme.value.expandedRows : scheme.value.rows)); const rows = computed(() => (surface.value === 'expanded' ? scheme.value.expandedRows : scheme.value.rows));
const activeRow = computed(() => rows.value.find((row) => row.id === rowId.value) ?? rows.value[0]!); const activeRow = computed(() => rows.value.find((row) => row.id === rowId.value) ?? rows.value[0]!);
const fontFields = [
{ key: 'secondaryFontSize', label: '辅助文字' },
{ key: 'bodyFontSize', label: '正文' },
{ key: 'emphasizedFontSize', label: '强调文字' },
{ key: 'largeFontSize', label: '大号文字' },
] as const;
const fontWeights = [
{ value: CLASSISLAND_TOKENS.fontWeights.thin, label: '100 Thin' },
{ value: CLASSISLAND_TOKENS.fontWeights.extraLight, label: '200 ExtraLight' },
{ value: CLASSISLAND_TOKENS.fontWeights.light, label: '300 Light' },
{ value: CLASSISLAND_TOKENS.fontWeights.normal, label: '400 Normal' },
{ value: CLASSISLAND_TOKENS.fontWeights.medium, label: '500 Medium(默认)' },
{ value: CLASSISLAND_TOKENS.fontWeights.semiBold, label: '600 SemiBold' },
{ value: CLASSISLAND_TOKENS.fontWeights.bold, label: '700 Bold' },
{ value: CLASSISLAND_TOKENS.fontWeights.extraBold, label: '800 ExtraBold' },
{ value: CLASSISLAND_TOKENS.fontWeights.black, label: '900 Black' },
] as const;
function rowStyle(row: IslandLayoutRow): Record<string, string> {
const style: Record<string, string> = {
'--row-gap': `${row.gap}px`,
opacity: String(row.opacity),
};
if (row.fontOverridesEnabled) {
style['--ci-fs-secondary'] = `${row.secondaryFontSize}px`;
style['--ci-fs-body'] = `${row.bodyFontSize}px`;
style['--ci-fs-emphasized'] = `${row.emphasizedFontSize}px`;
style['--ci-fs-large'] = `${row.largeFontSize}px`;
}
return style;
}
function previewStyle(): Record<string, string> {
const foreground: Record<string, string> = scheme.value.customForegroundEnabled
? {
'--ci-text-1': scheme.value.foreground,
'--ci-text-2': `color-mix(in srgb, ${scheme.value.foreground} 85.5%, transparent)`,
'--ci-text-3': `color-mix(in srgb, ${scheme.value.foreground} 77.3%, transparent)`,
'--ci-text-4': `color-mix(in srgb, ${scheme.value.foreground} 52.9%, transparent)`,
'--ci-text-5': `color-mix(in srgb, ${scheme.value.foreground} 36.5%, transparent)`,
}
: {};
return {
zoom: String(scheme.value.scale * zoom.value),
'--preview-gap': `${scheme.value.spacing}px`,
'--preview-radius': `${scheme.value.radius}px`,
'--preview-background': scheme.value.customBackgroundEnabled
? `color-mix(in srgb, ${scheme.value.color} ${scheme.value.opacity * 100}%, transparent)`
: 'var(--ci-bg-secondary)',
'--ci-fs-secondary': `${scheme.value.secondaryFontSize}px`,
'--ci-fs-body': `${scheme.value.bodyFontSize}px`,
'--ci-fs-emphasized': `${scheme.value.emphasizedFontSize}px`,
'--ci-fs-large': `${scheme.value.largeFontSize}px`,
'--ci-font-weight': String(scheme.value.fontWeight),
'--ci-accent': appearance.value.resolvedAccent ?? appearance.value.accent,
fontSize: `${scheme.value.bodyFontSize}px`,
...foreground,
};
}
const state: IslandState = { const state: IslandState = {
mode: 'hidden', mode: 'hidden',
active: null, active: null,
@@ -150,6 +208,12 @@ function addRow() {
main: false, main: false,
allowNotifications: true, allowNotifications: true,
gap: 8, gap: 8,
opacity: CLASSISLAND_TOKENS.opacity.line,
fontOverridesEnabled: false,
secondaryFontSize: CLASSISLAND_TOKENS.fontSizes.secondary,
bodyFontSize: CLASSISLAND_TOKENS.fontSizes.body,
emphasizedFontSize: CLASSISLAND_TOKENS.fontSizes.emphasized,
largeFontSize: CLASSISLAND_TOKENS.fontSizes.large,
nodes: [], nodes: [],
}; };
rows.value.push(row); rows.value.push(row);
@@ -693,27 +757,14 @@ function dropPreview(event: PointerEvent) {
</div> </div>
</section> </section>
</div> </div>
<div <div v-else class="island-preview" :class="{ separated: scheme.separated }" :style="previewStyle()">
v-else
class="island-preview"
:class="{ separated: scheme.separated }"
:style="{
zoom: scheme.scale * zoom,
'--preview-gap': `${scheme.spacing}px`,
'--preview-radius': `${scheme.radius}px`,
'--secondary': `${(appearance.fontSize / 13) * 14}px`,
'--emphasized': `${(appearance.fontSize / 13) * 18}px`,
'--large': `${(appearance.fontSize / 13) * 20}px`,
fontSize: `${(appearance.fontSize / 13) * 16}px`,
}"
>
<section <section
v-for="row in rows" v-for="row in rows"
:key="row.id" :key="row.id"
class="preview-row" class="preview-row"
:class="{ 'drop-row': drop?.row.id === row.id && !drop.node }" :class="{ 'drop-row': drop?.row.id === row.id && !drop.node }"
:data-row="row.id" :data-row="row.id"
:style="{ gap: `${row.gap}px` }" :style="rowStyle(row)"
@click.self="selectRow(row.id)" @click.self="selectRow(row.id)"
> >
<ComponentNode <ComponentNode
@@ -814,6 +865,30 @@ function dropPreview(event: PointerEvent) {
<el-form-item label="组件间距"> <el-form-item label="组件间距">
<el-input-number v-model="activeRow.gap" :min="0" :max="64" @change="save" /> <el-input-number v-model="activeRow.gap" :min="0" :max="64" @change="save" />
</el-form-item> </el-form-item>
<el-form-item label="整行透明度">
<el-slider
v-model="activeRow.opacity"
:min="0"
:max="1"
:step="0.05"
:format-tooltip="(value: number) => value.toFixed(2)"
@change="save"
/>
</el-form-item>
<el-form-item label="行级字号覆盖">
<el-switch v-model="activeRow.fontOverridesEnabled" @change="save" />
</el-form-item>
<el-form-item v-for="field in fontFields" :key="field.key" :label="`${field.label}字号(px)`">
<el-input-number
v-model="activeRow[field.key]"
:disabled="!activeRow.fontOverridesEnabled"
:min="CLASSISLAND_TOKENS.fontSizes.inputMin"
:max="CLASSISLAND_TOKENS.fontSizes.inputMax"
:step="CLASSISLAND_TOKENS.fontSizes.inputStep"
@change="save"
/>
</el-form-item>
<p class="hint">行级字号只写到当前行根元素;关闭覆盖后回落到方案字号。</p>
<el-form-item label="允许显示提醒"> <el-form-item label="允许显示提醒">
<el-switch v-model="activeRow.allowNotifications" @change="save" /> <el-switch v-model="activeRow.allowNotifications" @change="save" />
</el-form-item> </el-form-item>
@@ -839,20 +914,81 @@ function dropPreview(event: PointerEvent) {
v-model="scheme.scale" v-model="scheme.scale"
:min="METRICS.scaleMin" :min="METRICS.scaleMin"
:max="METRICS.scaleMax" :max="METRICS.scaleMax"
:step="0.05" :step="CLASSISLAND_TOKENS.dpi.scaleStep"
@change="save" @change="save"
/> />
</el-form-item> </el-form-item>
<el-form-item label="字体字重">
<el-select v-model="scheme.fontWeight" @change="save">
<el-option
v-for="weight in fontWeights"
:key="weight.value"
:label="weight.label"
:value="weight.value"
/>
</el-select>
</el-form-item>
<el-form-item v-for="field in fontFields" :key="field.key" :label="`${field.label}字号(px)`">
<el-input-number
v-model="scheme[field.key]"
:min="CLASSISLAND_TOKENS.fontSizes.inputMin"
:max="CLASSISLAND_TOKENS.fontSizes.inputMax"
:step="CLASSISLAND_TOKENS.fontSizes.inputStep"
@change="save"
/>
</el-form-item>
<div class="font-preview" aria-label="四档字号预览">
<span class="l1" :style="{ fontSize: `${scheme.secondaryFontSize}px` }">辅助文字</span>
<span class="l2" :style="{ fontSize: `${scheme.bodyFontSize}px` }">正文示例</span>
<span
class="l1"
:style="{ fontSize: `${scheme.emphasizedFontSize}px`, fontWeight: scheme.fontWeight }"
>
强调文字
</span>
<span class="l1" :style="{ fontSize: `${scheme.largeFontSize}px`, fontWeight: scheme.fontWeight }">
大号标题
</span>
</div>
<el-form-item label="行间距"> <el-form-item label="行间距">
<el-slider v-model="scheme.spacing" :min="0" :max="METRICS.rowSpacingMax" @change="save" /> <el-slider v-model="scheme.spacing" :min="0" :max="METRICS.rowSpacingMax" @change="save" />
</el-form-item> </el-form-item>
<el-form-item label="常态圆角"> <el-form-item label="常态圆角">
<el-slider v-model="scheme.radius" :min="0" :max="METRICS.radiusMax" @change="save" /> <el-slider
v-model="scheme.radius"
:min="0"
:max="METRICS.radiusMax"
:step="CLASSISLAND_TOKENS.radii.islandStep"
@change="save"
/>
</el-form-item> </el-form-item>
<el-form-item label="自定义背景色">
<el-switch v-model="scheme.customBackgroundEnabled" @change="save" />
<el-color-picker v-if="scheme.customBackgroundEnabled" v-model="scheme.color" @change="save" />
</el-form-item>
<el-form-item label="背景不透明度">
<el-slider
v-model="scheme.opacity"
:min="0"
:max="1"
:step="0.05"
:show-tooltip="true"
:format-tooltip="(value: number) => value.toFixed(2)"
@change="save"
/>
</el-form-item>
<el-form-item label="自定义前景色">
<el-switch v-model="scheme.customForegroundEnabled" @change="save" />
<el-color-picker v-if="scheme.customForegroundEnabled" v-model="scheme.foreground" @change="save" />
</el-form-item>
<p class="hint">
关闭自定义前景色后回落当前亮/暗主题的五级文字色;开启后按 100% / 85.5% / 77.3% / 52.9% / 36.5%
生成颜色 alpha。
</p>
<el-form-item label="各行分离显示"> <el-form-item label="各行分离显示">
<el-switch v-model="scheme.separated" @change="save" /> <el-switch v-model="scheme.separated" @change="save" />
</el-form-item> </el-form-item>
<p class="hint">字体、透明度、位置和动画与灵动岛共用设置。</p> <p class="hint">位置与动画与灵动岛共用设置。</p>
<el-button link type="primary" @click="router.push('/settings/island')">前往灵动岛外观设置</el-button> <el-button link type="primary" @click="router.push('/settings/island')">前往灵动岛外观设置</el-button>
</el-form> </el-form>
</el-drawer> </el-drawer>
@@ -4,14 +4,17 @@ import { computed, onMounted, onUnmounted, ref } from 'vue';
import { ElMessage } from 'element-plus'; import { ElMessage } from 'element-plus';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { import {
CLASSISLAND_TOKENS,
DEFAULT_ISLAND_APPEARANCE, DEFAULT_ISLAND_APPEARANCE,
defaultIslandLayouts, defaultIslandLayouts,
ISLAND_APPEARANCE_RANGES as RANGES, ISLAND_APPEARANCE_RANGES as RANGES,
ISLAND_ACCENT_SOURCES,
ISLAND_POSITION_LABELS, ISLAND_POSITION_LABELS,
ISLAND_POSITIONS, ISLAND_POSITIONS,
ISLAND_STYLE_LABELS, ISLAND_STYLE_LABELS,
ISLAND_STYLES, ISLAND_STYLES,
type IslandAppearance, type IslandAppearance,
type IslandAccentColorSource,
type IslandPosition, type IslandPosition,
type IslandStyle, type IslandStyle,
} from '@classhelper/shared'; } from '@classhelper/shared';
@@ -121,6 +124,13 @@ function applyIslandAppearance(patch: Partial<IslandAppearance> = {}): void {
window.desktop?.islandSetAppearance({ ...island.value }); window.desktop?.islandSetAppearance({ ...island.value });
} }
function setAccentPaletteColor(value: string | null): void {
if (!value) return;
const palette = [...island.value.accentPalette];
palette[island.value.accentPaletteIndex] = value;
applyIslandAppearance({ accentPalette: palette });
}
async function saveIslandAppearance(): Promise<void> { async function saveIslandAppearance(): Promise<void> {
if (!window.desktop?.saveConfig) return; if (!window.desktop?.saveConfig) return;
savingIsland.value = true; savingIsland.value = true;
@@ -281,13 +291,49 @@ onMounted(async () => {
@input="(value: number) => applyIslandAppearance({ speed: value })" @input="(value: number) => applyIslandAppearance({ speed: value })"
/> />
</el-form-item> </el-form-item>
<el-form-item label="主题色"> <el-form-item label="强调色来源">
<el-select
:model-value="island.accentSource"
style="width: 180px"
@change="(value: IslandAccentColorSource) => applyIslandAppearance({ accentSource: value })"
>
<el-option
v-for="item in ISLAND_ACCENT_SOURCES"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
<span class="text-muted ml-8">自定义 / 壁纸 / 跟随系统 / 屏幕主题色,未知来源回落 DodgerBlue</span>
</el-form-item>
<el-form-item v-if="island.accentSource === 0" label="主题色">
<el-color-picker <el-color-picker
:model-value="island.accent" :model-value="island.accent"
@change="(value: string | null) => applyIslandAppearance({ accent: value ?? '#0a84ff' })" @change="
(value: string | null) =>
applyIslandAppearance({ accent: value ?? CLASSISLAND_TOKENS.colors.light.primaryColor })
"
/> />
<span class="text-muted ml-8">用于高亮、按钮与进度条</span> <span class="text-muted ml-8">用于高亮、按钮与进度条</span>
</el-form-item> </el-form-item>
<el-form-item v-else-if="island.accentSource === 1 || island.accentSource === 3" label="调色板颜色">
<el-color-picker
:model-value="island.accentPalette[island.accentPaletteIndex]"
@change="setAccentPaletteColor"
/>
<el-input-number
:model-value="island.accentPaletteIndex"
:min="0"
:max="Math.max(0, island.accentPalette.length - 1)"
@change="
(value: number | undefined) => applyIslandAppearance({ accentPaletteIndex: Number(value ?? 0) })
"
/>
<span class="text-muted ml-8">按 SelectedPlatteIndex 取当前候选颜色</span>
</el-form-item>
<el-form-item v-else label="主题色">
<span class="text-muted">跟随操作系统强调色;不可用时回落 DodgerBlue</span>
</el-form-item>
<el-form-item label="视觉风格"> <el-form-item label="视觉风格">
<span v-if="layoutMode === 'custom'">ClassIsland · 半透明横条</span> <span v-if="layoutMode === 'custom'">ClassIsland · 半透明横条</span>
<el-select <el-select
+232 -2
View File
@@ -261,14 +261,236 @@ export const WEEK_PARITY_VALUES: readonly ('ALL' | 'ODD' | 'EVEN')[] = ['ALL', '
/** 一个学期按多少周为一个单双周循环(ClassIsland WeekCountDivTotal 的默认值) */ /** 一个学期按多少周为一个单双周循环(ClassIsland WeekCountDivTotal 的默认值) */
export const WEEK_PARITY_CYCLE = 2; export const WEEK_PARITY_CYCLE = 2;
/**
* ClassIsland 岛层设计 token 的 TypeScript 单一来源。
*
* CSS 变量在 `packages/ui/src/tokens.css` 中按 `--ci-*` 一一映射;窗口几何、
* 主进程安全区与设置页范围直接复用本对象,避免 TypeScript 与 CSS 各写一套。
* 应用外壳仍使用 `--ch-*` / `--ch-ui-*`,本对象只服务于岛与课程信息层。
*/
export const CLASSISLAND_TOKENS = {
colors: {
light: {
primaryColor: '#00BFFF',
secondaryColor: '#7FFFD4',
accentFallback: '#1E90FF',
accentPaletteFallback: '#1E90FF',
/** ClassIsland 原值 #E4000000(AARRGGBB),CSS 写作 RRGGBBAA。 */
text1: '#000000E4',
/** ClassIsland 浅色主题对 InformativeSecondary 的覆盖值。 */
text2: '#000000C0',
text3: '#00000072',
text4: '#0000005C',
text5: '#0000002E',
textOnAccent: '#FFFFFFFF',
bgBase: '#F3F3F3',
bgSecondary: '#EEEEEE',
bgTertiary: '#F9F9F9',
fillSecondary: '#0000000A',
smoke: '#00000066',
islandBgCustom: '#000000',
strokeIsland: '#00000014',
strokeControl: '#00000024',
strokeDivider: '#00000014',
strokeFlyout: '#0000001B',
fillStrong: '#00000072',
strokeCard: '#00000016',
strokeDrag: '#1E90FF',
strokeTutorial: '#1E90FF',
aqi1: '#228B22',
aqi2: '#CCCC00',
aqi3: '#FF8C00',
aqi4: '#CD5C5C',
aqi5: '#8B0000',
aqi6: '#800080',
weatherRain: '#0000FF',
glowClass: '#FFFF00',
danger: '#CD5C5C',
warningCritical: '#C42B1C',
warningCaution: '#9D5D00',
warningCautionBackground: '#FFF4CE',
},
dark: {
primaryColor: '#00BFFF',
secondaryColor: '#7FFFD4',
accentFallback: '#1E90FF',
accentPaletteFallback: '#1E90FF',
text1: '#FFFFFFFF',
/** ClassIsland 深色主题对 InformativeSecondary 的覆盖值。 */
text2: '#FFFFFFDA',
text3: '#FFFFFFC5',
text4: '#FFFFFF87',
text5: '#FFFFFF5D',
textOnAccent: '#FFFFFFFF',
bgBase: '#202020',
bgSecondary: '#1C1C1C',
bgTertiary: '#282828',
fillSecondary: '#FFFFFF14',
smoke: '#00000066',
islandBgCustom: '#000000',
strokeIsland: '#FFFFFF26',
strokeControl: '#FFFFFF3D',
strokeDivider: '#FFFFFF26',
strokeFlyout: '#FFFFFF33',
fillStrong: '#FFFFFF8A',
strokeCard: '#FFFFFF26',
strokeDrag: '#00BFFF',
strokeTutorial: '#00BFFF',
aqi1: '#3CB371',
aqi2: '#FFFF00',
aqi3: '#FFA500',
aqi4: '#CD5C5C',
aqi5: '#8B0000',
aqi6: '#9370DB',
weatherRain: '#00BFFF',
glowClass: '#FFFF00',
danger: '#CD5C5C',
warningCritical: '#FF99A4',
warningCaution: '#FCE100',
warningCautionBackground: '#433519',
},
},
fonts: {
app: "'HarmonyOS Sans SC', 'Microsoft YaHei UI', 'Noto Sans CJK SC', 'Noto Sans SC', 'PingFang SC', 'Source Han Sans SC', SimHei, 'WenQuanYi Micro Hei', sans-serif",
island:
"'HarmonyOS Sans SC', 'Microsoft YaHei UI', 'Noto Sans CJK SC', 'Noto Sans SC', 'PingFang SC', 'Source Han Sans SC', SimHei, 'WenQuanYi Micro Hei', sans-serif",
harmonyOsSans: "'HarmonyOS Sans SC', 'Microsoft YaHei UI', SimHei",
backend: "'Microsoft YaHei UI'",
iconFluent: "'FluentSystemIcons-Resizable'",
iconLucide: "'lucide'",
iconSf: "'SF-Symbols'",
},
fontWeights: {
thin: 100,
extraLight: 200,
light: 300,
normal: 400,
medium: 500,
semiBold: 600,
bold: 700,
extraBold: 800,
black: 900,
},
fontSizes: {
secondary: 14,
body: 16,
emphasized: 18,
large: 20,
version: 9,
caption: 12,
controlBase: 13,
label: 14,
title: 16,
rolling: 17,
oobeBody: 18,
brand: 20,
weather: 22,
oobeTitle: 32,
inputMin: 1,
inputMax: 40,
inputStep: 0.5,
},
radii: {
island: 8,
islandLocal: 0,
islandMax: 20,
islandStep: 0.5,
popup: 6,
card: 4,
control: 4,
drawer: '8px 8px 0 0',
pill: 999,
iconButton: 14,
oobeButton: 24,
},
spacing: {
islandHeight: 40,
islandPadX: 12,
islandMinWidth: 20,
componentGap: 12,
lineGap: 5,
settingsMaxWidth: 960,
popupPad: 12,
progressHeight: 3,
editbarBottom: 64,
splashWidth: 400,
splashHeight: 100,
},
shadows: {
island: '0 4px 8px 2px #00000048',
mask: '0 8px 32px 0 #00000066',
drawer: '0 8px 32px 0 #00000066',
drawerX: '0 0 8px #00000033',
classicMask: '0 0 8px #000000',
adorn: '0 0 8px #00000066',
},
opacity: {
islandBackground: 0.5,
line: 1,
pointerFaded: 0.05,
maskFrom: 0,
maskTo: 1,
},
layers: {
windowBottom: 0,
windowTop: 1,
content: 0,
mask: 1,
drag: 1,
drawer: 10,
timelineAdorn: 9999,
guide: 10000,
/** 原值 33550336;Web 层用浏览器最大安全整数哨兵表达同一语义。 */
sentinel: 2147483647,
},
dpi: {
/** ClassIsland 的所有视觉值都以 96 DPI 的 CSS px 为基准。 */
basis: 96,
scale: 1,
scaleMin: 0.75,
scaleMax: 2.5,
scaleStep: 0.05,
verticalSafeArea: 20,
tutorialSafeArea: 150,
effectScale: 1,
},
misc: {
rippleStroke: 200,
maskFade: 'linear-gradient(to bottom, #FFFFFF00, #FFFFFF00 65%, #FFFFFFFF)',
scrimTutorial: '#00000099',
debugBackground: '#22222277',
splashBackground: '#11111188',
brandGradientA: '#0C0E1F',
brandGradientB: '#0D1111',
brandDark: '#0D1111',
},
} as const;
/** ClassIsland `IntToFontWeightConverter` 的逐值映射;其他值回落 Normal。 */
export function classislandFontWeight(value: unknown): number {
if (
typeof value === 'number' &&
value >= CLASSISLAND_TOKENS.fontWeights.thin &&
value <= CLASSISLAND_TOKENS.fontWeights.black &&
value % 100 === 0
) {
return value;
}
return CLASSISLAND_TOKENS.fontWeights.normal;
}
/** 灵动岛默认外观(设置页个性化项的初始值,也是区间校验的单一来源) */ /** 灵动岛默认外观(设置页个性化项的初始值,也是区间校验的单一来源) */
export const DEFAULT_ISLAND_APPEARANCE = { export const DEFAULT_ISLAND_APPEARANCE = {
height: 44, height: 44,
width: 268, width: 268,
radius: 20, radius: 20,
opacity: 1, opacity: 1,
/** 默认强调色采用 Apple 系统蓝(与 WinIsland 的系统色体系一致) */ /** 默认强调色与 ClassIsland 的 PrimaryColor 对齐。 */
accent: '#0a84ff', accent: CLASSISLAND_TOKENS.colors.light.primaryColor,
/** 0=自定义,1=壁纸主题色,2=跟随系统,3=屏幕主题色;未知值回落兜底色。 */
accentSource: 0,
accentPalette: [CLASSISLAND_TOKENS.colors.light.primaryColor] as string[],
accentPaletteIndex: 0,
fontSize: 13, fontSize: 13,
animations: true, animations: true,
speed: 1, speed: 1,
@@ -320,6 +542,14 @@ export const ISLAND_POSITION_LABELS: Record<(typeof ISLAND_POSITIONS)[number], s
'bottom-right': '右下角', 'bottom-right': '右下角',
}; };
/** ClassIsland `ColorSource` 的显示顺序与中文说明。 */
export const ISLAND_ACCENT_SOURCES = [
{ value: 0, label: '自定义颜色' },
{ value: 1, label: '壁纸主题色' },
{ value: 2, label: '跟随系统' },
{ value: 3, label: '屏幕主题色' },
] as const;
/** 视觉风格可选值(参考 WinIsland 的 island_style) */ /** 视觉风格可选值(参考 WinIsland 的 island_style) */
export const ISLAND_STYLES = ['black', 'glass', 'tinted'] as const; export const ISLAND_STYLES = ['black', 'glass', 'tinted'] as const;
+170 -42
View File
@@ -1,4 +1,5 @@
import { isDayKey } from './utils.js'; import { isDayKey } from './utils.js';
import { CLASSISLAND_TOKENS, classislandFontWeight } from './constants.js';
export const ISLAND_COMPONENTS = [ export const ISLAND_COMPONENTS = [
'date', 'date',
@@ -18,21 +19,21 @@ export const ISLAND_COMPONENTS = [
] as const; ] as const;
/** ClassIsland master:MainWindowLine 与 Models/Settings.cs(2026-10-17 核对)。 */ /** ClassIsland master:MainWindowLine 与 Models/Settings.cs(2026-10-17 核对)。 */
export const CLASSISLAND_ISLAND_METRICS = { export const CLASSISLAND_ISLAND_METRICS = {
rowHeight: 40, rowHeight: CLASSISLAND_TOKENS.spacing.islandHeight,
horizontalPadding: 12, horizontalPadding: CLASSISLAND_TOKENS.spacing.islandPadX,
radius: 8, radius: CLASSISLAND_TOKENS.radii.island,
opacity: 0.5, opacity: CLASSISLAND_TOKENS.opacity.islandBackground,
scale: 1, scale: CLASSISLAND_TOKENS.dpi.scale,
scaleMin: 0.75, scaleMin: CLASSISLAND_TOKENS.dpi.scaleMin,
scaleMax: 2.5, scaleMax: CLASSISLAND_TOKENS.dpi.scaleMax,
radiusMax: 20, radiusMax: CLASSISLAND_TOKENS.radii.islandMax,
rowSpacingMax: 150, rowSpacingMax: 150,
secondaryFontSize: 14, secondaryFontSize: CLASSISLAND_TOKENS.fontSizes.secondary,
bodyFontSize: 16, bodyFontSize: CLASSISLAND_TOKENS.fontSizes.body,
emphasizedFontSize: 18, emphasizedFontSize: CLASSISLAND_TOKENS.fontSizes.emphasized,
largeFontSize: 20, largeFontSize: CLASSISLAND_TOKENS.fontSizes.large,
rowSpacing: 5, rowSpacing: CLASSISLAND_TOKENS.spacing.lineGap,
fadedOpacity: 0.05, fadedOpacity: CLASSISLAND_TOKENS.opacity.pointerFaded,
} as const; } as const;
export type IslandComponentKind = (typeof ISLAND_COMPONENTS)[number]; export type IslandComponentKind = (typeof ISLAND_COMPONENTS)[number];
export interface IslandWeather { export interface IslandWeather {
@@ -74,6 +75,13 @@ export interface ComponentAppearance {
cornerRadius: number; cornerRadius: number;
opacity: number; opacity: number;
} }
/** 四档核心字号;组件与行级覆盖共用同一字段名。 */
export interface IslandFontSizes {
secondaryFontSize: number;
bodyFontSize: number;
emphasizedFontSize: number;
largeFontSize: number;
}
export interface IslandComponentNode { export interface IslandComponentNode {
id: string; id: string;
kind: IslandComponentKind; kind: IslandComponentKind;
@@ -112,6 +120,14 @@ export interface IslandLayoutRow {
main: boolean; main: boolean;
allowNotifications: boolean; allowNotifications: boolean;
gap: number; gap: number;
/** 整行透明度,默认 1;不再与背景 alpha 相乘。 */
opacity: number;
/** 是否把四档字号写到这一行根元素,只影响本行。 */
fontOverridesEnabled: boolean;
secondaryFontSize: number;
bodyFontSize: number;
emphasizedFontSize: number;
largeFontSize: number;
nodes: IslandComponentNode[]; nodes: IslandComponentNode[];
} }
export interface IslandLayoutScheme { export interface IslandLayoutScheme {
@@ -123,8 +139,17 @@ export interface IslandLayoutScheme {
scale: number; scale: number;
color: string; color: string;
foreground: string; foreground: string;
/** false 时回落当前亮/暗主题背景。 */
customBackgroundEnabled: boolean;
/** false 时回落当前亮/暗主题的 5 级前景色。 */
customForegroundEnabled: boolean;
opacity: number; opacity: number;
radius: number; radius: number;
fontWeight: number;
secondaryFontSize: number;
bodyFontSize: number;
emphasizedFontSize: number;
largeFontSize: number;
separated: boolean; separated: boolean;
spacing: number; spacing: number;
} }
@@ -166,10 +191,21 @@ function defaultExpandedRows(): IslandLayoutRow[] {
main: true, main: true,
allowNotifications: false, allowNotifications: false,
gap: 12, gap: 12,
opacity: CLASSISLAND_TOKENS.opacity.line,
fontOverridesEnabled: false,
...defaultCoreFontSizes(),
nodes: [islandNode('date', 'expanded-date'), course], nodes: [islandNode('date', 'expanded-date'), course],
}, },
]; ];
} }
function defaultCoreFontSizes(): IslandFontSizes {
return {
secondaryFontSize: CLASSISLAND_TOKENS.fontSizes.secondary,
bodyFontSize: CLASSISLAND_TOKENS.fontSizes.body,
emphasizedFontSize: CLASSISLAND_TOKENS.fontSizes.emphasized,
largeFontSize: CLASSISLAND_TOKENS.fontSizes.large,
};
}
export function islandNode(kind: IslandComponentKind, id: string): IslandComponentNode { export function islandNode(kind: IslandComponentKind, id: string): IslandComponentNode {
return { return {
id, id,
@@ -197,19 +233,16 @@ export function islandNode(kind: IslandComponentKind, id: string): IslandCompone
}, },
appearance: { appearance: {
resourceOverridingEnabled: false, resourceOverridingEnabled: false,
secondaryFontSize: 14, ...defaultCoreFontSizes(),
bodyFontSize: 16,
emphasizedFontSize: 18,
largeFontSize: 20,
customForegroundEnabled: false, customForegroundEnabled: false,
foreground: '#ffffff', foreground: CLASSISLAND_TOKENS.colors.light.textOnAccent,
customBackgroundEnabled: false, customBackgroundEnabled: false,
background: '#202024', background: CLASSISLAND_TOKENS.colors.light.islandBgCustom,
customBackgroundOpacityEnabled: false, customBackgroundOpacityEnabled: false,
backgroundOpacity: 0.5, backgroundOpacity: CLASSISLAND_TOKENS.opacity.islandBackground,
customCornerRadiusEnabled: false, customCornerRadiusEnabled: false,
cornerRadius: 16, cornerRadius: CLASSISLAND_TOKENS.radii.island,
opacity: 1, opacity: CLASSISLAND_TOKENS.opacity.line,
}, },
advanced: { hideRules: [], align: 'stretch', width: 0, maxWidth: 0 }, advanced: { hideRules: [], align: 'stretch', width: 0, maxWidth: 0 },
}; };
@@ -234,6 +267,9 @@ export function defaultIslandLayouts(): IslandLayoutSettings {
main: true, main: true,
allowNotifications: true, allowNotifications: true,
gap: 12, gap: 12,
opacity: CLASSISLAND_TOKENS.opacity.line,
fontOverridesEnabled: false,
...defaultCoreFontSizes(),
nodes: [ nodes: [
islandNode('date', 'date'), islandNode('date', 'date'),
islandNode('clock', 'clock'), islandNode('clock', 'clock'),
@@ -243,12 +279,16 @@ export function defaultIslandLayouts(): IslandLayoutSettings {
}, },
], ],
scale: 1, scale: 1,
color: '#000000', color: CLASSISLAND_TOKENS.colors.light.islandBgCustom,
foreground: '#ffffff', foreground: CLASSISLAND_TOKENS.colors.light.textOnAccent,
opacity: 0.5, customBackgroundEnabled: true,
radius: 8, customForegroundEnabled: true,
opacity: CLASSISLAND_TOKENS.opacity.islandBackground,
radius: CLASSISLAND_TOKENS.radii.island,
fontWeight: CLASSISLAND_TOKENS.fontWeights.medium,
...defaultCoreFontSizes(),
separated: false, separated: false,
spacing: 5, spacing: CLASSISLAND_TOKENS.spacing.lineGap,
}, },
], ],
}; };
@@ -304,19 +344,44 @@ export function normalizeIslandLayouts(input: unknown): IslandLayoutSettings {
}, },
appearance: { appearance: {
resourceOverridingEnabled: a.resourceOverridingEnabled === true, resourceOverridingEnabled: a.resourceOverridingEnabled === true,
secondaryFontSize: clamp(a.secondaryFontSize, 8, 96, 14), secondaryFontSize: clamp(
bodyFontSize: clamp(a.bodyFontSize, 8, 96, 16), a.secondaryFontSize,
emphasizedFontSize: clamp(a.emphasizedFontSize, 8, 96, 18), CLASSISLAND_TOKENS.fontSizes.inputMin,
largeFontSize: clamp(a.largeFontSize, 8, 128, 20), CLASSISLAND_TOKENS.fontSizes.inputMax,
CLASSISLAND_TOKENS.fontSizes.secondary,
),
bodyFontSize: clamp(
a.bodyFontSize,
CLASSISLAND_TOKENS.fontSizes.inputMin,
CLASSISLAND_TOKENS.fontSizes.inputMax,
CLASSISLAND_TOKENS.fontSizes.body,
),
emphasizedFontSize: clamp(
a.emphasizedFontSize,
CLASSISLAND_TOKENS.fontSizes.inputMin,
CLASSISLAND_TOKENS.fontSizes.inputMax,
CLASSISLAND_TOKENS.fontSizes.emphasized,
),
largeFontSize: clamp(
a.largeFontSize,
CLASSISLAND_TOKENS.fontSizes.inputMin,
CLASSISLAND_TOKENS.fontSizes.inputMax,
CLASSISLAND_TOKENS.fontSizes.large,
),
customForegroundEnabled: a.customForegroundEnabled === true, customForegroundEnabled: a.customForegroundEnabled === true,
foreground: color(a.foreground, '#ffffff'), foreground: color(a.foreground, CLASSISLAND_TOKENS.colors.light.textOnAccent),
customBackgroundEnabled: a.customBackgroundEnabled === true, customBackgroundEnabled: a.customBackgroundEnabled === true,
background: color(a.background, '#202024'), background: color(a.background, CLASSISLAND_TOKENS.colors.light.islandBgCustom),
customBackgroundOpacityEnabled: a.customBackgroundOpacityEnabled === true, customBackgroundOpacityEnabled: a.customBackgroundOpacityEnabled === true,
backgroundOpacity: clamp(a.backgroundOpacity, 0, 1, 0.5), backgroundOpacity: clamp(a.backgroundOpacity, 0, 1, CLASSISLAND_TOKENS.opacity.islandBackground),
customCornerRadiusEnabled: a.customCornerRadiusEnabled === true, customCornerRadiusEnabled: a.customCornerRadiusEnabled === true,
cornerRadius: clamp(a.cornerRadius, 0, 100, 16), cornerRadius: clamp(
opacity: clamp(a.opacity, 0, 1, 1), a.cornerRadius,
0,
CLASSISLAND_TOKENS.radii.islandMax,
CLASSISLAND_TOKENS.radii.island,
),
opacity: clamp(a.opacity, 0, 1, CLASSISLAND_TOKENS.opacity.line),
}, },
advanced: { advanced: {
hideRules: Array.isArray(adv.hideRules) hideRules: Array.isArray(adv.hideRules)
@@ -341,6 +406,32 @@ export function normalizeIslandLayouts(input: unknown): IslandLayoutSettings {
main: r.main === true, main: r.main === true,
allowNotifications: r.allowNotifications !== false, allowNotifications: r.allowNotifications !== false,
gap: clamp(r.gap, 0, 64, 8), gap: clamp(r.gap, 0, 64, 8),
opacity: clamp(r.opacity, 0, 1, CLASSISLAND_TOKENS.opacity.line),
fontOverridesEnabled: r.fontOverridesEnabled === true,
secondaryFontSize: clamp(
r.secondaryFontSize,
CLASSISLAND_TOKENS.fontSizes.inputMin,
CLASSISLAND_TOKENS.fontSizes.inputMax,
CLASSISLAND_TOKENS.fontSizes.secondary,
),
bodyFontSize: clamp(
r.bodyFontSize,
CLASSISLAND_TOKENS.fontSizes.inputMin,
CLASSISLAND_TOKENS.fontSizes.inputMax,
CLASSISLAND_TOKENS.fontSizes.body,
),
emphasizedFontSize: clamp(
r.emphasizedFontSize,
CLASSISLAND_TOKENS.fontSizes.inputMin,
CLASSISLAND_TOKENS.fontSizes.inputMax,
CLASSISLAND_TOKENS.fontSizes.emphasized,
),
largeFontSize: clamp(
r.largeFontSize,
CLASSISLAND_TOKENS.fontSizes.inputMin,
CLASSISLAND_TOKENS.fontSizes.inputMax,
CLASSISLAND_TOKENS.fontSizes.large,
),
nodes: (Array.isArray(r.nodes) ? r.nodes : []) nodes: (Array.isArray(r.nodes) ? r.nodes : [])
.map((n) => node(n, 0)) .map((n) => node(n, 0))
.filter((n): n is IslandComponentNode => Boolean(n)), .filter((n): n is IslandComponentNode => Boolean(n)),
@@ -373,12 +464,49 @@ export function normalizeIslandLayouts(input: unknown): IslandLayoutSettings {
resident ? CLASSISLAND_ISLAND_METRICS.scaleMax : 3, resident ? CLASSISLAND_ISLAND_METRICS.scaleMax : 3,
1, 1,
), ),
color: color(scheme.color, '#000000'), color: color(scheme.color, CLASSISLAND_TOKENS.colors.light.islandBgCustom),
foreground: color(scheme.foreground, '#ffffff'), foreground: color(scheme.foreground, CLASSISLAND_TOKENS.colors.light.textOnAccent),
opacity: clamp(scheme.opacity, resident ? 0 : 0.1, 1, 0.5), customBackgroundEnabled: scheme.customBackgroundEnabled !== false,
radius: clamp(scheme.radius, 0, resident ? CLASSISLAND_ISLAND_METRICS.radiusMax : 100, 8), customForegroundEnabled: scheme.customForegroundEnabled !== false,
opacity: clamp(scheme.opacity, resident ? 0 : 0.1, 1, CLASSISLAND_TOKENS.opacity.islandBackground),
radius: clamp(
scheme.radius,
0,
resident ? CLASSISLAND_ISLAND_METRICS.radiusMax : 100,
CLASSISLAND_TOKENS.radii.island,
),
fontWeight: classislandFontWeight(scheme.fontWeight),
secondaryFontSize: clamp(
scheme.secondaryFontSize,
CLASSISLAND_TOKENS.fontSizes.inputMin,
CLASSISLAND_TOKENS.fontSizes.inputMax,
CLASSISLAND_TOKENS.fontSizes.secondary,
),
bodyFontSize: clamp(
scheme.bodyFontSize,
CLASSISLAND_TOKENS.fontSizes.inputMin,
CLASSISLAND_TOKENS.fontSizes.inputMax,
CLASSISLAND_TOKENS.fontSizes.body,
),
emphasizedFontSize: clamp(
scheme.emphasizedFontSize,
CLASSISLAND_TOKENS.fontSizes.inputMin,
CLASSISLAND_TOKENS.fontSizes.inputMax,
CLASSISLAND_TOKENS.fontSizes.emphasized,
),
largeFontSize: clamp(
scheme.largeFontSize,
CLASSISLAND_TOKENS.fontSizes.inputMin,
CLASSISLAND_TOKENS.fontSizes.inputMax,
CLASSISLAND_TOKENS.fontSizes.large,
),
separated: scheme.separated === true, separated: scheme.separated === true,
spacing: clamp(scheme.spacing, 0, resident ? CLASSISLAND_ISLAND_METRICS.rowSpacingMax : 100, 5), spacing: clamp(
scheme.spacing,
0,
resident ? CLASSISLAND_ISLAND_METRICS.rowSpacingMax : 100,
CLASSISLAND_TOKENS.spacing.lineGap,
),
}); });
} }
return { return {
+12
View File
@@ -1143,6 +1143,8 @@ export interface IslandNotification {
} }
/** 灵动岛外观设置(设置页可调,主进程持久化并按此驱动窗口与渲染进程) */ /** 灵动岛外观设置(设置页可调,主进程持久化并按此驱动窗口与渲染进程) */
export type IslandAccentColorSource = 0 | 1 | 2 | 3;
export interface IslandAppearance { export interface IslandAppearance {
/** 胶囊高度(px,36~72):展开卡高度按比例联动,保证布局不错乱 */ /** 胶囊高度(px,36~72):展开卡高度按比例联动,保证布局不错乱 */
height: number; height: number;
@@ -1154,6 +1156,16 @@ export interface IslandAppearance {
opacity: number; opacity: number;
/** 主题色(强调色,用于高亮与按钮) */ /** 主题色(强调色,用于高亮与按钮) */
accent: string; accent: string;
/**
* ClassIsland 强调色来源:
* 0=自定义、1=壁纸主题色、2=跟随系统、3=屏幕主题色。
*/
accentSource: IslandAccentColorSource;
/** 壁纸/屏幕主题色候选;来源为 1 或 3 时按索引取色。 */
accentPalette: string[];
accentPaletteIndex: number;
/** 主进程按 accentSource 解析出的只读实际颜色,不参与用户选择。 */
resolvedAccent?: string;
/** /**
* 基础字号(px,11~20)——参考 WinIsland 的 font_size: * 基础字号(px,11~20)——参考 WinIsland 的 font_size:
* 岛内**所有文本**都由它乘以各自的排版系数得出,因此改字号会整体等比缩放。 * 岛内**所有文本**都由它乘以各自的排版系数得出,因此改字号会整体等比缩放。
+8 -7
View File
@@ -1,12 +1,13 @@
@import './tokens.css'; @import './tokens.css';
:root:root { :root:root {
--el-color-primary: var(--ch-ui-primary); /* ClassIsland accent 的单一入口;改 --ci-accent 时 Element Plus 同步派生。 */
--el-color-primary-light-3: color-mix(in srgb, var(--ch-ui-primary) 70%, var(--ch-ui-surface)); --el-color-primary: var(--ci-accent);
--el-color-primary-light-5: color-mix(in srgb, var(--ch-ui-primary) 50%, var(--ch-ui-surface)); --el-color-primary-light-3: color-mix(in srgb, var(--ci-accent) 70%, var(--ch-ui-surface));
--el-color-primary-light-7: color-mix(in srgb, var(--ch-ui-primary) 30%, var(--ch-ui-surface)); --el-color-primary-light-5: color-mix(in srgb, var(--ci-accent) 50%, var(--ch-ui-surface));
--el-color-primary-light-8: color-mix(in srgb, var(--ch-ui-primary) 20%, var(--ch-ui-surface)); --el-color-primary-light-7: color-mix(in srgb, var(--ci-accent) 30%, var(--ch-ui-surface));
--el-color-primary-light-9: color-mix(in srgb, var(--ch-ui-primary) 10%, var(--ch-ui-surface)); --el-color-primary-light-8: color-mix(in srgb, var(--ci-accent) 20%, var(--ch-ui-surface));
--el-color-primary-dark-2: color-mix(in srgb, var(--ch-ui-primary) 80%, #000); --el-color-primary-light-9: color-mix(in srgb, var(--ci-accent) 10%, var(--ch-ui-surface));
--el-color-primary-dark-2: color-mix(in srgb, var(--ci-accent) 80%, black);
--el-border-radius-base: var(--ch-ui-radius); --el-border-radius-base: var(--ch-ui-radius);
--el-bg-color: var(--ch-ui-surface); --el-bg-color: var(--ch-ui-surface);
--el-bg-color-overlay: var(--ch-ui-surface); --el-bg-color-overlay: var(--ch-ui-surface);
+344
View File
@@ -1,3 +1,12 @@
/*
* 设计 token 分两层:
* - --ch-ui-*:应用外壳(设置中心、管理页);
* - --ci-*:ClassIsland 岛与课程信息层。
*
* --ci-* 的亮/暗键集合必须完全一致。组件只消费 token,不在局部重定义颜色;
* 行级字号与自定义前景色是唯一允许的元素级覆盖。
* ClassIsland 源值使用 AARRGGBB;CSS 统一转换为 RRGGBBAA。
*/
:root { :root {
--ch-ui-primary: #5d6bfa; --ch-ui-primary: #5d6bfa;
--ch-ui-bg: #f7f8fa; --ch-ui-bg: #f7f8fa;
@@ -9,7 +18,164 @@
--ch-ui-radius: 8px; --ch-ui-radius: 8px;
--ch-ui-gap: 16px; --ch-ui-gap: 16px;
--ch-ui-shadow: 0 8px 30px rgb(30 40 70 / 8%); --ch-ui-shadow: 0 8px 30px rgb(30 40 70 / 8%);
--ch-z-guide: 10000;
--ch-z-view-old: 1;
--ch-z-view-new: 2;
--ci-accent: #00bfff;
--ci-accent-2: #7fffd4;
--ci-accent-fallback: #1e90ff;
--ci-accent-palette-fallback: #1e90ff;
--ci-accent-fill: var(--ci-accent);
--ci-accent-fill-tertiary: color-mix(in srgb, var(--ci-accent) 16%, transparent);
--ci-accent-text: var(--ci-accent);
--ci-text-on-accent: #ffffff;
--ci-accent-soft: color-mix(in srgb, var(--ci-accent) 10%, transparent);
--ci-text-1: #000000e4;
--ci-text-2: #000000c0;
--ci-text-3: #00000072;
--ci-text-4: #0000005c;
--ci-text-5: #0000002e;
--ci-bg-base: #f3f3f3;
--ci-bg-secondary: #eeeeee;
--ci-bg-tertiary: #f9f9f9;
--ci-fill-secondary: #0000000a;
--ci-smoke: #00000066;
--ci-island-bg-custom: #000000;
--ci-island-opacity: 0.5;
--ci-island-bg-opacity: var(--ci-island-opacity);
--ci-line-opacity: 1;
--ci-pointer-faded-opacity: 0.05;
--ci-stroke-island: color-mix(in srgb, var(--ci-accent) 24%, transparent);
--ci-stroke-island-w: 1px;
--ci-stroke-control: #00000024;
--ci-stroke-divider: #00000014;
--ci-stroke-flyout: #0000001b;
--ci-fill-strong: #00000072;
--ci-stroke-card: #00000016;
--ci-stroke-drag: var(--ci-accent-text);
--ci-stroke-tutorial: var(--ci-accent-text);
--ci-stroke-tutorial-w: 2.5px;
--ci-stroke-tutorial-corner-w: 3px;
--ci-aqi-1: #228b22;
--ci-aqi-2: #cccc00;
--ci-aqi-3: #ff8c00;
--ci-aqi-4: #cd5c5c;
--ci-aqi-5: #8b0000;
--ci-aqi-6: #800080;
--ci-weather-rain: #0000ff;
--ci-glow-class: #ffff00;
--ci-glow-class-blur: 6px;
--ci-danger: #cd5c5c;
--ci-warning-critical: #c42b1c;
--ci-warning-caution: #9d5d00;
--ci-warning-caution-bg: #fff4ce;
--ci-shadow-island: 0 4px 8px 2px #00000048;
--ci-shadow-mask: 0 8px 32px 0 #00000066;
--ci-shadow-drawer: 0 8px 32px 0 #00000066;
--ci-shadow-drawer-x: 0 0 8px #00000033;
--ci-shadow-classic-mask: 0 0 8px #000000;
--ci-shadow-adorn: 0 0 8px #00000066;
--ci-mask-fade: linear-gradient(to bottom, #ffffff00, #ffffff00 65%, #ffffff);
--ci-scrim-tutorial: #00000099;
--ci-debug-bg: #22222277;
--ci-splash-bg: #11111188;
--ci-brand-gradient-a: #0c0e1f;
--ci-brand-gradient-b: #0d1111;
--ci-brand-dark: #0d1111;
--ci-ripple: var(--ci-accent-fill);
--ci-ripple-stroke: 200;
--ci-font:
'HarmonyOS Sans SC', 'Microsoft YaHei UI', 'Noto Sans CJK SC', 'Noto Sans SC', 'PingFang SC',
'Source Han Sans SC', SimHei, 'WenQuanYi Micro Hei', sans-serif;
--ci-font-island: var(--ci-font);
--ci-font-harmony: 'HarmonyOS Sans SC', 'Microsoft YaHei UI', SimHei;
--ci-font-backend: 'Microsoft YaHei UI';
--ci-font-icon-fluent: 'FluentSystemIcons-Resizable';
--ci-font-icon-lucide: 'lucide';
--ci-font-icon-sf: 'SF-Symbols';
--ci-fw-thin: 100;
--ci-fw-extra-light: 200;
--ci-fw-light: 300;
--ci-fw-normal: 400;
--ci-fw-medium: 500;
--ci-fw-semi-bold: 600;
--ci-fw-bold: 700;
--ci-fw-extra-bold: 800;
--ci-fw-black: 900;
--ci-font-weight: var(--ci-fw-medium);
--ci-line-height-body: 1.25;
--ci-line-height-caption: 1.6;
--ci-fs-secondary: 14px;
--ci-fs-body: 16px;
--ci-fs-emphasized: 18px;
--ci-fs-large: 20px;
--ci-fs-version: 9px;
--ci-fs-caption: 12px;
--ci-fs-control-base: 13px;
--ci-fs-label: 14px;
--ci-fs-title: 16px;
--ci-fs-rolling: 17px;
--ci-fs-oobe-body: 18px;
--ci-fs-brand: 20px;
--ci-fs-weather: 22px;
--ci-fs-oobe-title: 32px;
--ci-radius-island: 8px;
--ci-radius-island-local: 0;
--ci-radius-popup: 6px;
--ci-radius-card: 4px;
--ci-radius-control: 4px;
--ci-radius-drawer: 8px 8px 0 0;
--ci-radius-pill: 999px;
--ci-radius-icon-btn: 14px;
--ci-radius-oobe-btn: 24px;
--ci-island-height: 40px;
--ci-island-pad-x: 12px;
--ci-island-min-w: 20px;
--ci-component-gap: 12px;
--ci-line-gap: 5px;
--ci-settings-pad: 12px 12px 18px 12px;
--ci-settings-max-w: 960px;
--ci-component-settings-pad: 4px 0 4px 12px;
--ci-popup-pad: 12px;
--ci-theme-card-h: 150px;
--ci-theme-card-w: 328px;
--ci-editbar-bottom: 64px;
--ci-splash-w: 400px;
--ci-splash-h: 100px;
--ci-progress-height: 3px;
--ci-island-pad-factor: 0.78;
--ci-island-gap-factor: 0.62;
--ci-window-transparent: transparent;
--ci-edit-blur: 16px;
--ci-effect-scale: 1;
--ci-z-window: 0;
--ci-z-window-top: 1;
--ci-z-content: 0;
--ci-z-mask: 1;
--ci-z-drag: 1;
--ci-z-drawer: 10;
--ci-z-timeline-adorn: 9999;
--ci-z-sentinel: 2147483647;
--ci-dpi-basis: 96;
--ci-scale: 1;
--ci-vertical-safe-area: 20px;
--ci-tutorial-safe-area: 150;
--ci-duration: 200ms;
} }
html.dark { html.dark {
--ch-ui-bg: #14161a; --ch-ui-bg: #14161a;
--ch-ui-surface: #1d2027; --ch-ui-surface: #1d2027;
@@ -18,4 +184,182 @@ html.dark {
--ch-ui-text: #e9edf5; --ch-ui-text: #e9edf5;
--ch-ui-muted: #a2abbd; --ch-ui-muted: #a2abbd;
--ch-ui-shadow: 0 8px 30px rgb(0 0 0 / 25%); --ch-ui-shadow: 0 8px 30px rgb(0 0 0 / 25%);
--ci-accent: #00bfff;
--ci-accent-2: #7fffd4;
--ci-accent-fallback: #1e90ff;
--ci-accent-palette-fallback: #1e90ff;
--ci-accent-fill: var(--ci-accent);
--ci-accent-fill-tertiary: color-mix(in srgb, var(--ci-accent) 16%, transparent);
--ci-accent-text: var(--ci-accent);
--ci-text-on-accent: #ffffff;
--ci-accent-soft: color-mix(in srgb, var(--ci-accent) 10%, transparent);
--ci-text-1: #ffffffff;
--ci-text-2: #ffffffda;
--ci-text-3: #ffffffc5;
--ci-text-4: #ffffff87;
--ci-text-5: #ffffff5d;
--ci-bg-base: #202020;
--ci-bg-secondary: #1c1c1c;
--ci-bg-tertiary: #282828;
--ci-fill-secondary: #ffffff14;
--ci-smoke: #00000066;
--ci-island-bg-custom: #000000;
--ci-island-opacity: 0.5;
--ci-island-bg-opacity: var(--ci-island-opacity);
--ci-line-opacity: 1;
--ci-pointer-faded-opacity: 0.05;
--ci-stroke-island: color-mix(in srgb, var(--ci-accent) 28%, transparent);
--ci-stroke-island-w: 1px;
--ci-stroke-control: #ffffff3d;
--ci-stroke-divider: #ffffff26;
--ci-stroke-flyout: #ffffff33;
--ci-fill-strong: #ffffff8a;
--ci-stroke-card: #ffffff26;
--ci-stroke-drag: var(--ci-accent-text);
--ci-stroke-tutorial: var(--ci-accent-text);
--ci-stroke-tutorial-w: 2.5px;
--ci-stroke-tutorial-corner-w: 3px;
--ci-aqi-1: #3cb371;
--ci-aqi-2: #ffff00;
--ci-aqi-3: #ffa500;
--ci-aqi-4: #cd5c5c;
--ci-aqi-5: #8b0000;
--ci-aqi-6: #9370db;
--ci-weather-rain: #00bfff;
--ci-glow-class: #ffff00;
--ci-glow-class-blur: 2px;
--ci-danger: #cd5c5c;
--ci-warning-critical: #ff99a4;
--ci-warning-caution: #fce100;
--ci-warning-caution-bg: #433519;
--ci-shadow-island: 0 4px 8px 2px #00000048;
--ci-shadow-mask: 0 8px 32px 0 #00000066;
--ci-shadow-drawer: 0 8px 32px 0 #00000066;
--ci-shadow-drawer-x: 0 0 8px #00000033;
--ci-shadow-classic-mask: 0 0 8px #000000;
--ci-shadow-adorn: 0 0 8px #00000066;
--ci-mask-fade: linear-gradient(to bottom, #ffffff00, #ffffff00 65%, #ffffff);
--ci-scrim-tutorial: #00000099;
--ci-debug-bg: #22222277;
--ci-splash-bg: #11111188;
--ci-brand-gradient-a: #0c0e1f;
--ci-brand-gradient-b: #0d1111;
--ci-brand-dark: #0d1111;
--ci-ripple: var(--ci-accent-fill);
--ci-ripple-stroke: 200;
--ci-font:
'HarmonyOS Sans SC', 'Microsoft YaHei UI', 'Noto Sans CJK SC', 'Noto Sans SC', 'PingFang SC',
'Source Han Sans SC', SimHei, 'WenQuanYi Micro Hei', sans-serif;
--ci-font-island: var(--ci-font);
--ci-font-harmony: 'HarmonyOS Sans SC', 'Microsoft YaHei UI', SimHei;
--ci-font-backend: 'Microsoft YaHei UI';
--ci-font-icon-fluent: 'FluentSystemIcons-Resizable';
--ci-font-icon-lucide: 'lucide';
--ci-font-icon-sf: 'SF-Symbols';
--ci-fw-thin: 100;
--ci-fw-extra-light: 200;
--ci-fw-light: 300;
--ci-fw-normal: 400;
--ci-fw-medium: 500;
--ci-fw-semi-bold: 600;
--ci-fw-bold: 700;
--ci-fw-extra-bold: 800;
--ci-fw-black: 900;
--ci-font-weight: var(--ci-fw-medium);
--ci-line-height-body: 1.25;
--ci-line-height-caption: 1.6;
--ci-fs-secondary: 14px;
--ci-fs-body: 16px;
--ci-fs-emphasized: 18px;
--ci-fs-large: 20px;
--ci-fs-version: 9px;
--ci-fs-caption: 12px;
--ci-fs-control-base: 13px;
--ci-fs-label: 14px;
--ci-fs-title: 16px;
--ci-fs-rolling: 17px;
--ci-fs-oobe-body: 18px;
--ci-fs-brand: 20px;
--ci-fs-weather: 22px;
--ci-fs-oobe-title: 32px;
--ci-radius-island: 8px;
--ci-radius-island-local: 0;
--ci-radius-popup: 6px;
--ci-radius-card: 4px;
--ci-radius-control: 4px;
--ci-radius-drawer: 8px 8px 0 0;
--ci-radius-pill: 999px;
--ci-radius-icon-btn: 14px;
--ci-radius-oobe-btn: 24px;
--ci-island-height: 40px;
--ci-island-pad-x: 12px;
--ci-island-min-w: 20px;
--ci-component-gap: 12px;
--ci-line-gap: 5px;
--ci-settings-pad: 12px 12px 18px 12px;
--ci-settings-max-w: 960px;
--ci-component-settings-pad: 4px 0 4px 12px;
--ci-popup-pad: 12px;
--ci-theme-card-h: 150px;
--ci-theme-card-w: 328px;
--ci-editbar-bottom: 64px;
--ci-splash-w: 400px;
--ci-splash-h: 100px;
--ci-progress-height: 3px;
--ci-island-pad-factor: 0.78;
--ci-island-gap-factor: 0.62;
--ci-window-transparent: transparent;
--ci-edit-blur: 16px;
--ci-effect-scale: 1;
--ci-z-window: 0;
--ci-z-window-top: 1;
--ci-z-content: 0;
--ci-z-mask: 1;
--ci-z-drag: 1;
--ci-z-drawer: 10;
--ci-z-timeline-adorn: 9999;
--ci-z-sentinel: 2147483647;
--ci-dpi-basis: 96;
--ci-scale: 1;
--ci-vertical-safe-area: 20px;
--ci-tutorial-safe-area: 150;
--ci-duration: 200ms;
}
.l-primary,
.l1 {
color: var(--ci-text-1);
}
.l-secondary,
.l2 {
color: var(--ci-text-2);
}
.l-instructive,
.l3 {
color: var(--ci-text-3);
}
.l-decoration,
.l4 {
color: var(--ci-text-4);
}
.l-inactive,
.l5 {
color: var(--ci-text-5);
} }
+136
View File
@@ -0,0 +1,136 @@
import fs from 'node:fs';
import path from 'node:path';
import process from 'node:process';
const root = process.cwd();
const tokenFile = path.join(root, 'packages/ui/src/tokens.css');
const islandRoot = path.join(root, 'packages/desktop-client/src/island');
const scopedFiles = [
islandRoot,
path.join(root, 'packages/desktop-client/src/main/island.ts'),
path.join(root, 'packages/desktop-client/src/main/config.ts'),
path.join(root, 'packages/desktop-client/src/preload/island.ts'),
path.join(root, 'packages/desktop-client/src/renderer/components/IslandComponentSettings.vue'),
path.join(root, 'packages/desktop-client/src/renderer/styles/island-editor.css'),
path.join(root, 'packages/desktop-client/src/renderer/views/settings/IslandEditorView.vue'),
path.join(root, 'packages/desktop-client/src/renderer/views/settings/IslandSettingsView.vue'),
];
const source = fs.readFileSync(tokenFile, 'utf8');
const rootBlock = source.match(/:root\s*\{([\s\S]*?)\n\}/)?.[1] ?? '';
const darkBlock = source.match(/html\.dark\s*\{([\s\S]*?)\n\}/)?.[1] ?? '';
function tokenNames(block) {
return [...block.matchAll(/(--ci-[a-z0-9-]+)\s*:/g)].map((match) => match[1]);
}
const light = new Set(tokenNames(rootBlock));
const dark = new Set(tokenNames(darkBlock));
const errors = [];
if (!light.size || !dark.size) errors.push('无法解析 :root 或 html.dark 的 --ci-* token');
for (const name of light) if (!dark.has(name)) errors.push(`深色主题缺少 ${name}`);
for (const name of dark) if (!light.has(name)) errors.push(`亮色主题缺少 ${name}`);
const required = [
'--ci-accent',
'--ci-accent-2',
'--ci-accent-fallback',
'--ci-accent-palette-fallback',
'--ci-accent-fill',
'--ci-accent-fill-tertiary',
'--ci-accent-text',
'--ci-text-on-accent',
'--ci-accent-soft',
'--ci-text-1',
'--ci-text-2',
'--ci-text-3',
'--ci-text-4',
'--ci-text-5',
'--ci-bg-base',
'--ci-bg-secondary',
'--ci-bg-tertiary',
'--ci-island-bg-custom',
'--ci-island-opacity',
'--ci-island-bg-opacity',
'--ci-line-opacity',
'--ci-stroke-island',
'--ci-stroke-control',
'--ci-stroke-divider',
'--ci-stroke-flyout',
'--ci-stroke-card',
'--ci-stroke-drag',
'--ci-stroke-tutorial',
'--ci-shadow-island',
'--ci-shadow-mask',
'--ci-shadow-drawer',
'--ci-shadow-drawer-x',
'--ci-shadow-classic-mask',
'--ci-shadow-adorn',
'--ci-font',
'--ci-font-island',
'--ci-font-backend',
'--ci-font-icon-fluent',
'--ci-font-icon-lucide',
'--ci-font-icon-sf',
'--ci-fs-secondary',
'--ci-fs-body',
'--ci-fs-emphasized',
'--ci-fs-large',
'--ci-radius-island',
'--ci-radius-island-local',
'--ci-radius-popup',
'--ci-radius-card',
'--ci-radius-control',
'--ci-radius-drawer',
'--ci-radius-pill',
'--ci-island-height',
'--ci-island-pad-x',
'--ci-island-min-w',
'--ci-component-gap',
'--ci-line-gap',
'--ci-progress-height',
'--ci-z-window',
'--ci-z-window-top',
'--ci-z-mask',
'--ci-z-drag',
'--ci-z-timeline-adorn',
'--ci-z-sentinel',
'--ci-dpi-basis',
'--ci-scale',
'--ci-vertical-safe-area',
];
for (const name of required) if (!light.has(name)) errors.push(`缺少基础 token ${name}`);
function files(directory) {
return fs.readdirSync(directory, { withFileTypes: true }).flatMap((entry) => {
const target = path.join(directory, entry.name);
return entry.isDirectory() ? files(target) : [target];
});
}
const scoped = scopedFiles.flatMap((file) => (fs.statSync(file).isDirectory() ? files(file) : [file]));
for (const file of scoped.filter((value) => /\.(css|vue|ts)$/.test(value))) {
const text = fs.readFileSync(file, 'utf8');
const relative = path.relative(root, file);
if (/#[0-9a-f]{3,8}\b/i.test(text)) errors.push(`${relative} 含裸颜色字面量`);
if (/(?<![\w-])rgba?\(/i.test(text)) errors.push(`${relative} 含裸 rgb/rgba 色值`);
for (const match of text.matchAll(/--ci-([A-Za-z0-9_-]+)/g)) {
if (/[A-Z_]/.test(match[1])) errors.push(`${relative} 的 token 名不是 kebab-case:--ci-${match[1]}`);
}
}
for (const file of files(path.join(root, 'packages/desktop-client/src')).filter((value) =>
value.endsWith('.css'),
)) {
const text = fs.readFileSync(file, 'utf8');
if (/^\s*--ci-[a-z0-9-]+\s*:/m.test(text)) {
errors.push(`${path.relative(root, file)} 在 tokens.css 之外定义了 --ci-*`);
}
}
if (errors.length) {
console.error(`设计 token 检查失败(${errors.length} 项):`);
for (const error of errors) console.error(`- ${error}`);
process.exitCode = 1;
} else {
console.log(`设计 token 检查通过:亮/暗各 ${light.size} 个 --ci-*,岛相关文件无裸颜色。`);
}