fix(style): add worker

This commit is contained in:
jialin
2025-03-28 19:15:57 +08:00
parent 59d01a6bd9
commit 2079fc1801
10 changed files with 51 additions and 26 deletions
+4
View File
@@ -188,6 +188,10 @@
font-size: var(--font-size-base); font-size: var(--font-size-base);
} }
.font-size-13 {
font-size: 13px;
}
.font-size-14 { .font-size-14 {
font-size: var(--font-size-middle); font-size: var(--font-size-middle);
} }
+1 -1
View File
@@ -2,7 +2,7 @@ import { createFromIconfontCN } from '@ant-design/icons';
// import './iconfont/iconfont.js'; // import './iconfont/iconfont.js';
const IconFont = createFromIconfontCN({ const IconFont = createFromIconfontCN({
scriptUrl: '//at.alicdn.com/t/c/font_4613488_f316s64919m.js' scriptUrl: '//at.alicdn.com/t/c/font_4613488_hlvsvytu57b.js'
}); });
export default IconFont; export default IconFont;
@@ -1,5 +1,5 @@
import _ from 'lodash'; import _ from 'lodash';
import { useCallback, useMemo, useRef } from 'react'; import React, { useCallback, useMemo, useRef } from 'react';
type Point = { x: number; y: number; lineWidth: number }; type Point = { x: number; y: number; lineWidth: number };
type Stroke = Point[]; type Stroke = Point[];
@@ -130,6 +130,7 @@ export default function useDrawing(props: {
const getTransformedPoint = useCallback( const getTransformedPoint = useCallback(
(offsetX: number, offsetY: number) => { (offsetX: number, offsetY: number) => {
const { current: scale } = autoScale; const { current: scale } = autoScale;
console.log('lineWidth:----------', lineWidth, autoScale.current);
const { x: translateX, y: translateY } = translatePos.current; const { x: translateX, y: translateY } = translatePos.current;
@@ -146,6 +147,7 @@ export default function useDrawing(props: {
const getTransformLineWidth = useCallback( const getTransformLineWidth = useCallback(
(w = 1) => { (w = 1) => {
console.log('lineWidth:', lineWidth, autoScale.current);
const width = w || lineWidth; const width = w || lineWidth;
return width / autoScale.current; return width / autoScale.current;
}, },
+3 -2
View File
@@ -196,6 +196,7 @@ const CanvasImageEditor: React.FC<CanvasImageEditorProps> = forwardRef(
const onReset = useCallback(() => { const onReset = useCallback(() => {
clearOverlayCanvas(); clearOverlayCanvas();
setStrokes([]); setStrokes([]);
setMaskStrokes([]);
saveImage(); saveImage();
currentStroke.current = []; currentStroke.current = [];
console.log('Resetting strokes', currentStroke.current); console.log('Resetting strokes', currentStroke.current);
@@ -513,9 +514,9 @@ const CanvasImageEditor: React.FC<CanvasImageEditorProps> = forwardRef(
<ToolsBar <ToolsBar
handleBrushSizeChange={handleBrushSizeChange} handleBrushSizeChange={handleBrushSizeChange}
undo={undo} undo={undo}
onReset={onReset} onClear={onReset}
uploadButton={uploadButton}
handleFitView={handleFitView} handleFitView={handleFitView}
uploadButton={uploadButton}
disabled={disabled} disabled={disabled}
lineWidth={lineWidth} lineWidth={lineWidth}
loading={loading} loading={loading}
+3 -3
View File
@@ -19,7 +19,7 @@ interface ToolsBarProps {
uploadButton: React.ReactNode; uploadButton: React.ReactNode;
handleBrushSizeChange: (value: number) => void; handleBrushSizeChange: (value: number) => void;
undo: () => void; undo: () => void;
onReset: () => void; onClear: () => void;
handleFitView: () => void; handleFitView: () => void;
} }
@@ -30,7 +30,7 @@ const ToolsBar: React.FC<ToolsBarProps> = (props) => {
lineWidth, lineWidth,
handleBrushSizeChange, handleBrushSizeChange,
undo, undo,
onReset, onClear,
uploadButton, uploadButton,
handleFitView handleFitView
} = props; } = props;
@@ -83,7 +83,7 @@ const ToolsBar: React.FC<ToolsBarProps> = (props) => {
</Button> </Button>
</Tooltip> </Tooltip>
<Tooltip title={intl.formatMessage({ id: 'common.button.clear' })}> <Tooltip title={intl.formatMessage({ id: 'common.button.clear' })}>
<Button onClick={onReset} size="middle" type="text" disabled={disabled}> <Button onClick={onClear} size="middle" type="text" disabled={disabled}>
<ClearOutlined className="font-size-14" /> <ClearOutlined className="font-size-14" />
</Button> </Button>
</Tooltip> </Tooltip>
+4
View File
@@ -336,6 +336,10 @@ body {
.ant-pro-sider .ant-layout-sider-children { .ant-pro-sider .ant-layout-sider-children {
background-color: var(--color-fill-sider); background-color: var(--color-fill-sider);
// box-shadow:
// 0px 1px 2px 0px rgb(0 0 0 / 30%),
// 0px 2px 6px 2px rgb(0 0 0 / 15%);
// border-radius: 0 16px 16px 0;
} }
} }
@@ -443,7 +443,10 @@ const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
{ {
key: '1', key: '1',
label: ( label: (
<span style={{ fontWeight: 'var(--font-weight-medium)' }}> <span
style={{ fontWeight: 'var(--font-weight-medium)' }}
className="font-size-14"
>
{intl.formatMessage({ id: 'resources.form.advanced' })} {intl.formatMessage({ id: 'resources.form.advanced' })}
</span> </span>
), ),
@@ -80,13 +80,15 @@ const AddWorker: React.FC<ViewModalProps> = (props) => {
</Button> </Button>
</li> </li>
</ul> </ul>
<h3>1. {intl.formatMessage({ id: 'resources.worker.add.step1' })}</h3> <h3 className="font-size-14 font-600">
1. {intl.formatMessage({ id: 'resources.worker.add.step1' })}
</h3>
<HighlightCode <HighlightCode
code={addWorkerGuide.container.getToken} code={addWorkerGuide.container.getToken}
theme="dark" theme="dark"
lang="bash" lang="bash"
></HighlightCode> ></HighlightCode>
<h3 className="m-t-10"> <h3 className="m-t-10 font-size-14 font-600">
2. {intl.formatMessage({ id: 'resources.worker.add.step2' })}{' '} 2. {intl.formatMessage({ id: 'resources.worker.add.step2' })}{' '}
<span <span
className="font-size-12" className="font-size-12"
@@ -119,7 +121,7 @@ const AddWorker: React.FC<ViewModalProps> = (props) => {
></div> ></div>
)} )}
<HighlightCode theme="dark" code={code} lang="bash"></HighlightCode> <HighlightCode theme="dark" code={code} lang="bash"></HighlightCode>
<h3 className="m-b-0 m-t-10"> <h3 className="m-b-0 m-t-10 font-size-14 font-600">
3. {intl.formatMessage({ id: 'resources.worker.add.step3' })} 3. {intl.formatMessage({ id: 'resources.worker.add.step3' })}
</h3> </h3>
</div> </div>
@@ -417,7 +417,9 @@ const ModelFiles = () => {
render: (text: string, record: ListItem) => ( render: (text: string, record: ListItem) => (
<span className="flex flex-column" style={{ width: '100%' }}> <span className="flex flex-column" style={{ width: '100%' }}>
{record.source === modelSourceMap.local_path_value ? ( {record.source === modelSourceMap.local_path_value ? (
intl.formatMessage({ id: 'models.form.localPath' }) <AutoTooltip ghost>
{intl.formatMessage({ id: 'models.form.localPath' })}
</AutoTooltip>
) : ( ) : (
<AutoTooltip ghost>{generateSource(record)}</AutoTooltip> <AutoTooltip ghost>{generateSource(record)}</AutoTooltip>
)} )}
@@ -1,6 +1,6 @@
import HighlightCode from '@/components/highlight-code'; import HighlightCode from '@/components/highlight-code';
import { useIntl } from '@umijs/max'; import { useIntl } from '@umijs/max';
import React from 'react'; import React, { useMemo } from 'react';
import { addWorkerGuide } from '../config'; import { addWorkerGuide } from '../config';
type ViewModalProps = { token: string }; type ViewModalProps = { token: string };
@@ -10,32 +10,41 @@ const AddWorker: React.FC<ViewModalProps> = (props) => {
const origin = window.location.origin; const origin = window.location.origin;
const labels = useMemo(
() => ({
step1: intl.formatMessage({ id: 'resources.worker.add.step1' }),
step2: intl.formatMessage({ id: 'resources.worker.add.step2' }),
step2Tips: intl.formatMessage({ id: 'resources.worker.add.step2.tips' }),
step3: intl.formatMessage({ id: 'resources.worker.add.step3' }),
linuxOrMac: intl.formatMessage({ id: 'resources.worker.linuxormaxos' })
}),
[intl]
);
return ( return (
<div className="script-install"> <div className="script-install">
<h3>1. {intl.formatMessage({ id: 'resources.worker.add.step1' })}</h3> <h3 className="font-size-14 font-600">1. {labels.step1}</h3>
<h4>{intl.formatMessage({ id: 'resources.worker.linuxormaxos' })}</h4> <h4 className="font-size-13">{labels.linuxOrMac}</h4>
<HighlightCode <HighlightCode
code={addWorkerGuide.mac.getToken} code={addWorkerGuide.mac.getToken}
theme="dark" theme="dark"
></HighlightCode> ></HighlightCode>
<h4 className="m-t-6">Windows </h4> <h4 className="m-t-6 font-size-13">Windows </h4>
<HighlightCode <HighlightCode
code={addWorkerGuide.win.getToken} code={addWorkerGuide.win.getToken}
theme="dark" theme="dark"
></HighlightCode> ></HighlightCode>
<h3 className="m-t-10"> <h3 className="m-t-10 font-size-14 font-600">
2. {intl.formatMessage({ id: 'resources.worker.add.step2' })}{' '} 2. {labels.step2}{' '}
<span <span
className="font-size-12" className="font-size-12"
style={{ color: 'var(--ant-color-text-tertiary)' }} style={{ color: 'var(--ant-color-text-tertiary)' }}
dangerouslySetInnerHTML={{ dangerouslySetInnerHTML={{
__html: `(${intl.formatMessage({ __html: `(${labels.step2Tips})`
id: 'resources.worker.add.step2.tips'
})})`
}} }}
></span> ></span>
</h3> </h3>
<h4>{intl.formatMessage({ id: 'resources.worker.linuxormaxos' })}</h4> <h4 className="font-size-13">{labels.linuxOrMac}</h4>
<HighlightCode <HighlightCode
code={addWorkerGuide.mac.registerWorker({ code={addWorkerGuide.mac.registerWorker({
server: origin, server: origin,
@@ -43,7 +52,7 @@ const AddWorker: React.FC<ViewModalProps> = (props) => {
})} })}
theme="dark" theme="dark"
></HighlightCode> ></HighlightCode>
<h4 className="m-t-6">Windows </h4> <h4 className="m-t-6 font-size-13">Windows </h4>
<HighlightCode <HighlightCode
theme="dark" theme="dark"
code={addWorkerGuide.win.registerWorker({ code={addWorkerGuide.win.registerWorker({
@@ -51,9 +60,7 @@ const AddWorker: React.FC<ViewModalProps> = (props) => {
token: '${mytoken}' token: '${mytoken}'
})} })}
></HighlightCode> ></HighlightCode>
<h3 className="m-b-0 m-t-10"> <h3 className="m-b-0 m-t-10 font-size-14 font-600">3. {labels.step3}</h3>
3. {intl.formatMessage({ id: 'resources.worker.add.step3' })}
</h3>
</div> </div>
); );
}; };