feat: add more tip in ai-assistant plugin

pull/147/merge
moonrailgun 1 year ago
parent 86088a348c
commit caad90cd47

@ -51,6 +51,11 @@ const ActionButton = styled.div`
} }
`; `;
const ActionTip = styled.div`
font-size: 12px;
opacity: 0.6;
`;
export const AssistantPopover: React.FC<{ export const AssistantPopover: React.FC<{
onCompleted: () => void; onCompleted: () => void;
}> = React.memo((props) => { }> = React.memo((props) => {
@ -115,31 +120,6 @@ export const AssistantPopover: React.FC<{
<Tip>{Translate.helpMeTo}</Tip> <Tip>{Translate.helpMeTo}</Tip>
{typeof message === 'string' && message.length > 0 && (
<>
<ActionButton
onClick={() => handleCallAI(improveTextPrompt + message)}
>
{Translate.improveText}
</ActionButton>
<ActionButton
onClick={() => handleCallAI(shorterTextPrompt + message)}
>
{Translate.makeShorter}
</ActionButton>
<ActionButton
onClick={() => handleCallAI(longerTextPrompt + message)}
>
{Translate.makeLonger}
</ActionButton>
<ActionButton
onClick={() => handleCallAI(translateTextPrompt + message)}
>
{Translate.translateInputText}
</ActionButton>
</>
)}
<ActionButton <ActionButton
onClick={async () => { onClick={async () => {
const plainMessages = ( const plainMessages = (
@ -165,6 +145,33 @@ export const AssistantPopover: React.FC<{
> >
{Translate.summaryMessages} {Translate.summaryMessages}
</ActionButton> </ActionButton>
{typeof message === 'string' && message.length > 0 ? (
<>
<ActionButton
onClick={() => handleCallAI(improveTextPrompt + message)}
>
{Translate.improveText}
</ActionButton>
<ActionButton
onClick={() => handleCallAI(shorterTextPrompt + message)}
>
{Translate.makeShorter}
</ActionButton>
<ActionButton
onClick={() => handleCallAI(longerTextPrompt + message)}
>
{Translate.makeLonger}
</ActionButton>
<ActionButton
onClick={() => handleCallAI(translateTextPrompt + message)}
>
{Translate.translateInputText}
</ActionButton>
</>
) : (
<ActionTip>{Translate.inputTextShowMoreActionTip}</ActionTip>
)}
</Root> </Root>
); );
}); });

@ -29,6 +29,10 @@ export const Translate = {
'zh-CN': '翻译输入内容', 'zh-CN': '翻译输入内容',
'en-US': 'Translate Input', 'en-US': 'Translate Input',
}), }),
inputTextShowMoreActionTip: localTrans({
'zh-CN': '或者输入内容后展示更多操作',
'en-US': 'Or input message then show more actions',
}),
usage: localTrans({ usage: localTrans({
'zh-CN': '用时', 'zh-CN': '用时',
'en-US': 'Usage', 'en-US': 'Usage',

Loading…
Cancel
Save