npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-web-image-edit

v1.1.6

Published

web端图片编辑插件(Vue3版)

Downloads

27

Readme

vue-web-image-edit

web端图片编辑(Vue3版),本插件仅支持Vue3

插件安装

yarn add vue-web-image-edit
# or
npm install vue-web-image-edit --save

插件使用

由于插件使用Vue3编写,因此它只能在Vue3项目中运行

  • 在项目的入口文件main.ts/main.js中加入下述代码
// 导入截屏插件
import screenWindow from "vue-web-image-edit";
const app = createApp(App);
// 使用截屏插件
app.use(screenWindow, { themeColor: '#1f1f1f', headColor: '#1f1f1f' })
  • 在你的需要使用的业务代码中,添加下述代码
<template>
  <!--截图组件-->
  <screen-window
    v-if="imageEditStatus"
    :imageList="imageList"
    @edit-img-list="editImgList"
    @destroy-component="destroyComponent"
    @get-img-data="getImgData">
  </screen-window>
</template>

<script lang="ts">

export default defineComponent({
  setup(props, context) {
    // 控制组件显示状态
    const imageEditStatus = ref<boolean>(false);
    // 图片信息
    const imageList = ref<string[]>([]);
    // 编辑现有图片数据
    const editImgList = (imgArr: any) => {
        imageList.value = imgArr;
    }
    // 销毁组件函数
    const destroyComponent = function(status: boolean) {
      imageEditStatus.value = status;
    }
    // 获取裁剪图片、绘图图片信息
    const getImgData = function(data: { type: string|undefined; base64: string|undefined; }) {
      // imageUrl.value = data.base64
      // if(data.base64 && data.type == 'save') {
      //   imageList.value.push(data.base64)
      //   imageEditStatus.value = false;
      // }
      console.log("图片编辑弹框传递的图片信息", data.base64);
    }
    
    return {
      imageList,
      imageEditStatus,
      editImgList,
      destroyComponent,
      getImgData
    }
  }
})
</script>

参数说明

如示例代码所示,在template中直接使用screen-window插件,绑定组件需要的事件处理函数即可。

组件中属性的意义

  • imageEditStatus 用于控制组件是否出现在dom中
  • imageList 用于存储编辑的图片信息 例如:imageList.value = [require('@/assets/image/person.png')]
  • @destroy-component 用于接收图片编辑后传递的销毁消息,需要在对应的函数中销毁编辑弹框
  • @edit-img-list 用于接收图片编辑器中删除的imageList数据,保持数据一致
  • @get-image-data 用于接收图片编辑后传递的base64图片信息,在确认截图(type: "shot")和保存(type: "save“)绘制图片事件后触发

可选参数

  • themeColor 设置弹框body底色
  • headColor 设置弹框head底色