mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2026-04-14 00:20:33 +08:00
18 lines
572 B
TypeScript
18 lines
572 B
TypeScript
import { getControledMihomoConfig } from '../config'
|
|
import * as chromeRequest from './chromeRequest'
|
|
|
|
export async function getImageDataURL(url: string): Promise<string> {
|
|
const { 'mixed-port': port = 7890 } = await getControledMihomoConfig()
|
|
const res = await chromeRequest.get(url, {
|
|
responseType: 'arraybuffer',
|
|
proxy: {
|
|
protocol: 'http',
|
|
host: '127.0.0.1',
|
|
port
|
|
}
|
|
})
|
|
const mimeType = res.headers['content-type']
|
|
const dataURL = `data:${mimeType};base64,${Buffer.from(res.data as Buffer).toString('base64')}`
|
|
return dataURL
|
|
}
|