mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 21:20:29 +08:00
18 lines
531 B
TypeScript
18 lines
531 B
TypeScript
import axios from 'axios'
|
|
import { getControledMihomoConfig } from '../config'
|
|
|
|
export async function getImageDataURL(url: string): Promise<string> {
|
|
const { 'mixed-port': port = 7890 } = await getControledMihomoConfig()
|
|
const res = await axios.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).toString('base64')}`
|
|
return dataURL
|
|
}
|