
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
vue3-image-viewer
Advanced tools
Supply Chain Security
Vulnerability
Quality
Maintenance
License
npm i vue3-image-viewer
或者/or
yarn add vue3-image-viewer
import { Image } from 'vue3-image-viewer';
<template>
<div class="image">
<div class="item" v-for="(item, index) in images" :key="item.url">
<Image
width="270px"
height="300px"
:src="item.url"
preview
:images="images"
:initialIndex="index"
>
<template #footer>footer</template>
<template #loading>LOADING</template>
<template #error>ERROR</template>
</Image>
</div>
</div>
</template>
<script setup>
import { Image } from 'vue3-image-viewer'
import 'vue3-image-viewer/dist/style.css'
const images = [
{
title: 'title',
desc: 'desc',
url: 'http://iph.href.lu/800x540',
},
{
title: 'title',
desc: 'desc',
url: 'https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg',
},
{
title: 'title',
desc: 'desc',
url: 'https://fuss10.elemecdn.com/1/8e/aeffeb4de74e2fde4bd74fc7b4486jpeg.jpeg',
},
{
title: 'title',
desc: 'desc',
url: '',
},
];
</script>
<style lang="less" scoped>
.image {
display: flex;
flex-wrap: wrap;
gap: 20px;
justify-content: space-between;
width: 1200px;
margin: 0 auto;
}
</style>
<template>
<div class="viewer">
<div class="viewer-wrap">
<!-- 如果传入了markList则不取images中的marks -->
<Viewer
ref="viewerRef"
:imageList="images"
navigation
toolbar
drawable
deleteable
:scaleMin="1"
@drawEnd="drawEnd"
@resize="onResize"
@delete="onDelete"
@switch="onSwitch"
:initialIndex="currentIndex"
>
<template #loading>LOADING</template>
<template #error>ERROR</template>
</Viewer>
<!-- 自定义 -->
<div class="tools">
<div @click="toolBtn('fit')">适应窗口</div>
<div @click="toolBtn('prev')">上一个</div>
<div @click="toolBtn('next')">下一个</div>
<div @click="toolBtn('reset')">重置</div>
</div>
</div>
<div class="preview">
<div class="item" v-for="(item, index) in current.marks" :key="index">
<Viewer :image="current" :mark="item" focus>
<template #loading>LOADING</template>
<template #error>ERROR</template>
</Viewer>
</div>
</div>
</div>
</template>
<script setup>
import { Viewer } from 'vue3-image-viewer'
import 'vue3-image-viewer/dist/style.css'
import { reactive, ref, computed, unref } from 'vue';
const images = reactive([
{
title: 'title',
desc: 'desc',
url: 'https://fuss10.elemecdn.com/1/34/19aa98b1fcb2781c4fba33d850549jpeg.jpeg',
thumbnail:
'https://fuss10.elemecdn.com/1/34/19aa98b1fcb2781c4fba33d850549jpeg.jpeg',
marks: [],
},
{
title: 'title',
desc: 'desc',
url: 'https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg',
thumbnail:
'https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg',
marks: [
{
width: 220,
height: 220,
left: 470,
top: 230,
},
],
},
{
title: 'title',
desc: 'desc',
url: 'https://fuss10.elemecdn.com/3/28/bbf893f792f03a54408b3b7a7ebf0jpeg.jpeg',
thumbnail:
'https://fuss10.elemecdn.com/3/28/bbf893f792f03a54408b3b7a7ebf0jpeg.jpeg',
marks: [
{
width: 80,
height: 40,
left: 320,
top: 220,
},
],
},
{
title: 'title',
desc: 'desc',
url: '',
thumbnail: '',
marks: [],
},
]);
const currentIndex = ref(1);
const current = computed(() => images[currentIndex.value]);
const viewerRef = ref(null);
function onSwitch(index) {
currentIndex.value = index;
}
function onResize({ target, detail }) {
const { left, top, width, height } = detail;
const mark = { ...target };
mark.left = left;
mark.top = top;
mark.width = width;
mark.height = height;
const idx = current.value.marks.indexOf(target);
if (idx > -1) {
current.value.marks.splice(idx, 1, mark);
}
}
function onDelete({ target }) {
const idx = current.value.marks.indexOf(target);
if (idx > -1) {
current.value.marks.splice(idx, 1);
}
}
function drawEnd(item) {
const { left, top, width, height } = item;
if (!current.value.marks) {
current.value.marks = [];
}
const newMark = {
id: current.value.marks.length + 1 + '',
left,
top,
width,
height,
};
current.value.marks.unshift(newMark);
}
function toolBtn(type) {
const viewer = unref(viewerRef);
if (!viewer) {
return;
}
if (type === 'fit') {
viewer.toggleFit();
}
if (type === 'next') {
viewer.next();
}
if (type === 'prev') {
viewer.prev();
}
if (type === 'reset') {
viewer.reset();
}
}
</script>
<style lang="less" scoped>
.viewer {
width: 1200px;
margin: 0 auto;
display: flex;
align-items: flex-start;
justify-content: center;
.viewer-wrap {
width: 1000px;
height: 600px;
.tools {
display: flex;
justify-content: center;
gap: 10px;
margin-top: 10px;
div {
border: 1px solid #ccc;
border-radius: 4px;
cursor: pointer;
padding: 0 5px;
font-size: 14px;
line-height: 22px;
}
}
}
.preview {
width: 200px;
margin-left: 20px;
height: 600px;
overflow-y: auto;
display: flex;
flex-direction: column;
gap: 10px;
.item {
width: 100%;
height: 150px;
}
}
}
</style>
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
base | 地址前缀 | string | "" |
src | 图片地址 | string | "" |
token | token 参数 | string | "" |
aspectRatio | 固定宽高比 | number | 0 |
fit | object-fit | string | "fill" |
lazy | 懒加载 | boolean | false |
hideOnClickModal | 点击遮罩关闭预览 | boolean | false |
initialIndex | 在预览数组中的位置 | number | 0 |
preview | 是否开启预览 | boolean | false |
images | 预览列表 | array | [] |
loop | 开启循环 | boolean | false |
preload | 预览预加载 | array or boolean | [0,2] |
width | 盒子宽度 | string | "" |
height | 盒子高度 | string | "" |
alt | alt | string | "" |
referrerPolicy | referrerPolicy | string | "" |
bgColor | 背景颜色 | string | "black" |
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
base | 地址前缀 | string | "" |
token | token 参数 | string | "" |
scaleMax | 最大缩放倍数 | number | 15 |
scaleMin | 最小缩放倍数 | number | 1 |
scaleStep | 缩放步进 | number | 1.1 |
initialScale | 初始缩放倍数 | number | 1 |
imageList | 图片列表 | array | [] |
markList | 标记框列表 | array | [] |
initialIndex | 初始展示图片下标 | number | 0 |
loop | 开启循环 | boolean | 0 |
navigation | 底部预览条 | boolean | false |
toolbar | 工具栏 | boolean | false |
keyboard | 开启快捷键 | array | ['A', 'D'] |
fit | object-fit | string | "contain" |
preload | 图片预加载 | array or boolean | [0,2] |
fixed | 禁止缩放 | boolean | false |
focus | 锁定标记框的展示模式 | boolean | false |
drawable | 是否开启标记功能 | boolean | false |
deleteable | 是否显示移除标记框的按钮 | boolean | false |
image | 单张图片 | object | null |
mark | 单个标记框 | object | null |
A
,下一项: D
,锁定标记框: Space
,取消框图锁定: Esc
FAQs
`npm i vue3-image-viewer` 或者/or `yarn add vue3-image-viewer`
The npm package vue3-image-viewer receives a total of 71 weekly downloads. As such, vue3-image-viewer popularity was classified as not popular.
We found that vue3-image-viewer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.