This commit is contained in:
eoao
2025-04-26 17:24:39 +08:00
commit 24ba4772e6
107 changed files with 13612 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
import {useSettingStore} from "@/store/setting.js";
export function cvtR2Url(key) {
const settingStore = useSettingStore();
return 'https://' + settingStore.settings.r2Domain + '/' + key
}

View File

@@ -0,0 +1,13 @@
export function getExtName(fileName) {
const index = fileName.lastIndexOf('.')
return index !== -1 ? fileName.slice(index + 1).toLowerCase() : ''
}
export function formatBytes(bytes) {
if (bytes === 0) return '0 B';
const k = 1024;
const units = ['B', 'KB', 'MB', 'GB', 'TB'];
const i = Math.floor(Math.log(bytes) / Math.log(k));
const size = (bytes / Math.pow(k, i)).toFixed(2);
return `${size} ${units[i]}`;
}

View File

@@ -0,0 +1,3 @@
export function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms))
}

View File

@@ -0,0 +1,4 @@
export function isEmail(email) {
const reg = /^[a-zA-Z0-9]+@([a-zA-Z0-9-]+\.)+[a-zA-Z0-9-]+$/;
return reg.test(email);
}