diff --git a/apps/web-antd/src/api/files.ts b/apps/web-antd/src/api/files.ts new file mode 100644 index 0000000..0ed7f5b --- /dev/null +++ b/apps/web-antd/src/api/files.ts @@ -0,0 +1,45 @@ +import { requestClient } from '#/api/request'; + +export type UploadFileType = + | 'business_license' + | 'dish_image' + | 'merchant_logo' + | 'other' + | 'review_image' + | 'user_avatar'; + +export interface FileUploadResponse { + fileName?: null | string; + fileSize: number; + url?: null | string; +} + +const TENANT_STORAGE_KEY = 'sys-tenant-id'; +const DEV_TENANT_ID = import.meta.env.DEV ? import.meta.env.VITE_TENANT_ID : ''; + +function resolveTenantId() { + const hostname = window.location.hostname; + const hostnameParts = hostname.split('.').filter(Boolean); + const isIpAddress = /^\d+\.\d+\.\d+\.\d+$/.test(hostname); + const subdomainTenantId = + hostnameParts.length > 2 && !isIpAddress ? hostnameParts[0] : ''; + const storageTenantId = localStorage.getItem(TENANT_STORAGE_KEY) || ''; + return subdomainTenantId || storageTenantId || DEV_TENANT_ID || ''; +} + +export async function uploadTenantFileApi( + file: File, + type: UploadFileType = 'other', +) { + const tenantId = resolveTenantId(); + if (!tenantId) { + throw new Error('缺少租户标识'); + } + + const formData = new FormData(); + formData.append('File', file); + formData.append('TenantId', String(tenantId)); + formData.append('Type', type); + + return requestClient.post('/files/upload', formData); +} diff --git a/apps/web-antd/src/views/product/category/components/CategoryEditorDrawer.vue b/apps/web-antd/src/views/product/category/components/CategoryEditorDrawer.vue new file mode 100644 index 0000000..2d5567d --- /dev/null +++ b/apps/web-antd/src/views/product/category/components/CategoryEditorDrawer.vue @@ -0,0 +1,327 @@ + + +