From 1555bec154417f91d37b9257f94d62b262af98f8 Mon Sep 17 00:00:00 2001 From: jeremygan2021 Date: Tue, 17 Feb 2026 11:41:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E5=88=86=E9=94=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/shop/views.py | 17 ++++++++++++++++- miniprogram/config/index.js | 5 +++++ 2 files changed, 21 insertions(+), 1 deletion(-) 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,