parent
9a0aeb491a
commit
9bd6dedd90
@ -0,0 +1,28 @@
|
||||
import { marked, Tokens } from 'marked';
|
||||
import React from 'react';
|
||||
|
||||
interface MarkdownViewerProps {
|
||||
content: string;
|
||||
height?: string;
|
||||
}
|
||||
|
||||
const MarkdownViewer: React.FC<MarkdownViewerProps> = ({
|
||||
content,
|
||||
height = 'auto'
|
||||
}) => {
|
||||
const renderer = new marked.Renderer();
|
||||
|
||||
renderer.link = ({ href, title, text }: Tokens.Link) => {
|
||||
return `<a href="${href}" title="${title || ''}" target="_blank" rel="noopener noreferrer">${text}</a>`;
|
||||
};
|
||||
|
||||
return (
|
||||
<div style={{ height, overflow: 'auto' }}>
|
||||
<div
|
||||
dangerouslySetInnerHTML={{ __html: marked(content, { renderer }) }}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default React.memo(MarkdownViewer);
|
||||
@ -0,0 +1,60 @@
|
||||
import { KeyMap } from '@/config/hotkeys';
|
||||
export default [
|
||||
{
|
||||
scope: 'playground',
|
||||
command: 'shortcuts.playground.newmessage',
|
||||
keybinding: KeyMap.CREATE.iconKeybinding
|
||||
},
|
||||
{
|
||||
scope: 'playground',
|
||||
command: 'shortcuts.playground.clearmessage',
|
||||
keybinding: KeyMap.CLEAR.iconKeybinding
|
||||
},
|
||||
{
|
||||
scope: 'playground',
|
||||
command: 'shortcuts.playground.toggleparams',
|
||||
keybinding: KeyMap.RIGHT.iconKeybinding
|
||||
},
|
||||
{
|
||||
scope: 'models',
|
||||
// span: {
|
||||
// rowSpan: 3,
|
||||
// colSpan: 1
|
||||
// },
|
||||
command: 'shortcuts.models.newmodelHF',
|
||||
keybinding: KeyMap.NEW1.iconKeybinding
|
||||
},
|
||||
{
|
||||
scope: 'models',
|
||||
command: 'shortcuts.models.newmodelLM',
|
||||
keybinding: KeyMap.NEW2.iconKeybinding
|
||||
// span: {
|
||||
// rowSpan: 0,
|
||||
// colSpan: 0
|
||||
// }
|
||||
},
|
||||
{
|
||||
scope: 'models',
|
||||
command: 'shortcuts.models.search',
|
||||
keybinding: KeyMap.SEARCH.iconKeybinding
|
||||
// span: {
|
||||
// rowSpan: 0,
|
||||
// colSpan: 0
|
||||
// }
|
||||
},
|
||||
{
|
||||
scope: 'resources',
|
||||
command: 'shortcuts.resources.addworker',
|
||||
keybinding: KeyMap.CREATE.iconKeybinding
|
||||
},
|
||||
{
|
||||
scope: 'API keys',
|
||||
command: 'shortcuts.apikeys.new',
|
||||
keybinding: KeyMap.CREATE.iconKeybinding
|
||||
},
|
||||
{
|
||||
scope: 'users',
|
||||
command: 'shortcuts.users.new',
|
||||
keybinding: KeyMap.CREATE.iconKeybinding
|
||||
}
|
||||
];
|
||||
@ -1,17 +1,60 @@
|
||||
export default {
|
||||
CREATE: ['ctrl+alt+n', 'option+meta+n'],
|
||||
SAVE: ['ctrl+s', 'meta+s'],
|
||||
import { platformCall } from '@/utils';
|
||||
const platform = platformCall();
|
||||
const KeybindingsMap = {
|
||||
CREATE: ['alt+ctrl+N', 'alt+meta+N'],
|
||||
CLEAR: ['alt+ctrl+W', 'alt+meta+W'],
|
||||
RIGHT: ['ctrl+RIGHT', 'meta+RIGHT'],
|
||||
SAVE: ['ctrl+S', 'meta+S'],
|
||||
SUBMIT: ['ctrl+enter', 'meta+enter'],
|
||||
SAVEAS: ['ctrl+shift+s', 'meta+shift+s'],
|
||||
OPEN: ['ctrl+o', 'meta+o'],
|
||||
CANCEL: ['ctrl+w', 'meta+w'],
|
||||
SAVEAS: ['alt+ctrl+S', 'alt+meta+S'],
|
||||
OPEN: ['alt+ctrl+O', 'alt+meta+O'],
|
||||
CANCEL: ['ctrl+W', 'meta+W'],
|
||||
DELETE: ['delete'],
|
||||
COPY: ['ctrl+c', 'meta+c'],
|
||||
REFRESH: ['ctrl+r', 'meta+r'],
|
||||
EDIT: ['ctrl+e', 'meta+e'],
|
||||
SEARCH: ['ctrl+f', 'meta+f'],
|
||||
RESET: ['ctrl+shift+r', 'meta+shift+r'],
|
||||
INPUT: ['ctrl+k', 'meta+k'],
|
||||
COPY: ['ctrl+C', 'meta+C'],
|
||||
REFRESH: ['ctrl+R', 'meta+R'],
|
||||
EDIT: ['ctrl+E', 'meta+E'],
|
||||
SEARCH: ['ctrl+K', 'meta+K'],
|
||||
RESET: ['alt+ctrl+R', 'alt+meta+R'],
|
||||
INPUT: ['ctrl+K', 'meta+K'],
|
||||
NEW1: ['ctrl+1', 'meta+1'],
|
||||
NEW2: ['ctrl+2', 'meta+2']
|
||||
};
|
||||
|
||||
type KeyBindingType = keyof typeof KeybindingsMap;
|
||||
|
||||
type KeybindingValue = {
|
||||
keybinding: string;
|
||||
command: KeyBindingType;
|
||||
textKeybinding: string;
|
||||
iconKeybinding: string;
|
||||
};
|
||||
|
||||
const KeybiningList: KeybindingValue[] = Object.entries(KeybindingsMap).map(
|
||||
([key, value]) => {
|
||||
const keybinding = platform.isMac ? value[1] || value[0] : value[0];
|
||||
return {
|
||||
keybinding: keybinding,
|
||||
command: key,
|
||||
textKeybinding: platform.isMac
|
||||
? keybinding.replace('meta', 'Command').replace('alt', 'Option')
|
||||
: keybinding.replace('ctrl', 'Ctrl'),
|
||||
iconKeybinding: platform.isMac
|
||||
? keybinding.replace('meta', '⌘').replace('alt', '⌥')
|
||||
: keybinding.replace('ctrl', 'Ctrl')
|
||||
} as KeybindingValue;
|
||||
}
|
||||
);
|
||||
|
||||
const KeyMap: Record<KeyBindingType, KeybindingValue> = KeybiningList.reduce(
|
||||
(acc: any, item) => {
|
||||
acc[item.command] = item;
|
||||
return acc;
|
||||
},
|
||||
{}
|
||||
);
|
||||
|
||||
console.log('KeyMap=========', KeyMap);
|
||||
|
||||
export { KeyMap, KeybiningList };
|
||||
|
||||
export default KeybindingsMap;
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
export default {
|
||||
'shortcuts.search.placeholder': 'Search keybindings',
|
||||
'shortcuts.title': 'Keyboard shortcuts',
|
||||
'shortcuts.playground.newmessage': 'New message',
|
||||
'shortcuts.playground.clearmessage': 'Clear messages',
|
||||
'shortcuts.playground.toggleparams': 'Collapse/Expand parameters',
|
||||
'shortcuts.models.newmodelHF': 'Deploy Hugging Face model',
|
||||
'shortcuts.models.newmodelLM': 'Deploy Ollama model',
|
||||
'shortcuts.models.search': 'Search models from Hugging Face',
|
||||
'shortcuts.resources.addworker': 'Add worker',
|
||||
'shortcuts.apikeys.new': 'New API key',
|
||||
'shortcuts.users.new': 'New user'
|
||||
};
|
||||
@ -0,0 +1,14 @@
|
||||
// keyborad shortcuts
|
||||
export default {
|
||||
'shortcuts.title': '快捷键',
|
||||
'shortcuts.search.placeholder': '搜索快捷键',
|
||||
'shortcuts.playground.newmessage': '新建消息',
|
||||
'shortcuts.playground.clearmessage': '清空消息',
|
||||
'shortcuts.playground.toggleparams': '收起/展开参数',
|
||||
'shortcuts.models.newmodelHF': '部署 Hugging Face 模型',
|
||||
'shortcuts.models.newmodelLM': '部署 Ollama 模型',
|
||||
'shortcuts.models.search': '从 Hugging Face 搜索模型',
|
||||
'shortcuts.resources.addworker': '添加节点',
|
||||
'shortcuts.apikeys.new': '新建 API 密钥',
|
||||
'shortcuts.users.new': '新建用户'
|
||||
};
|
||||
Loading…
Reference in new issue