Fix: Some bugs (#12441)

### What problem does this PR solve?

Fix: Some bugs
- In a production environment, a second-level page refresh results in a
white screen.
- The knowledge graph cannot be opened.

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
chanx
2026-01-05 15:28:57 +08:00
committed by GitHub
parent 4e9407b4ae
commit 00f8a80ca4
11 changed files with 39 additions and 11 deletions

View File

@ -1 +1 @@
VITE_BASE_URL='' VITE_BASE_URL='/'

View File

@ -1 +1 @@
VITE_BASE_URL='' VITE_BASE_URL='/'

View File

@ -7,7 +7,7 @@
"scripts": { "scripts": {
"build": "vite build --mode production", "build": "vite build --mode production",
"build-storybook": "storybook build", "build-storybook": "storybook build",
"dev": "vite", "dev": "vite --host",
"lint": "eslint src --ext .ts,.tsx --report-unused-disable-directives --max-warnings 0", "lint": "eslint src --ext .ts,.tsx --report-unused-disable-directives --max-warnings 0",
"prepare": "cd .. && husky web/.husky", "prepare": "cd .. && husky web/.husky",
"preview": "vite preview", "preview": "vite preview",

View File

@ -12,7 +12,7 @@ export default ({ size, name, create_date }: Props) => {
const dateStr = formatDate(create_date); const dateStr = formatDate(create_date);
return ( return (
<div> <div>
<h2 className="text-[16px]">{name}</h2> <h2 className="text-[16px] truncate">{name}</h2>
<div className="text-text-secondary text-[12px] pt-[5px]"> <div className="text-text-secondary text-[12px] pt-[5px]">
Size{sizeName} Uploaded Time{dateStr} Size{sizeName} Uploaded Time{dateStr}
</div> </div>

View File

@ -69,7 +69,7 @@ const BreadcrumbPage = React.forwardRef<
role="link" role="link"
aria-disabled="true" aria-disabled="true"
aria-current="page" aria-current="page"
className={cn('font-normal text-foreground', className)} className={cn('font-normal text-foreground truncate max-w-40', className)}
{...props} {...props}
/> />
)); ));

View File

@ -104,7 +104,7 @@ const ChunkCard = ({
<TooltipContent <TooltipContent
className="p-0" className="p-0"
align={'start'} align={'start'}
side={'right'} side={'left'}
sideOffset={-20} sideOffset={-20}
tabIndex={-1} tabIndex={-1}
> >

View File

@ -232,7 +232,7 @@ const Chunk = () => {
<div className="h-[100px] flex flex-col justify-end pb-[5px]"> <div className="h-[100px] flex flex-col justify-end pb-[5px]">
<div> <div>
<h2 className="text-[24px]">{t('chunk.chunkResult')}</h2> <h2 className="text-[24px]">{t('chunk.chunkResult')}</h2>
<div className="text-[14px] text-[#979AAB]"> <div className="text-[14px] text-text-secondary">
{t('chunk.chunkResultTip')} {t('chunk.chunkResultTip')}
</div> </div>
</div> </div>

View File

@ -1,7 +1,7 @@
import { ElementDatum, Graph, IElementEvent } from '@antv/g6'; import { ElementDatum, Graph, IElementEvent } from '@antv/g6';
import isEmpty from 'lodash/isEmpty'; import isEmpty from 'lodash/isEmpty';
import { useCallback, useEffect, useMemo, useRef } from 'react'; import { useCallback, useEffect, useMemo, useRef } from 'react';
import { buildNodesAndCombos } from './util'; import { buildNodesAndCombos, defaultComboLabel } from './util';
import { useIsDarkTheme } from '@/components/theme-provider'; import { useIsDarkTheme } from '@/components/theme-provider';
import styles from './index.module.less'; import styles from './index.module.less';
@ -27,7 +27,7 @@ const ForceGraph = ({ data, show }: IProps) => {
const mi = buildNodesAndCombos(graphData.nodes); const mi = buildNodesAndCombos(graphData.nodes);
return { edges: graphData.edges, ...mi }; return { edges: graphData.edges, ...mi };
} }
return { nodes: [], edges: [] }; return { nodes: [], edges: [], combos: [] };
}, [data]); }, [data]);
const render = useCallback(() => { const render = useCallback(() => {
@ -113,6 +113,20 @@ const ForceGraph = ({ data, show }: IProps) => {
}; };
}, },
}, },
combo: {
style: (e) => {
if (e.label === defaultComboLabel) {
return {
stroke: 'rgba(0,0,0,0)',
fill: 'rgba(0,0,0,0)',
};
} else {
return {
stroke: isDark ? 'rgba(255,255,255,0.5)' : 'rgba(0,0,0,0.5)',
};
}
},
},
}); });
if (graphRef.current) { if (graphRef.current) {

View File

@ -1,6 +1,7 @@
import { isEmpty } from 'lodash'; import { isEmpty } from 'lodash';
import { v4 as uuid } from 'uuid'; import { v4 as uuid } from 'uuid';
export const defaultComboLabel = 'defaultCombo';
class KeyGenerator { class KeyGenerator {
idx = 0; idx = 0;
chars: string[] = []; chars: string[] = [];
@ -89,6 +90,18 @@ export const buildNodesAndCombos = (nodes: any[]) => {
combo: combos.find((y) => y.data.label === findCombo(x?.communities))?.id, combo: combos.find((y) => y.data.label === findCombo(x?.communities))?.id,
}; };
}); });
if (!combos.length) {
const defaultComboId = uuid();
const defaultCombo = {
id: defaultComboId,
label: 'defaultCombo',
data: {
label: 'defaultCombo',
},
};
combos.push(defaultCombo);
}
return { nodes: nextNodes, combos }; return { nodes: nextNodes, combos };
}; };

View File

@ -59,6 +59,6 @@ export default storage;
// Will not jump to the login page // Will not jump to the login page
export function redirectToLogin() { export function redirectToLogin() {
const env = import.meta.env; // const env = import.meta.env;
window.location.href = location.origin + env.VITE_BASE_URL + `/login`; window.location.href = location.origin + `/login`;
} }

View File

@ -60,6 +60,7 @@ export default defineConfig(({ mode, command }) => {
}, },
server: { server: {
port: 9222, port: 9222,
strictPort: false,
proxy: { proxy: {
'/api/v1/admin': { '/api/v1/admin': {
target: 'http://127.0.0.1:9381/', target: 'http://127.0.0.1:9381/',