style: menu style

This commit is contained in:
jialin
2025-02-17 13:49:55 +08:00
parent c60015bd09
commit db53920153
8 changed files with 26 additions and 150 deletions
+2 -1
View File
@@ -1,4 +1,5 @@
import { defineConfig } from '@umijs/max';
import keepAlive from './keep-alive';
import proxy from './proxy';
import routes from './routes';
import theme from './theme';
@@ -90,7 +91,7 @@ export default defineConfig({
model: {},
initialState: {},
request: {},
keepalive: ['/playground/text-to-image', '/playground/speech'],
keepalive: keepAlive,
locale: {
antd: true,
baseNavigator: true,
+6
View File
@@ -0,0 +1,6 @@
export const keepAliveRoutes = {
text2images: '/playground/text-to-image',
speech: '/playground/speech'
};
export default [keepAliveRoutes.text2images, keepAliveRoutes.speech];
+4 -2
View File
@@ -1,3 +1,5 @@
import { keepAliveRoutes } from './keep-alive';
export default [
{
name: 'dashboard',
@@ -28,7 +30,7 @@ export default [
{
name: 'text2images',
title: 'Text2Images',
path: '/playground/text-to-image',
path: keepAliveRoutes.text2images,
key: 'text2images',
icon: 'Comment',
component: './playground/images'
@@ -36,7 +38,7 @@ export default [
{
name: 'speech',
title: 'Speech',
path: '/playground/speech',
path: keepAliveRoutes.speech,
key: 'speech',
icon: 'Comment',
component: './playground/speech'
-3
View File
@@ -1,8 +1,5 @@
.ant-pro-layout {
.ant-pro-sider {
// &.ant-layout-sider {
// background: var(--color-white-1);
// }
.ant-layout-sider-children {
background-color: var(--color-fill-1);
border-inline: none;
-141
View File
@@ -1,141 +0,0 @@
import { controlSeqRegex } from './config';
const useParseAnsi = () => {
const removeBrackets = (str: string) => {
return str?.replace?.(/^\(…\)/, '');
};
const isClean = (input: string) => {
let match = controlSeqRegex.exec(input) || [];
const command = match?.[3];
const n = parseInt(match?.[1], 10) || 1;
return command === 'J' && n === 2;
};
const parseAnsi = (input: string, setId: () => number) => {
let cursorRow = 0;
let cursorCol = 0;
let screen = [['']];
let lastIndex = 0;
// let input = inputStr.replace(replaceLineRegex, '\n');
// handle the \r and \n characters in the text
const handleText = (text: string) => {
let processed = '';
for (let char of text) {
if (char === '\r') {
cursorCol = 0; // move to the beginning of the line
} else if (char === '\n') {
cursorRow++; // move to the next line
cursorCol = 0; // move to the beginning of the line
screen[cursorRow] = screen[cursorRow] || ['']; // create a new line if it does not exist
} else {
// add the character to the screen content array
screen[cursorRow][cursorCol] = char;
cursorCol++;
}
}
return processed;
};
let output = ''; // output text
let match;
// ANSI color map
const colorMap: Record<string, string> = {
'30': 'black',
'31': 'red',
'32': 'green',
'33': 'yellow',
'34': 'blue',
'35': 'magenta',
'36': 'cyan',
'37': 'white'
};
let currentStyle = ''; // current text style
// match ANSI control characters
while ((match = controlSeqRegex.exec(input)) !== null) {
// handle text before the control character
let textBeforeControl = input.slice(lastIndex, match.index);
output += handleText(textBeforeControl); // add the processed text to the output
lastIndex = controlSeqRegex.lastIndex; // update the last index
const n = parseInt(match[1], 10) || 1;
const m = parseInt(match[2], 10) || 1;
const command = match[3];
// handle ANSI control characters
switch (command) {
case 'A': // up
cursorRow = Math.max(0, cursorRow - n);
if (cursorRow === 0) {
// screen = [['']];
// cursorCol = 0;
}
break;
case 'B': // down
cursorRow += n;
break;
case 'C': // right
cursorCol += n;
break;
case 'D': // left
cursorCol = Math.max(0, cursorCol - n);
break;
case 'H': // move the cursor to the specified position (n, m)
cursorRow = Math.max(0, n - 1);
cursorCol = Math.max(0, m - 1);
break;
case 'J': // clear the screen
if (n === 2) {
screen = [['']];
cursorRow = 0;
cursorCol = 0;
}
break;
case 'm':
// if (match[1] === '0') {
// currentStyle = '';
// } else if (colorMap[match[1]]) {
// currentStyle = `color: ${colorMap[match[1]]};`;
// }
break;
}
// check if the row and column are within the screen content array
while (screen.length <= cursorRow) {
screen.push(['']);
}
while (screen[cursorRow].length <= cursorCol) {
screen[cursorRow].push('');
}
}
// handle the remaining text
output += handleText(input.slice(lastIndex));
let result = [];
for (let row = 0; row < screen.length; row++) {
let rowContent = screen[row].join('');
result.push({
content: removeBrackets(rowContent),
uid: setId()
});
}
result.push({
content: output,
uid: setId()
});
return result;
};
return { parseAnsi, isClean };
};
export default useParseAnsi;
+6
View File
@@ -390,6 +390,12 @@ body {
.ant-pro-layout {
height: 100vh;
.ant-menu-inline-collapsed {
.anticon {
font-size: 16px;
}
}
.ant-pro-page-container-children-container {
padding-block: var(--layout-content-blockpadding);
padding-inline: var(--layout-content-inlinepadding);
@@ -386,9 +386,9 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
}
};
const handleClear = () => {
setMessageId();
setImageList([]);
setTokenResult(null);
// setMessageId();
// setImageList([]);
// setTokenResult(null);
};
const handleInputChange = (e: any) => {
@@ -15,6 +15,11 @@ interface MessageItemProps {
onDelete?: () => void;
}
const contentRenderOptions = [
{ label: 'Markdown', value: 'markdown' },
{ label: 'Plain Text', value: 'plain' }
];
const ContentItem: React.FC<MessageItemProps> = ({
updateMessage,
onDelete,