Fix/ts errors in fe (#2218)
Some checks failed
supersonic CentOS CI / build (21) (push) Has been cancelled
supersonic mac CI / build (21) (push) Has been cancelled
supersonic ubuntu CI / build (21) (push) Has been cancelled
supersonic windows CI / build (21) (push) Has been cancelled

This commit is contained in:
poncheen
2025-04-11 20:58:35 +08:00
committed by GitHub
parent 97710a90c4
commit 5585b9e222
18 changed files with 262 additions and 258 deletions

View File

@@ -1,9 +1,9 @@
import { ProLayoutProps } from '@ant-design/pro-components';
const Settings: ProLayoutProps & {
export type DefaultSetting = ProLayoutProps & {
pwa?: boolean;
logo?: string;
} = {
};
const Settings: DefaultSetting = {
navTheme: 'light',
colorPrimary: '#296DF3',
layout: 'top',

View File

@@ -1,6 +1,5 @@
import RightContent from '@/components/RightContent';
import S2Icon, { ICON } from '@/components/S2Icon';
import type { Settings as LayoutSettings } from '@ant-design/pro-components';
import { Space, Spin, ConfigProvider } from 'antd';
import ScaleLoader from 'react-spinners/ScaleLoader';
import { history, RunTimeLayoutConfig } from '@umijs/max';
@@ -9,6 +8,7 @@ import settings from '../config/themeSettings';
import { queryCurrentUser } from './services/user';
import { deleteUrlQuery, isMobile, getToken } from '@/utils/utils';
import { publicPath } from '../config/defaultSettings';
import type { DefaultSetting } from '../config/defaultSettings';
import { Copilot } from 'supersonic-chat-sdk';
import { configProviderTheme } from '../config/themeSettings';
export { request } from './services/request';
@@ -42,7 +42,7 @@ const getAuthCodes = (params: any) => {
};
export async function getInitialState(): Promise<{
settings?: LayoutSettings;
settings?: DefaultSetting;
currentUser?: API.CurrentUser;
fetchUserInfo?: () => Promise<API.CurrentUser | undefined>;
codeList?: string[];

View File

@@ -1,13 +1,13 @@
import React, { useRef } from 'react';
import { LogoutOutlined, KeyOutlined, UnlockOutlined } from '@ant-design/icons';
import { useModel } from 'umi';
import { useModel } from '@umijs/max';
import HeaderDropdown from '../HeaderDropdown';
import styles from './index.less';
import TMEAvatar from '../TMEAvatar';
import { AUTH_TOKEN_KEY } from '@/common/constants';
import ChangePasswordModal, { IRef as IRefChangePasswordModal } from './ChangePasswordModal';
import AccessTokensModal, { IRef as IAccessTokensModalRef } from './AccessTokensModal';
import { history } from 'umi';
import { history } from '@umijs/max';
export type GlobalHeaderRightProps = {
menu?: boolean;

View File

@@ -1,4 +1,4 @@
import { request } from 'umi';
import { request } from '@umijs/max';
export async function getUserByDeptid(id: any) {
return request<any>(`${process.env.AUTH_API_BASE_URL}user/getUserByOrg/${id}`, {

View File

@@ -1,7 +1,7 @@
import { Button, message, notification } from 'antd';
import React from 'react';
import { useIntl } from 'umi';
import { useIntl } from '@umijs/max';
import defaultSettings from '../config/defaultSettings';
const { pwa } = defaultSettings;
@@ -37,7 +37,7 @@ if (pwa) {
worker.postMessage({ type: 'skip-waiting' }, [channel.port2]);
});
// Refresh current page to use the updated HTML and other assets after SW has skiped waiting
window.location.reload(true);
(window.location.reload as (forceReload?: boolean) => void)(true); //兼容老版IE,现在浏览器中此方法均不再接收参数
return true;
};
const key = `open${Date.now()}`;
@@ -75,7 +75,7 @@ if (pwa) {
});
// remove all caches
if (window.caches && window.caches.keys) {
if ('caches' in window) {
caches.keys().then((keys) => {
keys.forEach((key) => {
caches.delete(key);

View File

@@ -1,6 +1,6 @@
import { Button, Result } from 'antd';
import React from 'react';
import { history } from 'umi';
import { history } from '@umijs/max';
const NoAuthPage: React.FC = () => (
<Result

View File

@@ -1,6 +1,6 @@
import { Button, Result } from 'antd';
import React from 'react';
import { history } from 'umi';
import { history } from '@umijs/max';
const NoFoundPage: React.FC = () => (
<Result

View File

@@ -1,4 +1,4 @@
import { request } from 'umi';
import { request } from '@umijs/max';
import { AgentType, MemoryType, MetricType, ModelType } from './type';
export function getAgentList() {

View File

@@ -1,4 +1,4 @@
import { request } from 'umi';
import { request } from '@umijs/max';
import { DimensionType, ModelType, PluginType } from './type';
export function savePlugin(params: Partial<PluginType>) {

View File

@@ -7,7 +7,7 @@ import { XFlowGraphCommands, XFlowNodeCommands, XFlowEdgeCommands } from '@antv/
import { CanvasMiniMap, CanvasScaleToolbar, CanvasSnapline } from '@antv/xflow';
import { MODELS } from '@antv/xflow';
import GraphToolbar from './GraphToolbar/index';
import { connect } from 'umi';
import { connect } from '@umijs/max';
/** 配置画布 */
import { useGraphConfig } from './config-graph';

View File

@@ -1,7 +1,7 @@
import { message, Tabs, Button, Space } from 'antd';
import React, { useState, useEffect } from 'react';
import { getTagData } from '../service';
import { useParams, history } from 'umi';
import { useParams, history } from '@umijs/max';
import styles from './style.less';
import { ArrowLeftOutlined } from '@ant-design/icons';
import TagTrendSection from './components/TagTrendSection';

View File

@@ -2,7 +2,7 @@ import type { ActionType, ProColumns } from '@ant-design/pro-components';
import { ProTable } from '@ant-design/pro-components';
import { message, Space, Popconfirm } from 'antd';
import React, { useRef, useState, useEffect } from 'react';
import { useModel } from 'umi';
import { useModel } from '@umijs/max';
import { SENSITIVE_LEVEL_ENUM } from '../constant';
import { getTagList, deleteTag, batchDeleteTag, getTagObjectList } from '../service';
import TagFilter from './components/TagFilter';

View File

@@ -36,7 +36,7 @@ import TableTitleTooltips from '../../components/TableTitleTooltips';
import { createMetric, updateMetric, mockMetricAlias, getMetricTags } from '../../service';
import { MetricSettingKey, MetricSettingWording } from '../constants';
import { ISemantic } from '../../data';
import { history } from 'umi';
import { history } from '@umijs/max';
export type CreateFormProps = {
datasourceId?: number;

View File

@@ -1,5 +1,5 @@
import React, { useEffect, useState, useRef } from 'react';
import { useModel } from 'umi';
import { useModel } from '@umijs/max';
import {
typeConfigs,
formatterRelationData,

View File

@@ -1,6 +1,6 @@
// import { Radio } from 'antd';
import React, { useState } from 'react';
import { connect } from 'umi';
import { connect } from '@umijs/max';
import styles from './components/style.less';
import type { StateType } from './model';
import { SemanticNodeType } from './enum';

View File

@@ -1,7 +1,7 @@
import React, { useEffect, useState, useRef } from 'react';
import { Button, message, Form, Space, Drawer, Input } from 'antd';
import { ProCard } from '@ant-design/pro-components';
import { useModel } from 'umi';
import { useModel } from '@umijs/max';
import { createGroupAuth, updateGroupAuth } from '../../service';
import PermissionCreateForm from './PermissionCreateForm';
import type { StateType } from '../../model';

View File

@@ -1,6 +1,6 @@
import type { SqlParamsItem } from '@/pages/data-explore/data';
declare namespace API {
declare global {
namespace API {
// export type CurrentUser = {
// avatar?: string;
// name?: string;
@@ -18,9 +18,10 @@ declare namespace API {
export type CurrentUser = {
staffid: string;
staffName: string;
staffName: string | undefined;
orgName: string;
access?: 'user' | 'guest' | 'admin';
name?:string;
};
export interface UserItem {
@@ -238,4 +239,5 @@ declare namespace API {
defaultSourceId: number; // 查询表需要的默认datasource id
bindSourceId: number;
};
}
}

View File

@@ -17,7 +17,9 @@ export const TOKEN_KEY = AUTH_TOKEN_KEY;
const authHeaderInterceptor = (url: string, options: RequestOptionsInit) => {
const headers: any = {};
const query = queryString.parse(history.location.search) || {};
const token = query[TOKEN_KEY] || localStorage.getItem(TOKEN_KEY);
const rawToken = query[TOKEN_KEY];
const token = (typeof rawToken === 'string' ? rawToken : null) || localStorage.getItem(TOKEN_KEY);
if (token) {
headers.Authorization = `Bearer ${token}`;
headers.auth = `Bearer ${token}`;