fix:图片访问

fix:权限修改
This commit is contained in:
dzc committed 2026-10-29 14:25:46 +08:00
1 parent 6d267bcfc5
commit 653b4688cd
80 files changed
+232 -265

No files matched your search

@@ -169,7 +169,7 @@ defineExpose({
<template>
<view class="layout">
<image class="layout_bg" v-if="props.bg" :src="props.bg" mode="aspectFill" />
<image class="layout_bg" v-if="props.bg" :src="$fileUrl(props.bg)" mode="aspectFill" @error="$fileRetry(props.bg)" />
<view class="layout_header">
<base-safe-height :bgColor="props.navBgColor" v-if="state.visble.topSafe" type="top" />
<base-nav v-if="state.visble.topNav" :titleColor="props.navBgTitleColor" :bgColor="props.navBgColor"
+1 -1
View File
@@ -3,7 +3,7 @@
<view v-for="item in nodeData" :key="item.id">
<view class="tree-item" :style="item.id == selectedNodeId ? { borderColor: '#1879ff' } : { color: '#000' }"
@click.stop="toCurrentNode(item)">
<image class="tree-item-icon" :src="filePath(item.picUrl)" />
<image class="tree-item-icon" :src="$fileUrl(filePath(item.picUrl))" @error="$fileRetry(filePath(item.picUrl))" />
<text>{{ item.name }}</text>
</view>
+1 -1
View File
@@ -3,7 +3,7 @@
<view class="keyboard-panel" :class="{ 'keyboard-panel--open': show }">
<view class="keyboard-toggle" @tap.stop="toggleShow">
<image class="keyboard-toggle__icon"
:src="show ? '/static/page/fold.svg' : '/static/page/unfold.svg'" />
:src="$fileUrl(show ? '/static/page/fold.svg' : '/static/page/unfold.svg')" @error="$fileRetry(show ? '/static/page/fold.svg' : '/static/page/unfold.svg')" />
</view>
<view v-show="show" class="keyboard-content">
<view class="flex mb-20rpx" v-for="(row, rowIndex) in keyboardLayout" :key="rowIndex">
@@ -36,7 +36,7 @@
},
{ 'img-error': !item2[data.imageKey] },
]"
:src="item2[data.imageKey]"
:src="$fileUrl(item2[data.imageKey])"
mode="widthFix"
@load="imgLoad(item2, index + 1)"
@error="imgError(item2, index + 1)"
+2 -1
View File
@@ -1,7 +1,8 @@
import { previewFiles } from '@/sheep/utils/file-access'
export const usePreviewImage = (str: string | undefined) => {
if (str == undefined) return
let urlList = str.split(",")
uni.previewImage({
previewFiles({
urls: urlList,
})
}
+10 -49
View File
@@ -1,50 +1,11 @@
import { isDevEnv } from "./app"
export { fileUrl as filePath, originalFileUrl, stripFileHtml, downloadFile, previewFiles } from './file-access'
import { fileHtml } from './file-access'
const normalizeBase = (base: string | undefined) => {
if (!base) return ""
return base.endsWith("/") ? base.slice(0, -1) : base
}
const ensureLeadingSlash = (url: string) => {
if (!url) return ""
return url.startsWith("/") ? url : `/${url}`
}
export const filePath = (path?: string | null) => {
const rawPath = (path || "").trim()
if (!rawPath) return ""
if (/^https?:\/\//i.test(rawPath)) return rawPath
const devBase = normalizeBase(import.meta.env.VITE_IMAGE_DEV_PATH || import.meta.env.VITE_APP_DEV_SERVICE)
const prodBase = normalizeBase(import.meta.env.VITE_APP_PROD_IMAGE)
const base = isDevEnv() ? devBase : prodBase
if (!base) return rawPath
return `${base}${ensureLeadingSlash(rawPath)}`
}
export const parseHtml = (html: string) => {
const origin = "https://stgl.pj.gov.cn"
return html.replace(/<img\b[^>]*>/gi, (imgTag) => {
let next = imgTag
next = next.replace(/\bsrc\s*=\s*(['"])(.*?)\1/i, (_m, quote: string, src: string) => {
let resolved = src
if (resolved?.startsWith("/api")) resolved = `${origin}${resolved}`
if (resolved?.startsWith("//")) resolved = `https:${resolved}`
return `src=${quote}${resolved}${quote}`
})
const styleMatch = next.match(/\bstyle\s*=\s*(['"])([\s\S]*?)\1/i)
const required = "max-width: 100%; height: auto; display: block;"
if (styleMatch) {
const quote = styleMatch[1]
const styleValue = styleMatch[2] ?? ""
if (styleValue.includes("max-width") || styleValue.includes("width")) return next
const merged = styleValue.trim().length ? `${styleValue.replace(/;?\s*$/, "; ")}${required}` : required
return next.replace(/\bstyle\s*=\s*(['"])([\s\S]*?)\1/i, `style=${quote}${merged}${quote}`)
}
return next.replace(/<img\b/i, `<img style="${required}"`)
})
}
/** Preserve existing responsive article images while signing resource attributes. */
export const parseHtml = (html: string) => fileHtml(html || '').replace(/<img\b[^>]*>/gi, img => {
const required = 'max-width: 100%; height: auto; display: block;'
const style = img.match(/\bstyle\s*=\s*(['"])([\s\S]*?)\1/i)
if (!style) return img.replace(/<img\b/i, `<img style="${required}"`)
if (/(?:max-)?width\s*:/i.test(style[2])) return img
return img.replace(style[0], `style=${style[1]}${style[2].replace(/;?\s*$/, '; ')}${required}${style[1]}`)
})