feat: 添加租户列表接口,优化租户相关功能;更新前端租户列表和收藏功能
This commit is contained in:
@@ -24,11 +24,13 @@
|
||||
<div class="flex items-start gap-6">
|
||||
<div class="relative group cursor-pointer flex-shrink-0" @click="triggerUpload('avatar')">
|
||||
<div
|
||||
class="w-24 h-24 rounded-full border-4 border-slate-50 shadow-sm overflow-hidden bg-slate-100">
|
||||
class="w-24 h-24 rounded-full border-4 border-slate-50 shadow-sm overflow-hidden bg-slate-100 relative">
|
||||
<img :src="form.avatar" class="w-full h-full object-cover">
|
||||
<div
|
||||
class="absolute inset-0 bg-black/40 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity">
|
||||
<i class="pi pi-camera text-white text-2xl"></i>
|
||||
class="absolute inset-0 bg-black/40 flex items-center justify-center transition-opacity"
|
||||
:class="{'opacity-100': currentUploadType === 'avatar' && isUploading, 'opacity-0 group-hover:opacity-100': !(currentUploadType === 'avatar' && isUploading)}">
|
||||
<i v-if="currentUploadType === 'avatar' && isUploading" class="pi pi-spin pi-spinner text-white text-2xl"></i>
|
||||
<i v-else class="pi pi-camera text-white text-2xl"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -62,9 +64,14 @@
|
||||
<span class="text-sm font-medium">点击上传 (建议尺寸 1280x320)</span>
|
||||
</div>
|
||||
<!-- Hover Overlay -->
|
||||
<div v-if="form.cover"
|
||||
class="absolute inset-0 bg-black/40 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity">
|
||||
<span class="text-white font-bold"><i class="pi pi-refresh mr-2"></i>更换封面</span>
|
||||
<div v-if="form.cover || (currentUploadType === 'cover' && isUploading)"
|
||||
class="absolute inset-0 bg-black/40 flex flex-col items-center justify-center transition-opacity"
|
||||
:class="{'opacity-100': currentUploadType === 'cover' && isUploading, 'opacity-0 group-hover:opacity-100': !(currentUploadType === 'cover' && isUploading)}">
|
||||
<template v-if="currentUploadType === 'cover' && isUploading">
|
||||
<i class="pi pi-spin pi-spinner text-white text-3xl mb-2"></i>
|
||||
<span class="text-white text-sm font-bold">上传中 {{ Math.round(uploadProgress) }}%</span>
|
||||
</template>
|
||||
<span v-else class="text-white font-bold"><i class="pi pi-refresh mr-2"></i>更换封面</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -79,9 +86,11 @@
|
||||
|
||||
<!-- Save Button -->
|
||||
<div class="pt-6 border-t border-slate-100 flex justify-end">
|
||||
<button @click="saveSettings"
|
||||
class="px-8 py-3 bg-primary-600 text-white rounded-lg font-bold hover:bg-primary-700 shadow-lg shadow-primary-200 cursor-pointer active:scale-95 flex items-center gap-2">
|
||||
<i class="pi pi-check"></i> 保存修改
|
||||
<button @click="saveSettings" :disabled="saveLoading"
|
||||
class="px-8 py-3 bg-primary-600 text-white rounded-lg font-bold hover:bg-primary-700 shadow-lg shadow-primary-200 cursor-pointer active:scale-95 flex items-center gap-2 disabled:opacity-70 disabled:cursor-not-allowed">
|
||||
<i v-if="saveLoading" class="pi pi-spin pi-spinner"></i>
|
||||
<i v-else class="pi pi-check"></i>
|
||||
{{ saveLoading ? '保存中...' : '保存修改' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -193,6 +202,9 @@ const fileInput = ref(null);
|
||||
const currentUploadType = ref('');
|
||||
const showAddAccount = ref(false);
|
||||
const payoutAccounts = ref([]);
|
||||
const saveLoading = ref(false);
|
||||
const isUploading = ref(false);
|
||||
const uploadProgress = ref(0);
|
||||
|
||||
const newAccount = reactive({
|
||||
type: 'bank',
|
||||
@@ -240,9 +252,13 @@ const handleFileChange = async (event) => {
|
||||
const file = event.target.files[0];
|
||||
if (!file) return;
|
||||
|
||||
isUploading.value = true;
|
||||
uploadProgress.value = 0;
|
||||
|
||||
try {
|
||||
toast.add({ severity: 'info', summary: '正在上传...', life: 2000 });
|
||||
const task = commonApi.uploadWithProgress(file, 'image');
|
||||
const task = commonApi.uploadWithProgress(file, 'image', (p) => {
|
||||
uploadProgress.value = p;
|
||||
});
|
||||
const res = await task.promise;
|
||||
console.log('Upload response:', res);
|
||||
|
||||
@@ -260,6 +276,9 @@ const handleFileChange = async (event) => {
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
toast.add({ severity: 'error', summary: '上传失败', detail: e.message, life: 3000 });
|
||||
} finally {
|
||||
isUploading.value = false;
|
||||
uploadProgress.value = 0;
|
||||
}
|
||||
event.target.value = '';
|
||||
};
|
||||
@@ -304,11 +323,15 @@ const saveSettings = async () => {
|
||||
toast.add({ severity: 'error', summary: '错误', detail: '频道名称不能为空', life: 3000 });
|
||||
return;
|
||||
}
|
||||
if (saveLoading.value) return;
|
||||
saveLoading.value = true;
|
||||
try {
|
||||
await creatorApi.updateSettings(form);
|
||||
toast.add({ severity: 'success', summary: '保存成功', detail: '设置已更新', life: 3000 });
|
||||
} catch (e) {
|
||||
toast.add({ severity: 'error', summary: '保存失败', detail: e.message, life: 3000 });
|
||||
} finally {
|
||||
saveLoading.value = false;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
Reference in New Issue
Block a user