mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-21 15:55:50 +00:00
style: 完成所有文件的lint
This commit is contained in:
@@ -1,91 +1,77 @@
|
||||
import React, { useCallback } from 'react'
|
||||
import { Text, Dialog } from '@anthropic/ink'
|
||||
import { getGlobalConfig, saveGlobalConfig } from '../utils/config.js'
|
||||
import { isSupportedTerminal } from '../utils/ide.js'
|
||||
import { Select } from './CustomSelect/index.js'
|
||||
import React, { useCallback } from 'react';
|
||||
import { Text, Dialog } from '@anthropic/ink';
|
||||
import { getGlobalConfig, saveGlobalConfig } from '../utils/config.js';
|
||||
import { isSupportedTerminal } from '../utils/ide.js';
|
||||
import { Select } from './CustomSelect/index.js';
|
||||
|
||||
type IdeAutoConnectDialogProps = {
|
||||
onComplete: () => void
|
||||
}
|
||||
onComplete: () => void;
|
||||
};
|
||||
|
||||
export function IdeAutoConnectDialog({
|
||||
onComplete,
|
||||
}: IdeAutoConnectDialogProps): React.ReactNode {
|
||||
export function IdeAutoConnectDialog({ onComplete }: IdeAutoConnectDialogProps): React.ReactNode {
|
||||
const handleSelect = useCallback(
|
||||
async (value: string) => {
|
||||
const autoConnect = value === 'yes'
|
||||
const autoConnect = value === 'yes';
|
||||
|
||||
// Save the preference and mark dialog as shown
|
||||
saveGlobalConfig(current => ({
|
||||
...current,
|
||||
autoConnectIde: autoConnect,
|
||||
hasIdeAutoConnectDialogBeenShown: true,
|
||||
}))
|
||||
}));
|
||||
|
||||
onComplete()
|
||||
onComplete();
|
||||
},
|
||||
[onComplete],
|
||||
)
|
||||
);
|
||||
|
||||
const options = [
|
||||
{ label: 'Yes', value: 'yes' },
|
||||
{ label: 'No', value: 'no' },
|
||||
]
|
||||
];
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
title="Do you wish to enable auto-connect to IDE?"
|
||||
color="ide"
|
||||
onCancel={onComplete}
|
||||
>
|
||||
<Dialog title="Do you wish to enable auto-connect to IDE?" color="ide" onCancel={onComplete}>
|
||||
<Select options={options} onChange={handleSelect} defaultValue={'yes'} />
|
||||
<Text dimColor>
|
||||
You can also configure this in /config or with the --ide flag
|
||||
</Text>
|
||||
<Text dimColor>You can also configure this in /config or with the --ide flag</Text>
|
||||
</Dialog>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export function shouldShowAutoConnectDialog(): boolean {
|
||||
const config = getGlobalConfig()
|
||||
return (
|
||||
!isSupportedTerminal() &&
|
||||
config.autoConnectIde !== true &&
|
||||
config.hasIdeAutoConnectDialogBeenShown !== true
|
||||
)
|
||||
const config = getGlobalConfig();
|
||||
return !isSupportedTerminal() && config.autoConnectIde !== true && config.hasIdeAutoConnectDialogBeenShown !== true;
|
||||
}
|
||||
|
||||
type IdeDisableAutoConnectDialogProps = {
|
||||
onComplete: (disableAutoConnect: boolean) => void
|
||||
}
|
||||
onComplete: (disableAutoConnect: boolean) => void;
|
||||
};
|
||||
|
||||
export function IdeDisableAutoConnectDialog({
|
||||
onComplete,
|
||||
}: IdeDisableAutoConnectDialogProps): React.ReactNode {
|
||||
export function IdeDisableAutoConnectDialog({ onComplete }: IdeDisableAutoConnectDialogProps): React.ReactNode {
|
||||
const handleSelect = useCallback(
|
||||
(value: string) => {
|
||||
const disableAutoConnect = value === 'yes'
|
||||
const disableAutoConnect = value === 'yes';
|
||||
|
||||
if (disableAutoConnect) {
|
||||
saveGlobalConfig(current => ({
|
||||
...current,
|
||||
autoConnectIde: false,
|
||||
}))
|
||||
}));
|
||||
}
|
||||
|
||||
onComplete(disableAutoConnect)
|
||||
onComplete(disableAutoConnect);
|
||||
},
|
||||
[onComplete],
|
||||
)
|
||||
);
|
||||
|
||||
const handleCancel = useCallback(() => {
|
||||
onComplete(false)
|
||||
}, [onComplete])
|
||||
onComplete(false);
|
||||
}, [onComplete]);
|
||||
|
||||
const options = [
|
||||
{ label: 'No', value: 'no' },
|
||||
{ label: 'Yes', value: 'yes' },
|
||||
]
|
||||
];
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
@@ -96,10 +82,10 @@ export function IdeDisableAutoConnectDialog({
|
||||
>
|
||||
<Select options={options} onChange={handleSelect} defaultValue={'no'} />
|
||||
</Dialog>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export function shouldShowDisableAutoConnectDialog(): boolean {
|
||||
const config = getGlobalConfig()
|
||||
return !isSupportedTerminal() && config.autoConnectIde === true
|
||||
const config = getGlobalConfig();
|
||||
return !isSupportedTerminal() && config.autoConnectIde === true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user