From 5335a42c4a295095c6236517b8d411bc5fd83665 Mon Sep 17 00:00:00 2001 From: Ir0nMax Date: Mon, 27 Jan 2025 15:42:15 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=98=8E=E4=BF=AE=E5=A4=8D=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E5=90=8E=E6=B0=B4=E5=8D=B0=E6=96=87=E6=9C=AC=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin.NET.Core/Service/Auth/SysAuthService.cs | 2 +- Web/src/stores/userInfo.ts | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Admin.NET/Admin.NET.Core/Service/Auth/SysAuthService.cs b/Admin.NET/Admin.NET.Core/Service/Auth/SysAuthService.cs index f7ae023d..87be28a0 100644 --- a/Admin.NET/Admin.NET.Core/Service/Auth/SysAuthService.cs +++ b/Admin.NET/Admin.NET.Core/Service/Auth/SysAuthService.cs @@ -285,7 +285,7 @@ public class SysAuthService : IDynamicApiController, ITransient // 接口集合 var apis = (await App.GetRequiredService().GetUserApiList())[0]; // 水印文字(若系统水印为空则不显示) - var watermarkText = await _sysConfigService.GetConfigValueByCode(ConfigConst.SysWebWatermark); + var watermarkText = await _sysUserRep.ChangeRepository>().AsQueryable().Where(u => u.Id == user.TenantId).Select(u => u.Watermark).FirstAsync(); if (!string.IsNullOrWhiteSpace(watermarkText)) watermarkText += $"-{user.RealName}"; // $"-{user.RealName}-{_httpContextAccessor.HttpContext.GetRemoteIpAddressToIPv4(true)}-{DateTime.Now}"; diff --git a/Web/src/stores/userInfo.ts b/Web/src/stores/userInfo.ts index 73ed9055..a5757cdb 100644 --- a/Web/src/stores/userInfo.ts +++ b/Web/src/stores/userInfo.ts @@ -1,5 +1,7 @@ import { defineStore } from 'pinia'; -import { Session } from '/@/utils/storage'; +import { Local, Session } from '/@/utils/storage'; +import Watermark from '/@/utils/watermark'; +import { useThemeConfig } from '/@/stores/themeConfig'; import { i18n } from '/@/i18n'; import { getAPI } from '/@/utils/axios-utils'; @@ -90,6 +92,15 @@ export const useUserInfo = defineStore('userInfo', { // 增加了下面代码,引起当前会话的用户信息不会刷新,如:重新提交的头像不更新,需要新开一个页面才能正确显示 // Session.set('userInfo', userInfos); + // 用户水印 + const storesThemeConfig = useThemeConfig(); + storesThemeConfig.themeConfig.watermarkText = d.watermarkText ?? ''; + if (storesThemeConfig.themeConfig.isWatermark) Watermark.set(storesThemeConfig.themeConfig.watermarkText); + else Watermark.del(); + + Local.remove('themeConfig'); + Local.set('themeConfig', storesThemeConfig.themeConfig); + resolve(userInfos); }); });