style: 完成所有文件的lint

This commit is contained in:
claude-code-best
2026-05-01 21:39:30 +08:00
parent d136872cc9
commit 6182015005
1333 changed files with 68255 additions and 77882 deletions

View File

@@ -1,39 +1,29 @@
import React, { useState } from 'react'
import {
type OptionWithDescription,
Select,
} from '../../components/CustomSelect/select.js'
import { Dialog } from '@anthropic/ink'
import { Box, Text } from '@anthropic/ink'
import { useAppState } from '../../state/AppState.js'
import { isClaudeAISubscriber } from '../../utils/auth.js'
import { openBrowser } from '../../utils/browser.js'
import {
CLAUDE_IN_CHROME_MCP_SERVER_NAME,
openInChrome,
} from '../../utils/claudeInChrome/common.js'
import { isChromeExtensionInstalled } from '../../utils/claudeInChrome/setup.js'
import { getGlobalConfig, saveGlobalConfig } from '../../utils/config.js'
import { env } from '../../utils/env.js'
import { isRunningOnHomespace } from '../../utils/envUtils.js'
import React, { useState } from 'react';
import { type OptionWithDescription, Select } from '../../components/CustomSelect/select.js';
import { Dialog } from '@anthropic/ink';
import { Box, Text } from '@anthropic/ink';
import { useAppState } from '../../state/AppState.js';
import { isClaudeAISubscriber } from '../../utils/auth.js';
import { openBrowser } from '../../utils/browser.js';
import { CLAUDE_IN_CHROME_MCP_SERVER_NAME, openInChrome } from '../../utils/claudeInChrome/common.js';
import { isChromeExtensionInstalled } from '../../utils/claudeInChrome/setup.js';
import { getGlobalConfig, saveGlobalConfig } from '../../utils/config.js';
import { env } from '../../utils/env.js';
import { isRunningOnHomespace } from '../../utils/envUtils.js';
const CHROME_EXTENSION_URL = 'https://claude.ai/chrome'
const CHROME_PERMISSIONS_URL = 'https://clau.de/chrome/permissions'
const CHROME_RECONNECT_URL = 'https://clau.de/chrome/reconnect'
const CHROME_EXTENSION_URL = 'https://claude.ai/chrome';
const CHROME_PERMISSIONS_URL = 'https://clau.de/chrome/permissions';
const CHROME_RECONNECT_URL = 'https://clau.de/chrome/reconnect';
type MenuAction =
| 'install-extension'
| 'reconnect'
| 'manage-permissions'
| 'toggle-default'
type MenuAction = 'install-extension' | 'reconnect' | 'manage-permissions' | 'toggle-default';
type Props = {
onDone: (result?: string) => void
isExtensionInstalled: boolean
configEnabled: boolean | undefined
isClaudeAISubscriber: boolean
isWSL: boolean
}
onDone: (result?: string) => void;
isExtensionInstalled: boolean;
configEnabled: boolean | undefined;
isClaudeAISubscriber: boolean;
isWSL: boolean;
};
function ClaudeInChromeMenu({
onDone,
@@ -42,72 +32,66 @@ function ClaudeInChromeMenu({
isClaudeAISubscriber,
isWSL,
}: Props): React.ReactNode {
const mcpClients = useAppState(s => s.mcp.clients)
const [selectKey, setSelectKey] = useState(0)
const [enabledByDefault, setEnabledByDefault] = useState(
configEnabled ?? false,
)
const [showInstallHint, setShowInstallHint] = useState(false)
const [isExtensionInstalled, setIsExtensionInstalled] = useState(installed)
const mcpClients = useAppState(s => s.mcp.clients);
const [selectKey, setSelectKey] = useState(0);
const [enabledByDefault, setEnabledByDefault] = useState(configEnabled ?? false);
const [showInstallHint, setShowInstallHint] = useState(false);
const [isExtensionInstalled, setIsExtensionInstalled] = useState(installed);
const isHomespace = process.env.USER_TYPE === 'ant' && isRunningOnHomespace()
const isHomespace = process.env.USER_TYPE === 'ant' && isRunningOnHomespace();
const chromeClient = mcpClients.find(
c => c.name === CLAUDE_IN_CHROME_MCP_SERVER_NAME,
)
const isConnected = chromeClient?.type === 'connected'
const chromeClient = mcpClients.find(c => c.name === CLAUDE_IN_CHROME_MCP_SERVER_NAME);
const isConnected = chromeClient?.type === 'connected';
function openUrl(url: string): void {
if (isHomespace) {
void openBrowser(url)
void openBrowser(url);
} else {
void openInChrome(url)
void openInChrome(url);
}
}
function handleAction(action: MenuAction): void {
switch (action) {
case 'install-extension':
setSelectKey(k => k + 1)
setShowInstallHint(true)
openUrl(CHROME_EXTENSION_URL)
break
setSelectKey(k => k + 1);
setShowInstallHint(true);
openUrl(CHROME_EXTENSION_URL);
break;
case 'reconnect':
setSelectKey(k => k + 1)
setSelectKey(k => k + 1);
void isChromeExtensionInstalled().then(installed => {
setIsExtensionInstalled(installed)
setIsExtensionInstalled(installed);
if (installed) {
setShowInstallHint(false)
setShowInstallHint(false);
}
})
openUrl(CHROME_RECONNECT_URL)
break
});
openUrl(CHROME_RECONNECT_URL);
break;
case 'manage-permissions':
setSelectKey(k => k + 1)
openUrl(CHROME_PERMISSIONS_URL)
break
setSelectKey(k => k + 1);
openUrl(CHROME_PERMISSIONS_URL);
break;
case 'toggle-default': {
const newValue = !enabledByDefault
const newValue = !enabledByDefault;
saveGlobalConfig(current => ({
...current,
claudeInChromeDefaultEnabled: newValue,
}))
setEnabledByDefault(newValue)
break
}));
setEnabledByDefault(newValue);
break;
}
}
}
const options: OptionWithDescription<MenuAction>[] = []
const requiresExtensionSuffix = isExtensionInstalled
? ''
: ' (requires extension)'
const options: OptionWithDescription<MenuAction>[] = [];
const requiresExtensionSuffix = isExtensionInstalled ? '' : ' (requires extension)';
if (!isExtensionInstalled && !isHomespace) {
options.push({
label: 'Install Chrome extension',
value: 'install-extension',
})
});
}
options.push(
@@ -133,36 +117,23 @@ function ClaudeInChromeMenu({
label: `Enabled by default: ${enabledByDefault ? 'Yes' : 'No'}`,
value: 'toggle-default',
},
)
);
const isDisabled =
isWSL || ((process.env.USER_TYPE as string) !== 'ant' && !isClaudeAISubscriber)
const isDisabled = isWSL || ((process.env.USER_TYPE as string) !== 'ant' && !isClaudeAISubscriber);
return (
<Dialog
title="Claude in Chrome (Beta)"
onCancel={() => onDone()}
color="chromeYellow"
>
<Dialog title="Claude in Chrome (Beta)" onCancel={() => onDone()} color="chromeYellow">
<Box flexDirection="column" gap={1}>
<Text>
Claude in Chrome works with the Chrome extension to let you control
your browser directly from Claude Code. Navigate websites, fill forms,
capture screenshots, record GIFs, and debug with console logs and
network requests.
Claude in Chrome works with the Chrome extension to let you control your browser directly from Claude Code.
Navigate websites, fill forms, capture screenshots, record GIFs, and debug with console logs and network
requests.
</Text>
{isWSL && (
<Text color="error">
Claude in Chrome is not supported in WSL at this time.
</Text>
)}
{isWSL && <Text color="error">Claude in Chrome is not supported in WSL at this time.</Text>}
{(process.env.USER_TYPE as string) !== 'ant' && !isClaudeAISubscriber && (
<Text color="error">
Claude in Chrome requires a claude.ai subscription.
</Text>
<Text color="error">Claude in Chrome requires a claude.ai subscription.</Text>
)}
{!isDisabled && (
@@ -170,12 +141,7 @@ function ClaudeInChromeMenu({
{!isHomespace && (
<Box flexDirection="column">
<Text>
Status:{' '}
{isConnected ? (
<Text color="success">Enabled</Text>
) : (
<Text color="inactive">Disabled</Text>
)}
Status: {isConnected ? <Text color="success">Enabled</Text> : <Text color="inactive">Disabled</Text>}
</Text>
<Text>
Extension:{' '}
@@ -187,17 +153,10 @@ function ClaudeInChromeMenu({
</Text>
</Box>
)}
<Select
key={selectKey}
options={options}
onChange={handleAction}
hideIndexes
/>
<Select key={selectKey} options={options} onChange={handleAction} hideIndexes />
{showInstallHint && (
<Text color="warning">
Once installed, select {'"Reconnect extension"'} to connect.
</Text>
<Text color="warning">Once installed, select {'"Reconnect extension"'} to connect.</Text>
)}
<Text>
@@ -208,25 +167,22 @@ function ClaudeInChromeMenu({
</Text>
<Text dimColor>
Site-level permissions are inherited from the Chrome extension.
Manage permissions in the Chrome extension settings to control
which sites Claude can browse, click, and type on.
Site-level permissions are inherited from the Chrome extension. Manage permissions in the Chrome extension
settings to control which sites Claude can browse, click, and type on.
</Text>
</>
)}
<Text dimColor>Learn more: https://code.claude.com/docs/en/chrome</Text>
</Box>
</Dialog>
)
);
}
export const call = async function (
onDone: (result?: string) => void,
): Promise<React.ReactNode> {
const isExtensionInstalled = await isChromeExtensionInstalled()
const config = getGlobalConfig()
const isSubscriber = isClaudeAISubscriber()
const isWSL = env.isWslEnvironment()
export const call = async function (onDone: (result?: string) => void): Promise<React.ReactNode> {
const isExtensionInstalled = await isChromeExtensionInstalled();
const config = getGlobalConfig();
const isSubscriber = isClaudeAISubscriber();
const isWSL = env.isWslEnvironment();
return (
<ClaudeInChromeMenu
@@ -236,5 +192,5 @@ export const call = async function (
isClaudeAISubscriber={isSubscriber}
isWSL={isWSL}
/>
)
}
);
};