Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
飞
飞鹤小程序
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
FH
飞鹤小程序
Commits
965f1b83
Commit
965f1b83
authored
Nov 14, 2025
by
spc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed
parent
081fdb63
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
11 deletions
+14
-11
XingmaLabPosterPage.vue
components/xingmaLab/XingmaLabPosterPage.vue
+14
-11
No files found.
components/xingmaLab/XingmaLabPosterPage.vue
View file @
965f1b83
...
...
@@ -19,7 +19,7 @@
<!-- 图片区域 -->
<view
class=
"poster-image-wrapper"
>
<image
class=
"poster-image-bg"
:src=
"`$
{$baseUrl}homepage/Q3Res/xingmaLabPosterImgBg.png`"
<image
class=
"poster-image-bg"
:src=
"`$
{$baseUrl}homepage/Q3Res/xingmaLabPosterImgBg
2
.png`"
mode="aspectFit">
</image>
<image
v-if=
"imageUrl"
class=
"poster-image"
:src=
"imageUrl"
mode=
"aspectFit"
></image>
<!-- 文字内容 -->
...
...
@@ -525,25 +525,28 @@ const getImageInfo = (src) => {
})
}
// 计算自适应尺寸(保持宽高比,
类似 aspectFit
)
// 计算自适应尺寸(保持宽高比,
根据超出比例决定适配方向
)
const
calculateFitSize
=
(
imageWidth
,
imageHeight
,
containerWidth
,
containerHeight
)
=>
{
const
imageRatio
=
imageWidth
/
imageHeight
const
containerRatio
=
containerWidth
/
containerHeight
// 计算超出比例
const
widthOverflowRatio
=
(
imageWidth
-
containerWidth
)
/
containerWidth
const
heightOverflowRatio
=
(
imageHeight
-
containerHeight
)
/
containerHeight
let
drawWidth
,
drawHeight
,
drawX
,
drawY
if
(
imageRatio
>
containerRatio
)
{
// 图片更宽,以宽度为准
// 如果高度超出的比例大,则高度适配(固定高度,宽度自适应)
if
(
heightOverflowRatio
>
widthOverflowRatio
)
{
drawHeight
=
containerHeight
drawWidth
=
containerHeight
*
imageRatio
drawX
=
(
containerWidth
-
drawWidth
)
/
2
drawY
=
0
}
else
{
// 如果宽度超出的比例大,则宽度适配(固定宽度,高度自适应)
drawWidth
=
containerWidth
drawHeight
=
containerWidth
/
imageRatio
drawX
=
0
drawY
=
(
containerHeight
-
drawHeight
)
/
2
}
else
{
// 图片更高,以高度为准
drawWidth
=
containerHeight
*
imageRatio
drawHeight
=
containerHeight
drawX
=
(
containerWidth
-
drawWidth
)
/
2
drawY
=
0
}
return
{
drawWidth
,
drawHeight
,
drawX
,
drawY
}
...
...
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