diff --git a/backend/shop/views.py b/backend/shop/views.py index 0e978d1..aca8d2d 100644 --- a/backend/shop/views.py +++ b/backend/shop/views.py @@ -1466,7 +1466,22 @@ class DistributorViewSet(viewsets.GenericViewSet): distributor = user.distributor if distributor.qr_code_url: - return Response({'qr_code_url': distributor.qr_code_url}) + # 检查文件是否真的存在 + try: + # 如果是本地存储,检查文件路径 + if distributor.qr_code_url.startswith(settings.MEDIA_URL): + file_path = distributor.qr_code_url.replace(settings.MEDIA_URL, '', 1) + if default_storage.exists(file_path): + return Response({'qr_code_url': distributor.qr_code_url}) + elif distributor.qr_code_url.startswith('http'): + # 远程 URL,假设有效 + return Response({'qr_code_url': distributor.qr_code_url}) + except Exception as e: + logger.warning(f"Error checking QR code existence: {e}") + + # 如果文件不存在,重置 URL 并重新生成 + distributor.qr_code_url = '' + distributor.save() # 确保有邀请码 if not distributor.invite_code: diff --git a/miniprogram/config/index.js b/miniprogram/config/index.js index 3a0295d..552c4a8 100644 --- a/miniprogram/config/index.js +++ b/miniprogram/config/index.js @@ -32,6 +32,11 @@ const config = { enable: false // Disable cache to fix prebundle error }, mini: { + compile: { + include: [ + path.resolve(__dirname, '..', 'node_modules/marked') + ] + }, postcss: { pxtransform: { enable: true,