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;
|
||||
|
||||
@@ -3,8 +3,8 @@ import type { Props } from './types';
|
||||
|
||||
import { preferences } from '@easyflow-core/preferences';
|
||||
import {
|
||||
EasyFlowAvatar,
|
||||
Card,
|
||||
EasyFlowAvatar,
|
||||
Tabs,
|
||||
TabsList,
|
||||
TabsTrigger,
|
||||
@@ -29,14 +29,14 @@ const tabsValue = defineModel<string>('modelValue');
|
||||
<Card class="w-[200px]">
|
||||
<div class="mt-4 flex h-40 flex-col items-center justify-center gap-4">
|
||||
<EasyFlowAvatar
|
||||
:src="userInfo?.avatar ?? preferences.app.defaultAvatar"
|
||||
:src="userInfo?.avatar ?? preferences.app.defaultAvatar ?? ''"
|
||||
class="size-20"
|
||||
/>
|
||||
<span class="text-lg font-semibold">
|
||||
{{ userInfo?.realName ?? '' }}
|
||||
{{ (userInfo as any)?.realName ?? userInfo?.nickname ?? '' }}
|
||||
</span>
|
||||
<span class="text-foreground/80 text-sm">
|
||||
{{ userInfo?.username ?? '' }}
|
||||
{{ (userInfo as any)?.username ?? userInfo?.loginName ?? '' }}
|
||||
</span>
|
||||
</div>
|
||||
<!-- <Separator class="my-4" /> -->
|
||||
|
||||
@@ -159,7 +159,7 @@ function autoCollapseMenuByRouteMeta(route: RouteLocationNormalizedLoaded) {
|
||||
// 只在双列模式下生效
|
||||
if (
|
||||
['header-mixed-nav', 'sidebar-mixed-nav'].includes(
|
||||
preferences.app.layout,
|
||||
preferences.app.layout ?? '',
|
||||
) &&
|
||||
route.meta &&
|
||||
route.meta.hideInMenu
|
||||
@@ -259,9 +259,9 @@ const headerSlots = computed(() => {
|
||||
:class="logoClass"
|
||||
:collapsed="logoCollapsed"
|
||||
:src="preferences.logo.source"
|
||||
:src-dark="preferences.logo.sourceDark"
|
||||
:src-mini="preferences.logo.sourceMini"
|
||||
:text="preferences.app.name"
|
||||
:src-dark="preferences.logo.sourceDark ?? preferences.logo.source ?? ''"
|
||||
:src-mini="preferences.logo.sourceMini ?? preferences.logo.source ?? ''"
|
||||
:text="preferences.app.name ?? ''"
|
||||
:theme="showHeaderNav ? headerTheme : theme"
|
||||
@click="clickLogo"
|
||||
>
|
||||
@@ -353,9 +353,9 @@ const headerSlots = computed(() => {
|
||||
v-if="preferences.logo.enable"
|
||||
:fit="preferences.logo.fit"
|
||||
:src="preferences.logo.source"
|
||||
:src-dark="preferences.logo.sourceDark"
|
||||
:src-mini="preferences.logo.sourceMini"
|
||||
:text="preferences.app.name"
|
||||
:src-dark="preferences.logo.sourceDark ?? preferences.logo.source ?? ''"
|
||||
:src-mini="preferences.logo.sourceMini ?? preferences.logo.source ?? ''"
|
||||
:text="preferences.app.name ?? ''"
|
||||
:theme="theme"
|
||||
>
|
||||
<template v-if="$slots['logo-text']" #text>
|
||||
|
||||
@@ -235,7 +235,7 @@ async function handleReset() {
|
||||
return;
|
||||
}
|
||||
resetPreferences();
|
||||
await loadLocaleMessages(preferences.app.locale);
|
||||
await loadLocaleMessages(preferences.app.locale ?? 'zh-CN');
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -22,8 +22,6 @@ import echarts from './echarts';
|
||||
|
||||
type EchartsUIType = typeof EchartsUI | undefined;
|
||||
|
||||
type EchartsThemeType = 'dark' | 'light' | null;
|
||||
|
||||
function useEcharts(chartRef: Ref<EchartsUIType>) {
|
||||
let chartInstance: echarts.ECharts | null = null;
|
||||
let cacheOptions: EChartsOption = {};
|
||||
@@ -57,7 +55,7 @@ function useEcharts(chartRef: Ref<EchartsUIType>) {
|
||||
};
|
||||
});
|
||||
|
||||
const initCharts = (t?: EchartsThemeType) => {
|
||||
const initCharts = () => {
|
||||
const el = chartRef?.value?.$el;
|
||||
if (!el) {
|
||||
return;
|
||||
|
||||
@@ -116,9 +116,10 @@ export function setupEasyFlowVxeTable(setupOptions: SetupVxeTable) {
|
||||
watch(
|
||||
[() => isDark.value, () => locale.value],
|
||||
([isDarkValue, localeValue]) => {
|
||||
const resolvedLocale = (localeValue ?? 'zh-CN') as keyof typeof localMap;
|
||||
VxeUI.setTheme(isDarkValue ? 'dark' : 'light');
|
||||
VxeUI.setI18n(localeValue, localMap[localeValue]);
|
||||
VxeUI.setLanguage(localeValue);
|
||||
VxeUI.setI18n(resolvedLocale, localMap[resolvedLocale]);
|
||||
VxeUI.setLanguage(resolvedLocale);
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
|
||||
@@ -120,7 +120,7 @@ export const useTabbarStore = defineStore('core-tabbar', {
|
||||
});
|
||||
|
||||
if (tabIndex === -1) {
|
||||
const maxCount = preferences.tabbar.maxCount;
|
||||
const maxCount = preferences.tabbar.maxCount ?? 0;
|
||||
// 获取动态路由打开数,超过 0 即代表需要控制打开数
|
||||
const maxNumOfOpenTab = (routeTab?.meta?.maxNumOfOpenTab ??
|
||||
-1) as number;
|
||||
|
||||
Reference in New Issue
Block a user