fix: remove redundant local variables (#5654)

This commit is contained in:
自由的世界人 2025-05-04 19:56:56 +08:00 committed by GitHub
parent df943f3027
commit 0bad95230e
12 changed files with 17 additions and 31 deletions

View File

@ -237,8 +237,7 @@ async function getPoisData(apiKey: string, ids: string[]): Promise<BravePoiRespo
throw new Error(`Brave API error: ${response.status} ${response.statusText}\n${await response.text()}`)
}
const poisResponse = (await response.json()) as BravePoiResponse
return poisResponse
return (await response.json()) as BravePoiResponse
}
async function getDescriptionsData(apiKey: string, ids: string[]): Promise<BraveDescription> {
@ -257,8 +256,7 @@ async function getDescriptionsData(apiKey: string, ids: string[]): Promise<Brave
throw new Error(`Brave API error: ${response.status} ${response.statusText}\n${await response.text()}`)
}
const descriptionsData = (await response.json()) as BraveDescription
return descriptionsData
return (await response.json()) as BraveDescription
}
function formatLocalResults(poisData: BravePoiResponse, descData: BraveDescription): string {

View File

@ -209,20 +209,16 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
const validatedArgs = RequestPayloadSchema.parse(args)
if (request.params.name === 'fetch_html') {
const fetchResult = await Fetcher.html(validatedArgs)
return fetchResult
return await Fetcher.html(validatedArgs)
}
if (request.params.name === 'fetch_json') {
const fetchResult = await Fetcher.json(validatedArgs)
return fetchResult
return await Fetcher.json(validatedArgs)
}
if (request.params.name === 'fetch_txt') {
const fetchResult = await Fetcher.txt(validatedArgs)
return fetchResult
return await Fetcher.txt(validatedArgs)
}
if (request.params.name === 'fetch_markdown') {
const fetchResult = await Fetcher.markdown(validatedArgs)
return fetchResult
return await Fetcher.markdown(validatedArgs)
}
throw new Error('Tool not found')
})

View File

@ -183,7 +183,6 @@ async function searchFiles(
}
} catch (error) {
// Skip invalid paths during search
continue
}
}
}

View File

@ -55,8 +55,8 @@ class SequentialThinkingServer {
const { thoughtNumber, totalThoughts, thought, isRevision, revisesThought, branchFromThought, branchId } =
thoughtData
let prefix = ''
let context = ''
let prefix: string
let context: string
if (isRevision) {
prefix = chalk.yellow('🔄 Revision')

View File

@ -83,7 +83,7 @@ export class ExportService {
}
break
case 'text':
runs.push(new TextRun({ text: token.content, bold: isHeaderRow ? true : false }))
runs.push(new TextRun({ text: token.content, bold: isHeaderRow }))
break
case 'strong':
runs.push(new TextRun({ text: token.content, bold: true }))

View File

@ -10,7 +10,7 @@ export class GeminiService {
static async uploadFile(_: Electron.IpcMainInvokeEvent, file: FileType, apiKey: string): Promise<File> {
const sdk = new GoogleGenAI({ vertexai: false, apiKey })
const uploadResult = await sdk.files.upload({
return await sdk.files.upload({
file: file.path,
config: {
mimeType: 'application/pdf',
@ -18,7 +18,6 @@ export class GeminiService {
displayName: file.origin_name
}
})
return uploadResult
}
static async base64File(_: Electron.IpcMainInvokeEvent, file: FileType) {

View File

@ -429,13 +429,12 @@ class McpService {
const client = await this.initClient(server)
try {
const { prompts } = await client.listPrompts()
const serverPrompts = prompts.map((prompt: any) => ({
return prompts.map((prompt: any) => ({
...prompt,
id: `p${nanoid()}`,
serverId: server.id,
serverName: server.name
}))
return serverPrompts
} catch (error) {
Logger.error(`[MCP] Failed to list prompts for server: ${server.name}`, error)
return []

View File

@ -32,10 +32,9 @@ interface WebDAVResponse {
}
export async function getNutstoreSSOUrl() {
const url = await createOAuthUrl({
return await createOAuthUrl({
app: 'cherrystudio'
})
return url
}
export async function decryptToken(token: string) {

View File

@ -129,12 +129,11 @@ export class ProxyManager {
if (!protocol.includes('socks')) {
setGlobalDispatcher(new ProxyAgent(proxyUrl))
} else {
const dispatcher = socksDispatcher({
global[Symbol.for('undici.globalDispatcher.1')] = socksDispatcher({
port: parseInt(port),
type: protocol === 'socks5' ? 5 : 4,
host: host
})
global[Symbol.for('undici.globalDispatcher.1')] = dispatcher
}
}
}

View File

@ -74,8 +74,7 @@ export class SearchService {
})
// Get the page content after ensuring it's fully loaded
const content = await window.webContents.executeJavaScript('document.documentElement.outerHTML')
return content
return await window.webContents.executeJavaScript('document.documentElement.outerHTML')
}
}

View File

@ -44,7 +44,7 @@ export class CallBackServer {
Logger.error('OAuth callback server error:', error)
})
const runningServer = new Promise<http.Server>((resolve, reject) => {
return new Promise<http.Server>((resolve, reject) => {
server.listen(port, () => {
Logger.info(`OAuth callback server listening on port ${port}`)
resolve(server)
@ -54,7 +54,6 @@ export class CallBackServer {
reject(error)
})
})
return runningServer
}
get getServer(): Promise<http.Server> {

View File

@ -9,14 +9,13 @@ const gunzipPromise = util.promisify(zlib.gunzip)
/**
*
* @param {string} string - JSON
* @returns {Promise<Buffer>} Buffer
* @param str
*/
export async function compress(str) {
try {
const buffer = Buffer.from(str, 'utf-8')
const compressedBuffer = await gzipPromise(buffer)
return compressedBuffer
return await gzipPromise(buffer)
} catch (error) {
logger.error('Compression failed:', error)
throw error