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

@jkyu/monet-draw-vue

v1.5.0

Published

莫奈大屏渲染

Downloads

3

Readme

Monet-SDK(莫奈大屏渲染)

概述

  Monet-SDK是一种微服务低代码解决方案,也可以理解为Iframe的替代方案,可快速将莫奈大屏集成到任何React、Vue工程中,并提供了灵活易用的钩子函数,来满足与莫奈大屏的各种交互场景

React [传送门](https://www.npmjs.com/package/@jkyu/monet-draw-react)

如何使用Monet-SDK

1. 安装Monet-SDK

npm install @jkyu/monet-draw-vue

2. 修改webpack配置

复制资源,配置别名,开启HTTPS

const CopyPlugin = require('copy-webpack-plugin');
const path = require('path');
const draw = 'node_modules/@jkyu/monet-draw-vue/build';

const target = 'http://uc-dev.jdcityos.com';

module.exports = {
  configureWebpack: (config) => {
    config.plugins.push(
      new CopyPlugin(
        [
          {
            from: path.join(draw, 'static'),
            to: 'static'
          }
        ],
      )
    );
  },
  devServer: {
    port: 8600,
    // 配置代理
    proxy: {
      '/api': {
        target,
        ws: true,
        changeOrigin: true,
        secure: false,
        headers: {
          Host: '',
          Connection: 'keep-alive'
        },
        pathRewrite: {
          '^/api': '/api'
        }
      },
      '/geojson': {
        target,
        secure: false,
        changeOrigin: true,
        headers: {
          Host: '',
          Connection: 'keep-alive'
        },
        pathRewrite: {
          '^/geojson': '/geojson'
        }
      }
    }
  }
};

3. 引用样式

<head>
    ...
    <link
      rel="stylesheet"
      type="text/css"
      href="<%= BASE_URL %>static/monet-sdk.css"
    />
    ...
</head>

4. 使用Monet-SDK

globalOption({
  // 配置微服务地址,用于解析大屏信息
  // 默认为:https://imonet.jdcloud.com
  serverURL: "https://imonet.jdcloud.com"
})

<template>
  <div className="App">
    <div id="leftDiv" />
  </div>
</template>
<script>
import { onMounted, defineComponent } from 'vue';
import { MonetRender } from '@jkyu/monet-draw-vue';
export default defineComponent({
  name: 'App',
  setup () {
    let leftEvent = null;
    onMounted(() => {
      const leftRender = new MonetRender({ 
        bigScreenURL: '',     // 大屏发布地址
        width:"650px",        // 高度
        height:"300px",       // 宽度
        container: 'leftDiv', // 容器ID
        token:'234234...'     // 授权码
      });
      leftRender.initDataPool = () => ({});               // 初始化数据池
      leftRender.beforeScreenRender = (screenInfo) => {}; // 大屏信息渲染前
      leftRender.beforeComRender = (components) => {};    // 组件信息渲染前
      leftRender.watchDataPool = (dataPool) => {};        // 监听数据池
      // 组件渲染完成
      leftRender.onload = (monetEvent) => {
        leftEvent = monetEvent;
        // 根据组件ID,修改样式信息
        monetEvent.setComConfig(3289, (config) => {
           config.style = {
              backgroundColor: 'rgba(224,72,175,0.5)',
              font: { size: 32, color: '#000000' }
           };
           return config;
        });
      };
    })
    // 设置变量
    const setDataPool = (key,value)=>{
      leftEvent.setDataPool(key, value);
    }
    // 根据组件ID,修改系列信息
    const setComSeries = ()=>{
      leftEvent.setComSeries(3291, (series) => {
        series[0].barStyle.color = '#6DC8EC';
        return series;
      });
    }
    return {
      setDataPool,
      setComSeries
    }
  }
})
</script>
<style>
.App {
  height: 100vh;
  display: flex;
}
</style>

一些案例模板

|demo|描述| |---|---| |msdk-wp4| 基于React CRA创建的Webpack4工程,集成Monet-SDK的一个示例模板| |msdk-wp5| 基于React Webpack5工程,集成Monet-SDK的一个示例模板| |msdk-vue| 基于Monet-SDK集成莫奈大屏,React to Vue示例工程|