新增权限域名限制和链接背景上传
This commit is contained in:
@@ -1,5 +1,24 @@
|
||||
import {useSettingStore} from "@/store/setting.js";
|
||||
export function cvtR2Url(key) {
|
||||
const settingStore = useSettingStore();
|
||||
return settingStore.settings.r2Domain + '/' + key
|
||||
|
||||
if (!key) {
|
||||
return + 'https://' + ''
|
||||
}
|
||||
|
||||
if (key.startsWith('https://')) {
|
||||
return key
|
||||
}
|
||||
|
||||
const { settings } = useSettingStore();
|
||||
|
||||
let domain = settings.r2Domain
|
||||
|
||||
if (!domain.startsWith('http')) {
|
||||
return 'https://' + domain + '/' + key
|
||||
}
|
||||
|
||||
if (domain.endsWith("/")) {
|
||||
domain = domain.slice(0, -1);
|
||||
}
|
||||
return domain + '/' + key
|
||||
}
|
||||
@@ -40,11 +40,11 @@ export function fromNow(date) {
|
||||
if (diffSeconds < 60) return `Just now`;
|
||||
if (diffMinutes < 60) return `${diffMinutes} min ago`;
|
||||
if (diffHours < 2) return `${diffHours} hour${diffHours > 1 ? 's' : ''} ago`;
|
||||
return d.format('HH:mm');
|
||||
return d.format('hh:mm A');
|
||||
}
|
||||
|
||||
if (now.subtract(1, 'day').isSame(d, 'day')) {
|
||||
return d.format('hh:mm A');
|
||||
return d.format('MMM D');
|
||||
}
|
||||
|
||||
return d.year() === now.year()
|
||||
|
||||
@@ -14,13 +14,18 @@ export function formatBytes(bytes) {
|
||||
return `${size} ${units[i]}`;
|
||||
}
|
||||
|
||||
export function fileToBase64(file) {
|
||||
export function fileToBase64(file, type = false) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const reader = new FileReader();
|
||||
reader.readAsDataURL(file);
|
||||
reader.onload = () => {
|
||||
const base64 = reader.result.split(',')[1];
|
||||
resolve(base64);
|
||||
if (type) {
|
||||
const base64 = reader.result;
|
||||
resolve(base64);
|
||||
} else {
|
||||
const base64 = reader.result.split(',')[1];
|
||||
resolve(base64);
|
||||
}
|
||||
};
|
||||
reader.onerror = reject;
|
||||
});
|
||||
@@ -50,4 +55,4 @@ export function compressImage(file, config = {}) {
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user