From 41132310b4d00834c383f6aa4243b523d037d5b3 Mon Sep 17 00:00:00 2001 From: jiayuan929 <252461528@qq.com> Date: Tue, 30 Aug 2022 20:33:14 +0800 Subject: [PATCH] =?UTF-8?q?bugfix:admin=E4=B8=AD=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E4=BF=A1=E6=81=AF=E5=90=8Elogo=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E9=94=99=E8=AF=AF=20#2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/models.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/backend/app/models.py b/backend/app/models.py index 0d6d5cc..c7ee3b6 100644 --- a/backend/app/models.py +++ b/backend/app/models.py @@ -190,6 +190,25 @@ def save(self, *args, **kwargs): # save操作 super(App, self).save(*args, **kwargs) + @property + def logo_url(self): + if self.logo: + return "%s?v=%s" % (self.logo.url, time.time()) + else: + # 判断 以 app_code 命名的 logo 图片是否存在 + logo_name = "%s/%s.png" % (APP_LOGO_IMG_RELATED, self.code) + logo_path = os.path.join(settings.MEDIA_ROOT, logo_name) + if os.path.exists(logo_path): + return "%s%s" % (settings.MEDIA_URL, logo_name) + + # 判断是否是上传saas解压生成的文件, 存在的话使用之(saas内置应用上传包中带的logo) + logo_name = "%s/%s.png" % (SAAS_APP_LOGO_IMG_RELATED, self.code) + logo_path = os.path.join(settings.MEDIA_ROOT, logo_name) + if os.path.exists(logo_path): + return "%s%s" % (settings.MEDIA_URL, logo_name) + + return "%simg/app_logo/default.png" % settings.STATIC_URL + @property def get_logo_url(self): if self.logo: