mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-09-05 15:37:21 +08:00
🔨 Refactor(custom): refactored imports
This commit is contained in:
@@ -118,11 +118,6 @@ export function formatFileName (fileName: string, length: number = 20) {
|
||||
return isNeedToShorten(fileName, length) ? `${safeSliceF(name, length - 3 - ext.length)}...${ext}` : fileName
|
||||
}
|
||||
|
||||
export const getExtension = (fileName: string) => path.extname(fileName).slice(1)
|
||||
|
||||
export const isImage = (fileName: string) =>
|
||||
['jpg', 'jpeg', 'png', 'gif', 'webp', 'bmp', 'ico', 'svg'].includes(getExtension(fileName))
|
||||
|
||||
export function formObjToTableData (obj: any) {
|
||||
const exclude = [undefined, null, '', 'transformedConfig']
|
||||
return Object.keys(obj).filter(key => !exclude.includes(obj[key])).map(key => ({
|
||||
@@ -139,34 +134,6 @@ export function isValidUrl (str: string) {
|
||||
}
|
||||
}
|
||||
|
||||
export interface IHTTPProxy {
|
||||
host: string
|
||||
port: number
|
||||
protocol: string
|
||||
}
|
||||
|
||||
export const formatHttpProxy = (proxy: string | undefined, type: 'object' | 'string'): IHTTPProxy | undefined | string => {
|
||||
if (!proxy) return undefined
|
||||
if (/^https?:\/\//.test(proxy)) {
|
||||
const { protocol, hostname, port } = new URL(proxy)
|
||||
return type === 'string'
|
||||
? `${protocol}//${hostname}:${port}`
|
||||
: {
|
||||
host: hostname,
|
||||
port: Number(port),
|
||||
protocol: protocol.slice(0, -1)
|
||||
}
|
||||
}
|
||||
const [host, port] = proxy.split(':')
|
||||
return type === 'string'
|
||||
? `http://${host}:${port}`
|
||||
: {
|
||||
host,
|
||||
port: port ? Number(port) : 80,
|
||||
protocol: 'http'
|
||||
}
|
||||
}
|
||||
|
||||
export const svg = `
|
||||
<path class="path" d="
|
||||
M 30 15
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
export const cancelDownloadLoadingFileList = 'cancelDownloadLoadingFileList'
|
||||
export const refreshDownloadFileTransferList = 'refreshDownloadFileTransferList'
|
||||
export const selectDownloadFolder = 'selectDownloadFolder'
|
||||
Reference in New Issue
Block a user