Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
factory_front
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
qinjianhui
factory_front
Commits
24d145d2
Commit
24d145d2
authored
Aug 13, 2026
by
zhuzhequan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:修复md5图片不显示问题
parent
d2b3b13e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
1 deletions
+71
-1
src/components/ImageView.vue
+8
-1
src/utils/hooks/commonUtil.ts
+63
-0
No files found.
src/components/ImageView.vue
View file @
24d145d2
...
...
@@ -5,12 +5,13 @@
@
mouseover=
"(ev) => mouseoverImg(ev, src)"
@
mouseleave=
"mouseleaveImg"
>
<img
:src=
"
src
"
:style=
"imageStyle"
/>
<img
:src=
"
formatUrl
"
:style=
"imageStyle"
/>
</div>
</
template
>
<
script
setup
lang=
"ts"
>
import
useImagePreview
from
'@/utils/hooks/useImagePreview.'
import
{
computed
,
defineProps
}
from
'vue'
import
{
formatImgUrl
}
from
'@/utils/hooks/commonUtil.ts'
const
props
=
defineProps
({
src
:
{
type
:
String
,
...
...
@@ -31,6 +32,12 @@ const imageStyle = computed(() => {
height
:
props
.
height
,
}
})
const
formatUrl
=
computed
(()
=>
{
const
w
=
Number
(
props
.
width
.
replace
(
'px'
,
''
))
const
h
=
Number
(
props
.
height
.
replace
(
'px'
,
''
))
return
formatImgUrl
({
url
:
props
.
src
,
w
,
h
})
})
const
{
mouseoverImg
,
mouseleaveImg
}
=
useImagePreview
()
</
script
>
<
style
lang=
"scss"
scoped
>
...
...
src/utils/hooks/commonUtil.ts
View file @
24d145d2
import
{
md5
}
from
'js-md5'
export
type
AnyObject
=
{
[
propName
:
string
]:
string
|
number
|
boolean
|
undefined
|
unknown
}
...
...
@@ -145,3 +146,65 @@ export function checkUpdateParams(
}
return
params
}
/**
* 图片下载地址
* w=width&h=height&g=isgray&x=position_x&y=position_y&r=rotate&q=quality&f=format
* @param {*} url
* @param {Object} options
* @param {Number} options.w -width
* @param {Number} options.w -height
* @param {0 | 1} options.g -isgray 灰色
* @param {Number} options.x -position_x
* @param {Number} options.y -position_y
* @param {Number} options.r -rotate 旋转
* @param {Number} options.f - 格式
* @param {Number} options.q -quality 质量
* @param {'jpeg' | 'png' | 'gif' | 'jeg'} options.f -format
* @returns String
*/
interface
formatOption
{
url
:
string
w
?:
number
h
?:
number
others
?:
never
options
?:
never
}
// 图片地址格式化
export
function
formatImgUrl
(
option
:
formatOption
):
string
{
const
{
url
,
w
,
h
,
others
}
=
option
let
imagePath
=
''
let
query
=
''
if
(
w
)
{
query
+=
query
?
'&w='
:
'w='
+
Math
.
floor
(
w
);
}
if
(
h
)
{
query
+=
query
?
'&h='
:
'h='
+
Math
.
floor
(
h
);
}
if
(
others
){
Object
.
keys
(
others
).
forEach
(
key
=>
{
query
+=
`
${
query
?
'&'
:
''
}${
key
}
=
${
others
[
key
]}
`
;
});
}
const
zImgPath
=
`
${
location
.
origin
}${
location
.
host
.
indexOf
(
'test'
)
!==
-
1
||
location
.
protocol
==
'http:'
?
'/erpimg/'
:
''
}
`
if
(
url
.
startsWith
(
'http'
))
{
return
url
}
else
if
(
url
.
startsWith
(
'/'
))
{
return
window
.
location
+
url
}
else
{
if
(
'42f2b26039d7fd526b8a1d50bb329cbc'
===
md5
(
location
.
host
))
{
imagePath
=
zImgPath
+
'/erpimg/'
+
url
}
else
if
(
zImgPath
.
indexOf
(
'/erpimg'
)
!==
-
1
)
{
imagePath
=
zImgPath
+
url
}
else
{
imagePath
=
'https://image.jomalls.com/'
+
url
+
(
query
?
'?'
:
''
)
+
query
}
return
imagePath
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment