Skip to content

Commit f637dad

Browse files
committed
fix: image not show in some cases
1 parent 4dd4827 commit f637dad

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

apps/app/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@
1212
"dependencies": {
1313
"@element-plus/icons-vue": ">=0.2.6",
1414
"@element-plus/nuxt": "1.1.1",
15-
"@popperjs/core": "npm:@sxzz/popperjs-es@^2.11.7",
1615
"@nuxtjs/i18n": "9.1.1",
1716
"@pinia/nuxt": "^0.9.0",
17+
"@popperjs/core": "npm:@sxzz/popperjs-es@^2.11.7",
1818
"@vueuse/core": "^12.2.0",
1919
"cheerio": "^1.0.0",
2020
"dayjs": "^1.11.13",
2121
"element-plus": ">=2",
2222
"highlight.js": "11.7.0",
23+
"js-base64": "^3.7.7",
2324
"lodash-unified": "^1.0.3",
2425
"nuxt": "^3.15.0",
2526
"pinia": "^2.3.0",

apps/app/plugins/libs/renderer/useStaticClientAssets.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99

1010
import { StrUtil } from "zhi-common"
11+
import { Base64 } from "js-base64"
1112
import { useProviderMode } from "~/composables/useProviderMode"
1213
import { useBaseUrl } from "~/plugins/libs/renderer/useClientBaseUrl"
1314

@@ -33,9 +34,13 @@ export const useStaticClientAssets = () => {
3334
const src = img.getAttribute("src") ?? ""
3435
if (src.includes("assets")) {
3536
if (providerMode) {
36-
// const apiBase = env.public.providerUrl
37-
// const imgUrl = [apiBase, "api/asset/", src].join("/")
38-
logger.info("providerMode is not local, skip addClientAssetsPrefix, use api as alternative")
37+
const apiBase = env.public.providerUrl
38+
// src base64加密
39+
const base64Url = Base64.encodeURI(src)
40+
const imgUrl = StrUtil.pathJoin(StrUtil.pathJoin(apiBase, "/api/asset/origin/base64/"), base64Url)
41+
img.setAttribute("src", imgUrl)
42+
img.setAttribute("data-src", imgUrl)
43+
logger.info("providerMode is not local, skip addClientAssetsPrefix, use api as alternative", imgUrl)
3944
} else {
4045
const baseUrl = getClientBaseUrl()
4146
const pubicAssetsFolder = `public/siyuan-blog/${pageId}`

pnpm-lock.yaml

+15-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)