Bläddra i källkod

fix(mobile-h5): serve legacy OA app icon SVGs from static

Most templates still use /oa-app-icons/*.svg from web-admin public; only ep: icons rendered. Copy assets and rewrite paths to /static/oa-app-icons so H5/miniprogram can load them.

Co-authored-by: Cursor <cursoragent@cursor.com>
zlwu 2 månader sedan
förälder
incheckning
8aab018558

+ 4 - 0
mobile-h5/scripts/check-oa-app-icons.js

@@ -39,6 +39,10 @@ import assert from 'node:assert/strict'
   assert.strictEqual(img.kind, 'image')
   assert.strictEqual(img.src, 'https://cdn.example/a.png')
 
+  const legacy = resolveOaAppIcon('/oa-app-icons/doc-orange.svg')
+  assert.strictEqual(legacy.kind, 'image')
+  assert.strictEqual(legacy.src, '/static/oa-app-icons/doc-orange.svg')
+
   const built = buildEpIconUrl('Wallet', '#fef3c7')
   assert.strictEqual(built, 'ep:Wallet|#fef3c7')
   const r = resolveOaAppIcon(built)

+ 8 - 0
mobile-h5/static/oa-app-icons/cart-rose.svg

@@ -0,0 +1,8 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 80 80" fill="none">
+  <rect width="80" height="80" rx="16" fill="#f43f5e"/>
+  <g fill="#fff">
+    <rect x="22" y="28" width="36" height="5" rx="2.5"/>
+    <rect x="22" y="37.5" width="36" height="5" rx="2.5"/>
+    <rect x="22" y="47" width="36" height="5" rx="2.5"/>
+  </g>
+</svg>

+ 8 - 0
mobile-h5/static/oa-app-icons/check-teal.svg

@@ -0,0 +1,8 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 80 80" fill="none">
+  <rect width="80" height="80" rx="16" fill="#14b8a6"/>
+  <g fill="#fff">
+    <rect x="22" y="28" width="36" height="5" rx="2.5"/>
+    <rect x="22" y="37.5" width="36" height="5" rx="2.5"/>
+    <rect x="22" y="47" width="36" height="5" rx="2.5"/>
+  </g>
+</svg>

+ 8 - 0
mobile-h5/static/oa-app-icons/clock-blue.svg

@@ -0,0 +1,8 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 80 80" fill="none">
+  <rect width="80" height="80" rx="16" fill="#3b82f6"/>
+  <g fill="#fff">
+    <rect x="22" y="28" width="36" height="5" rx="2.5"/>
+    <rect x="22" y="37.5" width="36" height="5" rx="2.5"/>
+    <rect x="22" y="47" width="36" height="5" rx="2.5"/>
+  </g>
+</svg>

+ 8 - 0
mobile-h5/static/oa-app-icons/doc-orange.svg

@@ -0,0 +1,8 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 80 80" fill="none">
+  <rect width="80" height="80" rx="16" fill="#f97316"/>
+  <g fill="#fff">
+    <rect x="22" y="28" width="36" height="5" rx="2.5"/>
+    <rect x="22" y="37.5" width="36" height="5" rx="2.5"/>
+    <rect x="22" y="47" width="36" height="5" rx="2.5"/>
+  </g>
+</svg>

+ 8 - 0
mobile-h5/static/oa-app-icons/leave-mint.svg

@@ -0,0 +1,8 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 80 80" fill="none">
+  <rect width="80" height="80" rx="16" fill="#10b981"/>
+  <g fill="#fff">
+    <rect x="22" y="28" width="36" height="5" rx="2.5"/>
+    <rect x="22" y="37.5" width="36" height="5" rx="2.5"/>
+    <rect x="22" y="47" width="36" height="5" rx="2.5"/>
+  </g>
+</svg>

+ 8 - 0
mobile-h5/static/oa-app-icons/mail-violet.svg

@@ -0,0 +1,8 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 80 80" fill="none">
+  <rect width="80" height="80" rx="16" fill="#8b5cf6"/>
+  <g fill="#fff">
+    <rect x="22" y="28" width="36" height="5" rx="2.5"/>
+    <rect x="22" y="37.5" width="36" height="5" rx="2.5"/>
+    <rect x="22" y="47" width="36" height="5" rx="2.5"/>
+  </g>
+</svg>

+ 8 - 0
mobile-h5/static/oa-app-icons/tag-cyan.svg

@@ -0,0 +1,8 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 80 80" fill="none">
+  <rect width="80" height="80" rx="16" fill="#06b6d4"/>
+  <g fill="#fff">
+    <rect x="22" y="28" width="36" height="5" rx="2.5"/>
+    <rect x="22" y="37.5" width="36" height="5" rx="2.5"/>
+    <rect x="22" y="47" width="36" height="5" rx="2.5"/>
+  </g>
+</svg>

+ 8 - 0
mobile-h5/static/oa-app-icons/yen-amber.svg

@@ -0,0 +1,8 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 80 80" fill="none">
+  <rect width="80" height="80" rx="16" fill="#f59e0b"/>
+  <g fill="#fff">
+    <rect x="22" y="28" width="36" height="5" rx="2.5"/>
+    <rect x="22" y="37.5" width="36" height="5" rx="2.5"/>
+    <rect x="22" y="47" width="36" height="5" rx="2.5"/>
+  </g>
+</svg>

+ 18 - 4
mobile-h5/utils/oa-app-icons.js

@@ -79,6 +79,23 @@ export function parseEpIconUrl(iconUrl) {
   return { icon, bg, fg: iconFgFromBg(bg) }
 }
 
+/**
+ * 旧版静态图标存 `/oa-app-icons/*.svg`(web-admin/public)。
+ * 小程序/H5 需走 `static/oa-app-icons/`,否则 5173 下 404。
+ */
+export function resolveOaAppIconImageSrc(iconUrl) {
+  const u = String(iconUrl || '').trim()
+  if (!u || isEpIconUrl(u)) return ''
+  if (/^https?:\/\//i.test(u)) return u
+  if (u.startsWith('/oa-app-icons/')) {
+    return '/static' + u
+  }
+  if (u.startsWith('/static/')) return u
+  if (u.startsWith('/')) return u
+  // MinIO 相对 key:由调用方或 config 拼完整 URL;此处原样返回
+  return u
+}
+
 export function resolveOaAppIcon(iconUrl) {
   const u = String(iconUrl || '').trim()
   if (!u) {
@@ -89,10 +106,7 @@ export function resolveOaAppIcon(iconUrl) {
     const p = parseEpIconUrl(u)
     return { kind: 'ep', icon: p.icon, bg: p.bg, fg: p.fg }
   }
-  if (/^https?:\/\//i.test(u) || u.startsWith('/')) {
-    return { kind: 'image', src: u }
-  }
-  return { kind: 'image', src: u }
+  return { kind: 'image', src: resolveOaAppIconImageSrc(u) }
 }
 
 const EP_ICON_SVG_INNER = {