mirror of
https://github.com/langgenius/dify.git
synced 2026-05-03 08:58:09 +08:00
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:
@ -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
5
web/utils/get-icon.ts
Normal 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`
|
||||
}
|
||||
@ -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
9
web/utils/semver.ts
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user