export const createId = (before: string = 'node') => {
	const time = Date.now().toString(36)
	const random = Math.random().toString(36).substring(2, 20)
	return `${before}_${time}${random}`
}

/** 下载图片 */
export const downloadImage = (url: string, name: string) => {
	fetch(url)
		.then((res) => res.blob())
		.then((blob) => {
			const a = document.createElement('a')
			a.href = URL.createObjectURL(blob)
			a.target = '_blank'
			a.download = name || 'image.png'
			a.click()
		})
}