Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"mermaid": "^10.9.0",
"mitt": "^3.0.0",
"moment": "^2.30.1",
"nanoid": "^5.1.5",
"npm": "^10.2.4",
"nprogress": "^0.2.0",
"pinia": "^2.1.6",
Expand Down
8 changes: 5 additions & 3 deletions ui/src/utils/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MsgError } from '@/utils/message'

import { nanoid } from 'nanoid'
export function toThousands(num: any) {
return num?.toString().replace(/\d+/, function (n: any) {
return n.replace(/(\d)(?=(?:\d{3})+$)/g, '$1,')
Expand All @@ -25,7 +25,7 @@ export function filesize(size: number) {
随机id
*/
export const randomId = function () {
return Math.floor(Math.random() * 10000) + ''
return nanoid()
}

/*
Expand All @@ -48,7 +48,9 @@ const typeList: any = {
export function getImgUrl(name: string) {
const list = Object.values(typeList).flat()

const type = list.includes(fileType(name).toLowerCase()) ? fileType(name).toLowerCase() : 'unknown'
const type = list.includes(fileType(name).toLowerCase())
? fileType(name).toLowerCase()
: 'unknown'
return new URL(`../assets/fileType/${type}-icon.svg`, import.meta.url).href
}
// 是否是白名单后缀
Expand Down