feat: 品牌 Logo 支持启动页吉祥物,上传区改为点击预览
All checks were successful
Build and Deploy Front / deploy (push) Successful in 4m8s
All checks were successful
Build and Deploy Front / deploy (push) Successful in 4m8s
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
4434f9552a
commit
e7ad6e79a5
19
index.html
19
index.html
@ -408,6 +408,25 @@
|
||||
if (sub) sub.textContent = copy.sub;
|
||||
if (retry) retry.textContent = copy.retry;
|
||||
|
||||
/* 冷启动优先用缓存吉祥物,避免等 Vue/API(与 brandLogo.ts MASCOT_CACHE_KEY 一致) */
|
||||
try {
|
||||
var cachedMascot = (localStorage.getItem('oms_brand_mascot_url') || '').trim();
|
||||
var logoImg = boot.querySelector('.boot-logo');
|
||||
if (
|
||||
logoImg &&
|
||||
cachedMascot &&
|
||||
(/^https?:\/\//i.test(cachedMascot) ||
|
||||
cachedMascot.charAt(0) === '/' ||
|
||||
cachedMascot.indexOf('data:') === 0)
|
||||
) {
|
||||
logoImg.src = cachedMascot;
|
||||
root.style.setProperty(
|
||||
'--app-mascot-bg',
|
||||
'url("' + cachedMascot.replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '")',
|
||||
);
|
||||
}
|
||||
} catch (eMascot) {}
|
||||
|
||||
window.__dismissAppBoot = function () {
|
||||
if (!boot || boot.classList.contains('is-leaving')) return;
|
||||
boot.classList.add('is-leaving');
|
||||
|
||||
@ -76,14 +76,16 @@ export async function uploadPaymentReceiveQr(channel: PaymentReceiveQrChannel, f
|
||||
return unwrapData<PaymentReceiveQrDto>(res.data)
|
||||
}
|
||||
|
||||
export type BrandLogoChannel = 'portal' | 'site'
|
||||
export type BrandLogoChannel = 'portal' | 'site' | 'favicon' | 'mascot'
|
||||
|
||||
export interface BrandLogoDto {
|
||||
portalUrl?: string
|
||||
siteUrl?: string
|
||||
faviconUrl?: string
|
||||
mascotUrl?: string
|
||||
}
|
||||
|
||||
/** 获取品牌 Logo(系统顶栏 / 官网)可访问地址 */
|
||||
/** 获取品牌 Logo(系统顶栏 / 官网 / 标签 / 吉祥物)可访问地址 */
|
||||
export async function getBrandLogo() {
|
||||
const res = await axiosInstance.get(omsUrl('/system/other-config/brand-logo'))
|
||||
return unwrapData<BrandLogoDto>(res.data)
|
||||
|
||||
@ -51,7 +51,7 @@ body {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
margin: 0 auto;
|
||||
background: url('/app-mascot.png') center / contain no-repeat;
|
||||
background: var(--app-mascot-bg, url('/app-mascot.png')) center / contain no-repeat;
|
||||
filter: grayscale(1) brightness(1.08) contrast(0.92);
|
||||
opacity: 0.78;
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<img
|
||||
class="app-mascot-state__img"
|
||||
:class="{ 'is-bounce': mode === 'loading' }"
|
||||
:src="mascotSrc"
|
||||
:src="appMascotUrl"
|
||||
alt=""
|
||||
decoding="async"
|
||||
draggable="false"
|
||||
@ -16,7 +16,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import mascotSrc from '@/assets/images/app-mascot.png'
|
||||
import { appMascotUrl } from '@/utils/brandLogo'
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
collectPaginateEntries,
|
||||
getPaginationMeta,
|
||||
} from './pagination';
|
||||
import { appMascotUrl } from '@/utils/brandLogo';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
@ -367,11 +368,11 @@
|
||||
:class="{ 'interface-tree--hierarchical': hierarchical }"
|
||||
>
|
||||
<div v-if="loading" class="loading-state">
|
||||
<img class="state-mascot is-bounce" src="/app-mascot.png" alt="" draggable="false" />
|
||||
<img class="state-mascot is-bounce" :src="appMascotUrl" alt="" draggable="false" />
|
||||
<p>{{ loadingText }}</p>
|
||||
</div>
|
||||
<div v-else-if="isTreeEmpty" class="empty-state">
|
||||
<img class="state-mascot" src="/app-mascot.png" alt="" draggable="false" />
|
||||
<img class="state-mascot" :src="appMascotUrl" alt="" draggable="false" />
|
||||
<p>{{ emptyText }}</p>
|
||||
</div>
|
||||
<a-tree
|
||||
|
||||
@ -283,7 +283,7 @@ import { openWindow, regexUrl } from '@/utils';
|
||||
import { MenuService, AuthService } from '@/api/rbac';
|
||||
import type { MenuTreeDto } from '@/api/rbac';
|
||||
import navLogoFallback from '@/assets/500x500.png';
|
||||
import { loadBrandLogoUrls } from '@/utils/brandLogo';
|
||||
import { applyDocumentFavicon, loadBrandLogoUrls } from '@/utils/brandLogo';
|
||||
import {
|
||||
initHiprintClientState,
|
||||
setHiprintClientEnabled,
|
||||
@ -317,6 +317,7 @@ const rbacUserStore = useRbacUserStore();
|
||||
const navLogoSrc = ref(navLogoFallback);
|
||||
void loadBrandLogoUrls().then((urls) => {
|
||||
navLogoSrc.value = urls.portal;
|
||||
applyDocumentFavicon(urls.favicon);
|
||||
});
|
||||
|
||||
const topMenuCon = ref<HTMLElement | null>(null);
|
||||
|
||||
@ -4254,11 +4254,20 @@ export default {
|
||||
'system.otherConfig.actions.brandLogo': 'Brand logo',
|
||||
'system.otherConfig.brandLogo.title': 'Brand logo',
|
||||
'system.otherConfig.brandLogo.tip':
|
||||
'Shown on the system top nav and official site header. Takes effect immediately; defaults are used when empty.',
|
||||
'Used for system top nav, official site header, browser tab icon, and boot mascot. Takes effect immediately; defaults when empty. Prefer square PNG.',
|
||||
'system.otherConfig.brandLogo.portal': 'System top nav',
|
||||
'system.otherConfig.brandLogo.site': 'Official site',
|
||||
'system.otherConfig.brandLogo.favicon': 'Browser tab',
|
||||
'system.otherConfig.brandLogo.mascot': 'Boot mascot',
|
||||
'system.otherConfig.brandLogo.size.portal': '128 / 256 PNG · top nav ~36px',
|
||||
'system.otherConfig.brandLogo.size.site': '128 / 256 PNG · site ~40px',
|
||||
'system.otherConfig.brandLogo.size.favicon': '32 / 64 PNG · browser tab',
|
||||
'system.otherConfig.brandLogo.size.mascot': '256 / 512 PNG · boot ~96px',
|
||||
'system.otherConfig.brandLogo.replace': 'Replace',
|
||||
'system.otherConfig.brandLogo.empty': 'Not uploaded',
|
||||
'system.otherConfig.brandLogo.clickUpload': 'Click or drag to upload',
|
||||
'system.otherConfig.brandLogo.clickReplace': 'Click to replace',
|
||||
'system.otherConfig.brandLogo.uploading': 'Uploading…',
|
||||
'system.otherConfig.brandLogo.uploadSuccess': 'Brand logo updated',
|
||||
'system.otherConfig.brandLogo.uploadFailed': 'Upload failed',
|
||||
'system.otherConfig.brandLogo.loadFailed': 'Failed to load brand logo',
|
||||
|
||||
@ -4266,11 +4266,20 @@ export default {
|
||||
'system.otherConfig.actions.brandLogo': '品牌 Logo',
|
||||
'system.otherConfig.brandLogo.title': '品牌 Logo',
|
||||
'system.otherConfig.brandLogo.tip':
|
||||
'用于系统顶栏与官网头部展示。更换后立即生效;未上传时前端使用默认图。',
|
||||
'用于系统顶栏、官网头部、浏览器标签与启动页吉祥物。更换后立即生效;未上传时前端使用默认图。建议上传正方形 PNG。',
|
||||
'system.otherConfig.brandLogo.portal': '系统顶栏',
|
||||
'system.otherConfig.brandLogo.site': '官网',
|
||||
'system.otherConfig.brandLogo.favicon': '网站标签',
|
||||
'system.otherConfig.brandLogo.mascot': '启动页吉祥物',
|
||||
'system.otherConfig.brandLogo.size.portal': '建议 128 / 256 PNG,顶栏约 36px',
|
||||
'system.otherConfig.brandLogo.size.site': '建议 128 / 256 PNG,官网约 40px',
|
||||
'system.otherConfig.brandLogo.size.favicon': '建议 32 / 64 PNG,浏览器标签',
|
||||
'system.otherConfig.brandLogo.size.mascot': '建议 256 / 512 PNG,启动页约 96px',
|
||||
'system.otherConfig.brandLogo.replace': '更换图片',
|
||||
'system.otherConfig.brandLogo.empty': '尚未上传',
|
||||
'system.otherConfig.brandLogo.clickUpload': '点击或拖拽上传',
|
||||
'system.otherConfig.brandLogo.clickReplace': '点击更换',
|
||||
'system.otherConfig.brandLogo.uploading': '上传中…',
|
||||
'system.otherConfig.brandLogo.uploadSuccess': '品牌 Logo 已更新',
|
||||
'system.otherConfig.brandLogo.uploadFailed': '上传失败',
|
||||
'system.otherConfig.brandLogo.loadFailed': '加载品牌 Logo 失败',
|
||||
|
||||
@ -23,6 +23,7 @@ import { applyDesktopPlatformClass, installWeChatH5HistoryGuard } from '@/utils/
|
||||
applyDesktopPlatformClass();
|
||||
import { installChunkReloadHandlers, reloadOnChunkLoadError } from '@/utils/chunkReload';
|
||||
import { initGa } from '@/utils/ga';
|
||||
import { bootstrapBrandAssets } from '@/utils/brandLogo';
|
||||
import { setAuthToken } from './api/rbac';
|
||||
import { useRbacUserStore } from '@/store/modules/rbac-user';
|
||||
import { applyRbacUserToUserStore } from '@/utils/enter-system';
|
||||
@ -137,6 +138,8 @@ async function bootstrap() {
|
||||
initAuthKeepAlive();
|
||||
// GA4:有 VITE_GA_MEASUREMENT_ID 才加载;地域/设备等自动采集
|
||||
initGa();
|
||||
// 浏览器标签 favicon(匿名可读;未配置仍用 /favicon.png)
|
||||
void bootstrapBrandAssets();
|
||||
|
||||
// 登录页勿预热 VXE/Element:体积大且会注入全局 CSS,和首屏抢带宽
|
||||
if (isHomePath(entryPath) && !isH5LikePath(entryPath) && !light) {
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { ref } from 'vue'
|
||||
import { getBrandLogo, type BrandLogoDto } from '@/api/system/otherConfig'
|
||||
import { resolveOmsAssetUrl, unwrapData } from '@/api/oms/common'
|
||||
import { resolveAdminApiPath } from '@/utils/adminApi'
|
||||
@ -6,14 +7,100 @@ import portalLogoFallback from '@/assets/500x500.png'
|
||||
export type BrandLogoUrls = {
|
||||
portal: string
|
||||
site: string
|
||||
favicon: string
|
||||
mascot: string
|
||||
}
|
||||
|
||||
const SITE_LOGO_FALLBACK = '/site/img/logo1.png'
|
||||
const FAVICON_FALLBACK = '/favicon.png'
|
||||
export const MASCOT_FALLBACK = '/app-mascot.png'
|
||||
/** 启动页在 Vue 挂载前读取,须与 index.html 一致 */
|
||||
export const MASCOT_CACHE_KEY = 'oms_brand_mascot_url'
|
||||
|
||||
function readCachedMascotUrl(): string {
|
||||
if (typeof localStorage === 'undefined') return ''
|
||||
try {
|
||||
const raw = (localStorage.getItem(MASCOT_CACHE_KEY) || '').trim()
|
||||
if (!raw) return ''
|
||||
if (/^https?:\/\//i.test(raw) || raw.startsWith('/') || raw.startsWith('data:')) {
|
||||
return raw
|
||||
}
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
function mapBrandLogoDto(data?: BrandLogoDto | null): BrandLogoUrls {
|
||||
return {
|
||||
portal: resolveOmsAssetUrl(data?.portalUrl) || portalLogoFallback,
|
||||
site: resolveOmsAssetUrl(data?.siteUrl) || SITE_LOGO_FALLBACK,
|
||||
favicon: resolveOmsAssetUrl(data?.faviconUrl) || FAVICON_FALLBACK,
|
||||
mascot: resolveOmsAssetUrl(data?.mascotUrl) || MASCOT_FALLBACK,
|
||||
}
|
||||
}
|
||||
|
||||
/** 空态 / 启动页吉祥物(可被配置覆盖) */
|
||||
export const appMascotUrl = ref(readCachedMascotUrl() || MASCOT_FALLBACK)
|
||||
|
||||
function setMascotCssVar(resolved: string) {
|
||||
if (typeof document === 'undefined') return
|
||||
try {
|
||||
const safe = resolved.replace(/\\/g, '\\\\').replace(/"/g, '\\"')
|
||||
document.documentElement.style.setProperty('--app-mascot-bg', `url("${safe}")`)
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof document !== 'undefined') {
|
||||
const initial = appMascotUrl.value
|
||||
if (initial && initial !== MASCOT_FALLBACK) {
|
||||
setMascotCssVar(initial.split('?')[0] || initial)
|
||||
}
|
||||
}
|
||||
|
||||
/** 更新浏览器标签 favicon(带缓存戳) */
|
||||
export function applyDocumentFavicon(url?: string | null) {
|
||||
if (typeof document === 'undefined') return
|
||||
const raw = String(url || '').trim() || FAVICON_FALLBACK
|
||||
const href = raw.includes('?') ? raw : `${raw}?_t=${Date.now()}`
|
||||
let link = document.querySelector<HTMLLinkElement>('link[rel="icon"]')
|
||||
if (!link) {
|
||||
link = document.createElement('link')
|
||||
link.rel = 'icon'
|
||||
document.head.appendChild(link)
|
||||
}
|
||||
link.type = 'image/png'
|
||||
link.href = href
|
||||
}
|
||||
|
||||
/** 应用启动页 / 空态吉祥物,并写入 localStorage 供下次冷启动 */
|
||||
export function applyAppMascot(url?: string | null) {
|
||||
if (typeof document === 'undefined') return
|
||||
const resolved = resolveOmsAssetUrl(url) || MASCOT_FALLBACK
|
||||
const display =
|
||||
resolved === MASCOT_FALLBACK || resolved.includes('?')
|
||||
? resolved
|
||||
: `${resolved}?_t=${Date.now()}`
|
||||
|
||||
appMascotUrl.value = display
|
||||
|
||||
try {
|
||||
if (resolved === MASCOT_FALLBACK) {
|
||||
localStorage.removeItem(MASCOT_CACHE_KEY)
|
||||
} else {
|
||||
localStorage.setItem(MASCOT_CACHE_KEY, resolved)
|
||||
}
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
|
||||
setMascotCssVar(resolved)
|
||||
|
||||
const bootImg = document.querySelector<HTMLImageElement>('#app-boot .boot-logo')
|
||||
if (bootImg) {
|
||||
bootImg.src = display
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,6 +113,8 @@ export async function loadBrandLogoUrls(): Promise<BrandLogoUrls> {
|
||||
return {
|
||||
portal: portalLogoFallback,
|
||||
site: SITE_LOGO_FALLBACK,
|
||||
favicon: FAVICON_FALLBACK,
|
||||
mascot: readCachedMascotUrl() || MASCOT_FALLBACK,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -46,6 +135,24 @@ export async function fetchBrandLogoUrlsPublic(): Promise<BrandLogoUrls> {
|
||||
return {
|
||||
portal: portalLogoFallback,
|
||||
site: SITE_LOGO_FALLBACK,
|
||||
favicon: FAVICON_FALLBACK,
|
||||
mascot: readCachedMascotUrl() || MASCOT_FALLBACK,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 启动时应用配置的 favicon + 吉祥物(匿名可读) */
|
||||
export async function bootstrapBrandAssets() {
|
||||
const cached = readCachedMascotUrl()
|
||||
if (cached) {
|
||||
applyAppMascot(cached)
|
||||
}
|
||||
const urls = await fetchBrandLogoUrlsPublic()
|
||||
applyDocumentFavicon(urls.favicon)
|
||||
applyAppMascot(urls.mascot)
|
||||
}
|
||||
|
||||
/** @deprecated 使用 bootstrapBrandAssets */
|
||||
export async function bootstrapBrandFavicon() {
|
||||
await bootstrapBrandAssets()
|
||||
}
|
||||
|
||||
@ -135,7 +135,7 @@
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
margin: 0 auto 10px;
|
||||
background: url('/app-mascot.png') center / contain no-repeat;
|
||||
background: var(--app-mascot-bg, url('/app-mascot.png')) center / contain no-repeat;
|
||||
filter: grayscale(1) brightness(1.08) contrast(0.92);
|
||||
opacity: 0.78;
|
||||
}
|
||||
|
||||
@ -264,7 +264,7 @@
|
||||
>
|
||||
<img
|
||||
class="h5-empty__mascot"
|
||||
src="/app-mascot.png"
|
||||
:src="appMascotUrl"
|
||||
alt=""
|
||||
decoding="async"
|
||||
draggable="false"
|
||||
@ -529,7 +529,7 @@
|
||||
<div v-else-if="isLoggedIn" class="h5-empty h5-price-empty">
|
||||
<img
|
||||
class="h5-empty__mascot"
|
||||
src="/app-mascot.png"
|
||||
:src="appMascotUrl"
|
||||
alt=""
|
||||
decoding="async"
|
||||
draggable="false"
|
||||
@ -732,6 +732,7 @@ import {
|
||||
} from '@/api/order';
|
||||
import { getSalesProductDetail } from '@/api/channel/salesProduct';
|
||||
import { h5Navigate } from '@/utils/device';
|
||||
import { appMascotUrl } from '@/utils/brandLogo';
|
||||
import { isLogin } from '@/utils/auth';
|
||||
import { checkCustomerContactRequired } from '@/utils/customerContactGate';
|
||||
import { ensureH5Login } from '../composables/useH5LoginGate';
|
||||
|
||||
@ -17,6 +17,7 @@ import {
|
||||
updateCustoms9610,
|
||||
} from '@/api/order/customs9610'
|
||||
import { $baseMessage } from '@/utils'
|
||||
import { appMascotUrl } from '@/utils/brandLogo'
|
||||
import { hasPermission } from '@/utils/rbac-permission'
|
||||
import { formatDateTime, normalizeListRow, pickField } from '@/utils/warehouseListMapper'
|
||||
import { renderWarehouseActionBtn, wrapWarehouseActions } from '@/utils/warehouseActionRenderer'
|
||||
@ -769,7 +770,7 @@ onMounted(() => {
|
||||
|
||||
<div ref="tableContainerRef" class="list-wrap">
|
||||
<div v-if="!listLoading && totalCount === 0" class="list-empty-hint">
|
||||
<img class="list-empty-hint__mascot" src="/app-mascot.png" alt="" draggable="false" />
|
||||
<img class="list-empty-hint__mascot" :src="appMascotUrl" alt="" draggable="false" />
|
||||
<span>{{ t('order.customs9610.empty.hint') }}</span>
|
||||
</div>
|
||||
<a-spin :loading="listLoading" class="table-spin">
|
||||
|
||||
@ -117,7 +117,7 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { fetchBrandLogoUrlsPublic } from '@/utils/brandLogo';
|
||||
import { applyDocumentFavicon, fetchBrandLogoUrlsPublic } from '@/utils/brandLogo';
|
||||
import { useUserStore } from '@/store';
|
||||
import { useRbacUserStore } from '@/store/modules/rbac-user';
|
||||
import { applyRbacUserToUserStore } from '@/utils/enter-system';
|
||||
@ -154,6 +154,7 @@
|
||||
const siteLogoSrc = ref('/site/img/logo1.png');
|
||||
void fetchBrandLogoUrlsPublic().then((urls) => {
|
||||
siteLogoSrc.value = urls.site;
|
||||
applyDocumentFavicon(urls.favicon);
|
||||
});
|
||||
|
||||
function onLoginClick(e: MouseEvent) {
|
||||
|
||||
@ -508,7 +508,7 @@
|
||||
v-model:visible="brandLogoVisible"
|
||||
:title="t('system.otherConfig.brandLogo.title')"
|
||||
:footer="false"
|
||||
width="640px"
|
||||
width="720px"
|
||||
:mask-closable="false"
|
||||
unmount-on-close
|
||||
>
|
||||
@ -518,37 +518,51 @@
|
||||
<div v-if="brandLogoLoading" class="payment-qr-loading">
|
||||
<a-spin />
|
||||
</div>
|
||||
<div v-else class="payment-qr-grid">
|
||||
<div v-else class="brand-logo-grid">
|
||||
<div
|
||||
v-for="item in brandLogoCards"
|
||||
:key="item.channel"
|
||||
class="payment-qr-card"
|
||||
class="brand-logo-card"
|
||||
>
|
||||
<div class="payment-qr-card__head">
|
||||
<span class="payment-qr-card__title">{{ item.title }}</span>
|
||||
<a-upload
|
||||
:show-file-list="false"
|
||||
accept="image/png,image/jpeg,image/jpg,image/webp,image/gif,image/bmp"
|
||||
:disabled="item.uploading"
|
||||
:custom-request="(option) => handleBrandLogoUpload(item.channel, option)"
|
||||
<div class="brand-logo-card__meta">
|
||||
<span class="brand-logo-card__title">{{ item.title }}</span>
|
||||
<span class="brand-logo-card__size">{{ item.sizeHint }}</span>
|
||||
</div>
|
||||
<a-upload
|
||||
class="brand-logo-card__upload"
|
||||
draggable
|
||||
:show-file-list="false"
|
||||
accept="image/png,image/jpeg,image/jpg,image/webp,image/gif,image/bmp"
|
||||
:disabled="item.uploading"
|
||||
:custom-request="(option) => handleBrandLogoUpload(item.channel, option)"
|
||||
>
|
||||
<div
|
||||
class="brand-logo-card__zone"
|
||||
:class="{
|
||||
'is-filled': !!item.url,
|
||||
'is-uploading': item.uploading,
|
||||
}"
|
||||
>
|
||||
<a-button size="small" :loading="item.uploading">
|
||||
{{ t('system.otherConfig.brandLogo.replace') }}
|
||||
</a-button>
|
||||
</a-upload>
|
||||
</div>
|
||||
<div class="payment-qr-card__preview">
|
||||
<a-image
|
||||
v-if="item.url"
|
||||
:src="item.url"
|
||||
:preview="true"
|
||||
width="200"
|
||||
fit="contain"
|
||||
/>
|
||||
<div v-else class="payment-qr-card__empty">
|
||||
{{ t('system.otherConfig.brandLogo.empty') }}
|
||||
<template v-if="item.uploading">
|
||||
<a-spin />
|
||||
<span class="brand-logo-card__hint">
|
||||
{{ t('system.otherConfig.brandLogo.uploading') }}
|
||||
</span>
|
||||
</template>
|
||||
<template v-else-if="item.url">
|
||||
<img class="brand-logo-card__img" :src="item.url" alt="" />
|
||||
<div class="brand-logo-card__mask">
|
||||
{{ t('system.otherConfig.brandLogo.clickReplace') }}
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<span class="brand-logo-card__plus">+</span>
|
||||
<span class="brand-logo-card__hint">
|
||||
{{ t('system.otherConfig.brandLogo.clickUpload') }}
|
||||
</span>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</a-upload>
|
||||
</div>
|
||||
</div>
|
||||
</a-modal>
|
||||
@ -579,6 +593,7 @@ import {
|
||||
type PaymentReceiveQrChannel,
|
||||
type SystemOtherConfigDto,
|
||||
} from '@/api/system/otherConfig'
|
||||
import { applyAppMascot, applyDocumentFavicon } from '@/utils/brandLogo'
|
||||
import {
|
||||
getWechatOrderNotifyTemplates,
|
||||
saveWechatOrderNotifyTemplate,
|
||||
@ -1084,33 +1099,62 @@ const brandLogoLoading = ref(false)
|
||||
const brandLogoUrls = reactive({
|
||||
portal: '',
|
||||
site: '',
|
||||
favicon: '',
|
||||
mascot: '',
|
||||
})
|
||||
const brandLogoUploading = reactive({
|
||||
portal: false,
|
||||
site: false,
|
||||
favicon: false,
|
||||
mascot: false,
|
||||
})
|
||||
|
||||
const brandLogoCards = computed(() => [
|
||||
{
|
||||
channel: 'portal' as BrandLogoChannel,
|
||||
title: t('system.otherConfig.brandLogo.portal'),
|
||||
sizeHint: t('system.otherConfig.brandLogo.size.portal'),
|
||||
url: brandLogoUrls.portal,
|
||||
uploading: brandLogoUploading.portal,
|
||||
},
|
||||
{
|
||||
channel: 'site' as BrandLogoChannel,
|
||||
title: t('system.otherConfig.brandLogo.site'),
|
||||
sizeHint: t('system.otherConfig.brandLogo.size.site'),
|
||||
url: brandLogoUrls.site,
|
||||
uploading: brandLogoUploading.site,
|
||||
},
|
||||
{
|
||||
channel: 'favicon' as BrandLogoChannel,
|
||||
title: t('system.otherConfig.brandLogo.favicon'),
|
||||
sizeHint: t('system.otherConfig.brandLogo.size.favicon'),
|
||||
url: brandLogoUrls.favicon,
|
||||
uploading: brandLogoUploading.favicon,
|
||||
},
|
||||
{
|
||||
channel: 'mascot' as BrandLogoChannel,
|
||||
title: t('system.otherConfig.brandLogo.mascot'),
|
||||
sizeHint: t('system.otherConfig.brandLogo.size.mascot'),
|
||||
url: brandLogoUrls.mascot,
|
||||
uploading: brandLogoUploading.mascot,
|
||||
},
|
||||
])
|
||||
|
||||
function applyBrandLogoDto(data?: { portalUrl?: string; siteUrl?: string } | null) {
|
||||
function applyBrandLogoDto(data?: {
|
||||
portalUrl?: string
|
||||
siteUrl?: string
|
||||
faviconUrl?: string
|
||||
mascotUrl?: string
|
||||
} | null) {
|
||||
const stamp = Date.now()
|
||||
const portal = resolveOmsAssetUrl(data?.portalUrl)
|
||||
const site = resolveOmsAssetUrl(data?.siteUrl)
|
||||
brandLogoUrls.portal = portal ? `${portal}${portal.includes('?') ? '&' : '?'}_t=${stamp}` : ''
|
||||
brandLogoUrls.site = site ? `${site}${site.includes('?') ? '&' : '?'}_t=${stamp}` : ''
|
||||
const stampUrl = (raw?: string) => {
|
||||
const url = resolveOmsAssetUrl(raw)
|
||||
return url ? `${url}${url.includes('?') ? '&' : '?'}_t=${stamp}` : ''
|
||||
}
|
||||
brandLogoUrls.portal = stampUrl(data?.portalUrl)
|
||||
brandLogoUrls.site = stampUrl(data?.siteUrl)
|
||||
brandLogoUrls.favicon = stampUrl(data?.faviconUrl)
|
||||
brandLogoUrls.mascot = stampUrl(data?.mascotUrl)
|
||||
}
|
||||
|
||||
async function loadBrandLogo() {
|
||||
@ -1242,6 +1286,12 @@ async function handleBrandLogoUpload(channel: BrandLogoChannel, option: any) {
|
||||
try {
|
||||
const data = await uploadBrandLogo(channel, file)
|
||||
applyBrandLogoDto(data)
|
||||
if (channel === 'favicon' || data?.faviconUrl) {
|
||||
applyDocumentFavicon(brandLogoUrls.favicon || data?.faviconUrl)
|
||||
}
|
||||
if (channel === 'mascot' || data?.mascotUrl) {
|
||||
applyAppMascot(resolveOmsAssetUrl(data?.mascotUrl) || brandLogoUrls.mascot)
|
||||
}
|
||||
option?.onSuccess?.(data)
|
||||
Message.success(t('system.otherConfig.brandLogo.uploadSuccess'))
|
||||
} catch (e: any) {
|
||||
@ -1777,7 +1827,7 @@ onMounted(() => {
|
||||
|
||||
.payment-qr-card__head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
}
|
||||
@ -1802,8 +1852,136 @@ onMounted(() => {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.payment-qr-grid {
|
||||
.brand-logo-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.brand-logo-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
min-width: 0;
|
||||
padding: 16px;
|
||||
border: 1px solid var(--color-border-2);
|
||||
border-radius: 10px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.brand-logo-card__meta {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.brand-logo-card__title {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--color-text-1);
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.brand-logo-card__size {
|
||||
font-size: 12px;
|
||||
line-height: 1.45;
|
||||
color: var(--color-text-3);
|
||||
}
|
||||
|
||||
.brand-logo-card__upload {
|
||||
width: 100%;
|
||||
flex: 1;
|
||||
|
||||
:deep(.arco-upload),
|
||||
:deep(.arco-upload-trigger),
|
||||
:deep(.arco-upload-list) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
:deep(.arco-upload-drag) {
|
||||
width: 100%;
|
||||
padding: 0;
|
||||
border: none;
|
||||
background: transparent;
|
||||
}
|
||||
}
|
||||
|
||||
.brand-logo-card__zone {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
min-height: 200px;
|
||||
padding: 20px;
|
||||
border: 1px dashed var(--color-border-3, #c9cdd4);
|
||||
border-radius: 8px;
|
||||
background: var(--color-fill-1, #f7f8fa);
|
||||
cursor: pointer;
|
||||
overflow: hidden;
|
||||
transition:
|
||||
border-color 0.15s ease,
|
||||
background-color 0.15s ease;
|
||||
|
||||
&:hover:not(.is-uploading) {
|
||||
border-color: var(--app-primary-color, #1d7281);
|
||||
background: color-mix(in srgb, var(--app-primary-color, #1d7281) 6%, #fff);
|
||||
}
|
||||
|
||||
&.is-filled {
|
||||
border-style: solid;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
&.is-uploading {
|
||||
cursor: wait;
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
||||
.brand-logo-card__img {
|
||||
max-width: 100%;
|
||||
max-height: 148px;
|
||||
object-fit: contain;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.brand-logo-card__mask {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 8px;
|
||||
background: rgba(0, 0, 0, 0.45);
|
||||
color: #fff;
|
||||
font-size: 13px;
|
||||
opacity: 0;
|
||||
transition: opacity 0.15s ease;
|
||||
}
|
||||
|
||||
.brand-logo-card__zone.is-filled:hover .brand-logo-card__mask {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.brand-logo-card__plus {
|
||||
font-size: 28px;
|
||||
line-height: 1;
|
||||
font-weight: 300;
|
||||
color: var(--color-text-3);
|
||||
}
|
||||
|
||||
.brand-logo-card__hint {
|
||||
font-size: 12px;
|
||||
color: var(--color-text-3);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.payment-qr-grid,
|
||||
.brand-logo-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user