fix: 修复全量类型检查报错
- 收敛可选配置字段并补齐默认值,消除 strict 模式报错 - 补充页面脚本类型定义,移除未使用变量与隐式 any - 修复主题、表格、标签页等公共包类型边界
This commit is contained in:
@@ -29,8 +29,9 @@ function updateCSSVariables(preferences: Preferences) {
|
||||
// html 设置 data-theme=[builtinType]
|
||||
if (Reflect.has(theme, 'builtinType')) {
|
||||
const rootTheme = root.dataset.theme;
|
||||
if (rootTheme !== builtinType) {
|
||||
root.dataset.theme = builtinType;
|
||||
const resolvedBuiltinType = builtinType ?? '';
|
||||
if (rootTheme !== resolvedBuiltinType) {
|
||||
root.dataset.theme = resolvedBuiltinType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +40,7 @@ function updateCSSVariables(preferences: Preferences) {
|
||||
(item) => item.type === builtinType,
|
||||
);
|
||||
|
||||
let builtinTypeColorPrimary: string | undefined = '';
|
||||
let builtinTypeColorPrimary: string | undefined;
|
||||
|
||||
if (currentBuiltType) {
|
||||
const isDark = isDarkTheme(preferences.theme.mode);
|
||||
@@ -78,12 +79,16 @@ function updateMainColorVariables(preference: Preferences) {
|
||||
}
|
||||
const { colorDestructive, colorPrimary, colorSuccess, colorWarning } =
|
||||
preference.theme;
|
||||
const resolvedColorPrimary = colorPrimary ?? 'hsl(216 100% 50%)';
|
||||
const resolvedColorWarning = colorWarning ?? 'hsl(42 84% 61%)';
|
||||
const resolvedColorSuccess = colorSuccess ?? 'hsl(144 57% 58%)';
|
||||
const resolvedColorDestructive = colorDestructive ?? 'hsl(348 100% 61%)';
|
||||
|
||||
const colorVariables = generatorColorVariables([
|
||||
{ color: colorPrimary, name: 'primary' },
|
||||
{ alias: 'warning', color: colorWarning, name: 'yellow' },
|
||||
{ alias: 'success', color: colorSuccess, name: 'green' },
|
||||
{ alias: 'destructive', color: colorDestructive, name: 'red' },
|
||||
{ color: resolvedColorPrimary, name: 'primary' },
|
||||
{ alias: 'warning', color: resolvedColorWarning, name: 'yellow' },
|
||||
{ alias: 'success', color: resolvedColorSuccess, name: 'green' },
|
||||
{ alias: 'destructive', color: resolvedColorDestructive, name: 'red' },
|
||||
]);
|
||||
|
||||
// 要设置的 CSS 变量映射
|
||||
@@ -105,7 +110,7 @@ function updateMainColorVariables(preference: Preferences) {
|
||||
executeUpdateCSSVariables(colorVariables);
|
||||
}
|
||||
|
||||
function isDarkTheme(theme: string) {
|
||||
function isDarkTheme(theme?: string) {
|
||||
let dark = theme === 'dark';
|
||||
if (theme === 'auto') {
|
||||
dark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||
|
||||
Reference in New Issue
Block a user