Skip to content

Commit

Permalink
feat: up richContainer data get & minWidth limit & up iconfont & fix …
Browse files Browse the repository at this point in the history
…back button block
  • Loading branch information
noneAuth committed Dec 26, 2023
1 parent 2dd6db9 commit b65da52
Show file tree
Hide file tree
Showing 10 changed files with 3,613 additions and 437 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Toolbar from './Toolbar';
import './index.less';

const URL_SEARCH_KEY = 'ActiveAssetID';
const MIN_WIDTH = 336;
const visibleStyle: React.CSSProperties = {
visibility: 'visible',
width: '100%',
Expand Down Expand Up @@ -57,7 +58,7 @@ const RichContainer = props => {
useEffect(() => {
if (isExpanded) {
const defaultWidth = getDefaultSideWidth();
setWidth(defaultWidth);
setWidth(defaultWidth >= MIN_WIDTH ? defaultWidth : MIN_WIDTH);
} else setWidth(0);
}, [isExpanded]);

Expand Down Expand Up @@ -129,8 +130,10 @@ const RichContainer = props => {
};
const onResizeStop = (e, direction, ref, d) => {
setWidth(prev => {
localStorage.setItem('GI_RICH_CONTAINER_SIDE_WIDTH', prev + d.width);
return prev + d.width;
const currentWidth = prev + d.width;
const realWidth = currentWidth >= MIN_WIDTH ? currentWidth : MIN_WIDTH;
localStorage.setItem('GI_RICH_CONTAINER_SIDE_WIDTH', realWidth);
return realWidth;
});
setIsResizing(false);
};
Expand Down Expand Up @@ -208,7 +211,12 @@ const RichContainer = props => {
}}
onClick={() => {
if (!HAS_QUERY_VIEW) {
handleChange(DATA_QUERY_ID[0]);
const localKey = localStorage.getItem(URL_SEARCH_KEY) || '';
if (DATA_QUERY_ID.includes(localKey)) {
handleChange(localKey);
} else {
handleChange(DATA_QUERY_ID[0]);
}
}
}}
>
Expand All @@ -227,9 +235,14 @@ const RichContainer = props => {
fontSize: 12,
...(HAS_FILTER_VIEW ? ActiveButtonStyle : {}),
}}
onClick={() => {
onClick={e => {
if (!HAS_FILTER_VIEW) {
handleChange(localStorage.getItem(URL_SEARCH_KEY) || DATA_FILTER_ID[0]);
const localKey = localStorage.getItem(URL_SEARCH_KEY) || '';
if (DATA_FILTER_ID.includes(localKey)) {
handleChange(localKey);
} else {
handleChange(DATA_FILTER_ID[0]);
}
}
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const registerMeta = context => {
type: 'string',
'x-decorator': 'FormItem',
'x-component': 'Input',
default: 'icon-deploymentunit1',
default: 'icon-tugraph-graph-view',
},
},
{
Expand All @@ -78,7 +78,7 @@ const registerMeta = context => {
type: 'string',
'x-decorator': 'FormItem',
'x-component': 'Input',
default: 'icon-query',
default: 'icon-tugraph-query',
},
},
{
Expand All @@ -101,7 +101,7 @@ const registerMeta = context => {
type: 'string',
'x-decorator': 'FormItem',
'x-component': 'Input',
default: 'icon-filter',
default: 'icon-tugraph-filter',
},
},
{
Expand Down Expand Up @@ -138,7 +138,7 @@ const registerMeta = context => {
},
{
id: 'condition-content',
name:'条件展示容器',
name: '条件展示容器',
required: true,
GI_CONTAINER: {
title: $i18n.get({ id: 'basic.components.RichContainer.registerMeta.IntegratedComponents', dm: '集成组件' }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const SegmentedTabs: React.FunctionComponent<SegmentedTabsProps> = props => {

const [state, setState] = React.useState<{ active: string }>(() => {
const { searchParams } = getSearchParams(window.location);
const active = searchParams.get(queryKey) || defaultActive || items[0].key;
const active = searchParams.get(queryKey) || defaultActive || items[0]?.key || '';
return {
active,
};
Expand Down
1 change: 1 addition & 0 deletions packages/gi-assets-tugraph-db
Submodule gi-assets-tugraph-db added at ff5183
6 changes: 3 additions & 3 deletions packages/gi-common-components/src/Icon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import React from 'react';
import { loadFontJson, loadUnicodeFont, type FontJson } from './loader';

export const fontFamily = 'iconfont';
export const FONT_3381398 = 'font_3381398_i824ocozt7';

// --- 注册 font icon ---

Expand Down Expand Up @@ -36,8 +37,7 @@ export { glyphs, icons };

// --- 注册 antd iconfont ---
const registeredIds = new Set<string>();
const builtInIconFontId = 'font_3381398_i824ocozt7';
const getIconfontScriptUrl = (id: string) => `//at.alicdn.com/t/a/${id}.js`;
const getIconfontScriptUrl = (id: string) => `//at.alicdn.com/t/a/${FONT_3381398}.js`;

async function loadUnicodeFonts(ids: string[]) {
await Promise.all(ids.map(id => loadUnicodeFont(id)));
Expand All @@ -58,7 +58,7 @@ export async function registerIconFonts(ids: string[]) {
}

// 注册内置 iconfont
registerIconFonts([builtInIconFontId]);
registerIconFonts([FONT_3381398]);

interface IconProps extends React.HTMLProps<HTMLSpanElement> {
spin?: boolean;
Expand Down
3 changes: 2 additions & 1 deletion packages/gi-site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
"umi": "^3.5.41",
"umi-request": "^1.4.0",
"use-immer": "^0.9.0",
"xlsx2js": "^1.3.8"
"xlsx2js": "^1.3.8",
"@tugraph/gi-assets-tugraph-db": "workspace:*"
},
"devDependencies": {
"cross-env": "7.0.3",
Expand Down
3 changes: 2 additions & 1 deletion packages/gi-site/scripts/create-assets.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { fileURLToPath } from 'url';
import assets from './deps.json' assert { type: 'json' };

const __filename = fileURLToPath(import.meta.url);
export const FONT_3381398 = 'font_3381398_i824ocozt7';

const __dirname = path.dirname(__filename);
assets.forEach(item => {
Expand Down Expand Up @@ -40,7 +41,7 @@ assets.forEach(item => {
});

/** 生成 font 字体 */
fetch('https://at.alicdn.com/t/a/font_3381398_hecr296g6n8.js')
fetch(`https://at.alicdn.com/t/a/${FONT_3381398}.js`)
.then(res => res.text())
.then(res => {
fs.writeFile(path.resolve(__dirname, '../public/libs/', `font.js`), res, error => {
Expand Down
2 changes: 1 addition & 1 deletion packages/gi-site/src/components/SegmentedTabs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const SegmentedTabs: React.FunctionComponent<SegmentedTabsProps> = props => {

const [state, setState] = React.useState<{ active: string }>(() => {
const { searchParams, path } = getSearchParams(window.location);
const active = searchParams.get(queryKey) || defaultActive || items[0].key;
const active = searchParams.get(queryKey) || defaultActive || items[0]?.key || '';
return {
active,
};
Expand Down
2 changes: 1 addition & 1 deletion packages/gi-site/src/services/inject.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default {};
export default {};
Loading

0 comments on commit b65da52

Please sign in to comment.