fix: 修复全量类型检查报错
- 收敛可选配置字段并补齐默认值,消除 strict 模式报错 - 补充页面脚本类型定义,移除未使用变量与隐式 any - 修复主题、表格、标签页等公共包类型边界
This commit is contained in:
@@ -92,7 +92,7 @@ function createRequestClient(baseURL: string, options?: RequestClientOptions) {
|
||||
client,
|
||||
doReAuthenticate,
|
||||
doRefreshToken,
|
||||
enableRefreshToken: preferences.app.enableRefreshToken,
|
||||
enableRefreshToken: preferences.app.enableRefreshToken ?? false,
|
||||
formatToken,
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -22,7 +22,7 @@ async function generateAccess(options: GenerateMenuAndRoutesOptions) {
|
||||
IFrameView,
|
||||
};
|
||||
|
||||
return await generateAccessible(preferences.app.accessMode, {
|
||||
return await generateAccessible(preferences.app.accessMode ?? 'frontend', {
|
||||
...options,
|
||||
fetchMenuListAsync: async () => {
|
||||
ElMessage({
|
||||
|
||||
@@ -54,11 +54,9 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
if (accessStore.loginExpired) {
|
||||
accessStore.setLoginExpired(false);
|
||||
} else {
|
||||
onSuccess
|
||||
? await onSuccess?.()
|
||||
: await router.push(
|
||||
userInfo.homePath || preferences.app.defaultHomePath,
|
||||
);
|
||||
const homePath =
|
||||
userInfo.homePath || preferences.app.defaultHomePath || '/';
|
||||
onSuccess ? await onSuccess?.() : await router.push(homePath);
|
||||
}
|
||||
|
||||
if (userInfo?.nickname) {
|
||||
|
||||
@@ -8,7 +8,6 @@ import { useAppConfig } from '@easyflow/hooks';
|
||||
import { $t } from '@easyflow/locales';
|
||||
import { preferences } from '@easyflow/preferences';
|
||||
|
||||
import { api } from '#/api/request';
|
||||
import { useAuthStore } from '#/store';
|
||||
|
||||
defineOptions({ name: 'Login' });
|
||||
@@ -18,8 +17,6 @@ const authStore = useAuthStore();
|
||||
|
||||
const { apiURL } = useAppConfig(import.meta.env, import.meta.env.PROD);
|
||||
|
||||
type PlatformType = 'ding_talk' | 'wx_web';
|
||||
|
||||
const title = computed(() => preferences.auth.welcomeBack);
|
||||
const subTitle = computed(() => preferences.auth.loginSubtitle);
|
||||
const formSchema = computed((): EasyFlowFormSchema[] => {
|
||||
@@ -91,14 +88,6 @@ function onSubmit(values: any) {
|
||||
console.error('初始化tac失败', error);
|
||||
});
|
||||
}
|
||||
|
||||
function getAuthUrl(platform: PlatformType) {
|
||||
return api.get('/thirdAuth/getAuthUrl', {
|
||||
params: {
|
||||
platform,
|
||||
},
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -29,6 +29,26 @@ import AddPluginModal from '#/views/ai/plugin/AddPluginModal.vue';
|
||||
import CategoryPluginModal from '#/views/ai/plugin/CategoryPluginModal.vue';
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
interface PluginCategory {
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
interface PluginRecord {
|
||||
id: string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
interface HeaderActionEvent {
|
||||
key?: string;
|
||||
}
|
||||
|
||||
interface CategoryFormData {
|
||||
id?: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
// 操作按钮配置
|
||||
const actions: ActionButton[] = [
|
||||
{
|
||||
@@ -74,12 +94,12 @@ const actions: ActionButton[] = [
|
||||
},
|
||||
},
|
||||
];
|
||||
const categoryList = ref([]);
|
||||
const categoryList = ref<PluginCategory[]>([]);
|
||||
const controlBtns = [
|
||||
{
|
||||
icon: Edit,
|
||||
label: $t('button.edit'),
|
||||
onClick(row) {
|
||||
onClick(row: PluginCategory) {
|
||||
formData.value.name = row.name;
|
||||
formData.value.id = row.id;
|
||||
isEdit.value = true;
|
||||
@@ -90,7 +110,7 @@ const controlBtns = [
|
||||
type: 'danger',
|
||||
icon: Delete,
|
||||
label: $t('button.delete'),
|
||||
onClick(row) {
|
||||
onClick(row: PluginCategory) {
|
||||
handleDeleteCategory(row);
|
||||
},
|
||||
},
|
||||
@@ -106,9 +126,12 @@ const footerButton = {
|
||||
const getPluginCategoryList = async () => {
|
||||
return api.get('/api/v1/pluginCategory/list').then((res) => {
|
||||
if (res.errorCode === 0) {
|
||||
const serverCategories = Array.isArray(res.data)
|
||||
? (res.data as PluginCategory[])
|
||||
: [];
|
||||
categoryList.value = [
|
||||
{ id: '0', name: $t('common.allCategories') },
|
||||
...res.data,
|
||||
...serverCategories,
|
||||
];
|
||||
}
|
||||
});
|
||||
@@ -116,7 +139,7 @@ const getPluginCategoryList = async () => {
|
||||
onMounted(() => {
|
||||
getPluginCategoryList();
|
||||
});
|
||||
const handleDelete = (item) => {
|
||||
const handleDelete = (item: PluginRecord) => {
|
||||
ElMessageBox.confirm($t('message.deleteAlert'), $t('message.noticeTitle'), {
|
||||
confirmButtonText: $t('message.ok'),
|
||||
cancelButtonText: $t('message.cancel'),
|
||||
@@ -148,7 +171,7 @@ const headerButtons = [
|
||||
const pluginCategoryId = ref('0');
|
||||
const dialogVisible = ref(false); // 弹窗显隐
|
||||
const isEdit = ref(false); // 是否为编辑模式
|
||||
const formData = ref({ name: '', id: '' });
|
||||
const formData = ref<CategoryFormData>({ name: '', id: '' });
|
||||
|
||||
const handleSubmit = () => {
|
||||
// 触发对应事件,传递表单数据
|
||||
@@ -160,7 +183,7 @@ const handleSubmit = () => {
|
||||
// 提交后关闭弹窗
|
||||
dialogVisible.value = false;
|
||||
};
|
||||
const handleButtonClick = (event, _item) => {
|
||||
const handleButtonClick = (event: HeaderActionEvent, _item: unknown) => {
|
||||
switch (event.key) {
|
||||
case 'add': {
|
||||
aiPluginModalRef.value.openDialog({});
|
||||
@@ -168,10 +191,10 @@ const handleButtonClick = (event, _item) => {
|
||||
}
|
||||
}
|
||||
};
|
||||
const handleSearch = (params) => {
|
||||
pageDataRef.value.setQuery({ title: params, isQueryOr: true });
|
||||
const handleSearch = (params?: string) => {
|
||||
pageDataRef.value.setQuery({ title: params ?? '', isQueryOr: true });
|
||||
};
|
||||
const handleEditCategory = (params) => {
|
||||
const handleEditCategory = (params: CategoryFormData) => {
|
||||
api
|
||||
.post('/api/v1/pluginCategory/update', {
|
||||
id: params.id,
|
||||
@@ -184,7 +207,7 @@ const handleEditCategory = (params) => {
|
||||
}
|
||||
});
|
||||
};
|
||||
const handleAddCategory = (params) => {
|
||||
const handleAddCategory = (params: CategoryFormData) => {
|
||||
api.post('/api/v1/pluginCategory/save', { name: params.name }).then((res) => {
|
||||
if (res.errorCode === 0) {
|
||||
getPluginCategoryList();
|
||||
@@ -192,7 +215,7 @@ const handleAddCategory = (params) => {
|
||||
}
|
||||
});
|
||||
};
|
||||
const handleDeleteCategory = (params) => {
|
||||
const handleDeleteCategory = (params: PluginCategory) => {
|
||||
api
|
||||
.get(`/api/v1/pluginCategory/doRemoveCategory?id=${params.id}`)
|
||||
.then((res) => {
|
||||
@@ -202,7 +225,7 @@ const handleDeleteCategory = (params) => {
|
||||
}
|
||||
});
|
||||
};
|
||||
const handleClickCategory = (item) => {
|
||||
const handleClickCategory = (item: PluginCategory) => {
|
||||
pageDataRef.value.setQuery({ category: item.id });
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -29,6 +29,7 @@ const pageDataRef = ref();
|
||||
const saveDialog = ref();
|
||||
const formInline = ref({
|
||||
id: '',
|
||||
title: '',
|
||||
});
|
||||
function search(formEl: FormInstance | undefined) {
|
||||
formEl?.validate((valid) => {
|
||||
|
||||
@@ -17,17 +17,47 @@ import {
|
||||
import { api } from '#/api/request.js';
|
||||
import providerList from '#/views/ai/model/modelUtils/providerList.json';
|
||||
|
||||
const providerOptions =
|
||||
ref<Array<{ label: string; options: any; value: string }>>(providerList);
|
||||
const brands = ref([]);
|
||||
const llmOptions = ref([]);
|
||||
interface ProviderOptionExtra {
|
||||
chatPath?: string;
|
||||
llmEndpoint?: string;
|
||||
}
|
||||
|
||||
interface ProviderOption {
|
||||
label: string;
|
||||
options?: ProviderOptionExtra;
|
||||
value: string;
|
||||
}
|
||||
|
||||
interface ModelProvider {
|
||||
key: string;
|
||||
options?: ProviderOptionExtra;
|
||||
title: string;
|
||||
}
|
||||
|
||||
interface LlmOption {
|
||||
extra: Map<string, string | undefined>;
|
||||
label: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
interface SettingsEntity {
|
||||
chatgpt_api_key: string;
|
||||
chatgpt_chatPath: string;
|
||||
chatgpt_endpoint: string;
|
||||
chatgpt_model_name: string;
|
||||
model_of_chat: string;
|
||||
}
|
||||
|
||||
const providerOptions = ref<ProviderOption[]>(providerList as ProviderOption[]);
|
||||
const brands = ref<ModelProvider[]>([]);
|
||||
const llmOptions = ref<LlmOption[]>([]);
|
||||
|
||||
// 获取品牌接口数据
|
||||
function getBrands() {
|
||||
api.get('/api/v1/modelProvider/list').then((res) => {
|
||||
if (res.errorCode === 0) {
|
||||
brands.value = res.data;
|
||||
llmOptions.value = formatLlmList(res.data);
|
||||
brands.value = (res.data ?? []) as ModelProvider[];
|
||||
llmOptions.value = formatLlmList(brands.value);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -47,7 +77,7 @@ onMounted(() => {
|
||||
getBrands();
|
||||
});
|
||||
|
||||
const entity = ref({
|
||||
const entity = ref<SettingsEntity>({
|
||||
model_of_chat: '',
|
||||
chatgpt_api_key: '',
|
||||
chatgpt_chatPath: '',
|
||||
@@ -55,7 +85,7 @@ const entity = ref({
|
||||
chatgpt_model_name: '',
|
||||
});
|
||||
|
||||
function formatLlmList(data) {
|
||||
function formatLlmList(data: ModelProvider[]): LlmOption[] {
|
||||
return data.map((item) => {
|
||||
const extra = new Map([
|
||||
['chatPath', item.options?.chatPath],
|
||||
@@ -68,10 +98,10 @@ function formatLlmList(data) {
|
||||
};
|
||||
});
|
||||
}
|
||||
function handleChangeModel(value) {
|
||||
function handleChangeModel(value: string) {
|
||||
const extra = providerList.find((item) => item.value === value);
|
||||
entity.value.chatgpt_chatPath = extra.options.chatPath;
|
||||
entity.value.chatgpt_endpoint = extra.options.llmEndpoint;
|
||||
entity.value.chatgpt_chatPath = extra?.options?.chatPath ?? '';
|
||||
entity.value.chatgpt_endpoint = extra?.options?.llmEndpoint ?? '';
|
||||
}
|
||||
function handleSave() {
|
||||
api.post('/api/v1/sysOption/save', entity.value).then((res) => {
|
||||
|
||||
@@ -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