Feat/plugins (#12547)

Co-authored-by: AkaraChen <akarachen@outlook.com>
Co-authored-by: Yi <yxiaoisme@gmail.com>
Co-authored-by: Joel <iamjoel007@gmail.com>
Co-authored-by: JzoNg <jzongcode@gmail.com>
Co-authored-by: twwu <twwu@dify.ai>
Co-authored-by: kurokobo <kuro664@gmail.com>
Co-authored-by: Hiroshi Fujita <fujita-h@users.noreply.github.com>
This commit is contained in:
zxhlyh
2025-01-09 18:47:41 +08:00
committed by GitHub
parent e4c4490175
commit 3c014f3ae5
719 changed files with 48585 additions and 8553 deletions

View File

@ -34,3 +34,14 @@ export const formatTime = (num: number) => {
}
return `${num.toFixed(2)} ${units[index]}`
}
export const downloadFile = ({ data, fileName }: { data: Blob; fileName: string }) => {
const url = window.URL.createObjectURL(data)
const a = document.createElement('a')
a.href = url
a.download = fileName
document.body.appendChild(a)
a.click()
a.remove()
window.URL.revokeObjectURL(url)
}

5
web/utils/get-icon.ts Normal file
View File

@ -0,0 +1,5 @@
import { MARKETPLACE_API_PREFIX } from '@/config'
export const getIconFromMarketPlace = (plugin_id: string) => {
return `${MARKETPLACE_API_PREFIX}/plugins/${plugin_id}/icon`
}

View File

@ -55,3 +55,13 @@ export async function fetchWithRetry<T = any>(fn: Promise<T>, retries = 3): Prom
return [null, res]
}
}
export const correctProvider = (provider: string) => {
if (!provider)
return ''
if (provider.includes('/'))
return provider
return `langgenius/${provider}/${provider}`
}

9
web/utils/semver.ts Normal file
View File

@ -0,0 +1,9 @@
import semver from 'semver'
export const getLatestVersion = (versionList: string[]) => {
return semver.rsort(versionList)[0]
}
export const compareVersion = (v1: string, v2: string) => {
return semver.compare(v1, v2)
}