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

yg-portaljs-sdk

v1.0.16

Published

yg portal jssdk umd

Downloads

23

Readme

Yg Portal SDK

安装

npm install yg-portaljs-sdk

使用

es6

逐一指定要加载的方法

import { changeTheme, refresh } from './yg-portaljs-sdk';

整体加载的写法如下。

import * as ypsdk from 'yg-portaljs-sdk';

ypsdk.changeTheme('techblue')

script tag

window.ypsdk.changeTheme('techblue');

amd

<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.2/require.min.js"></script>
<script>
  window.requirejs(['yg-portaljs-sdk'], function(ypsdk) {
    console.log(ypsdk.add(1, 2));
  });
</script>

Demo:

  • [SDK 配置]

| 函数 | 说明 | 参数 | | :-----| ----: | :----: | | changeTheme | 改变主题 | (string: 'techblue','sunorange','dark') | | refresh | 刷新 | 无 | | goHome | 回到主页 | 无 | | logOut | 退出 | 无 | | onAddTab | 监听tab | options | | addTab | 添加tab | 无 | | onHighLightMenu | 监听菜单高亮 | options | | highLightMenu | 菜单高亮 | options | | onTitleTab | 监听tabTitle变化 | options | | titleTab | 设置tabTitle | 无 | | onRouterChange | 监听RouterChange | options | | routerChange | 设置router change | options | | onRemoveTab | 监听onRemoveTab| options | | removeTab | 设置router change | options | | onHideTabs | 监听第一层tab隐藏 | options | | hideTabs | 触发hide Tabs | 无 | | clearTab | 清除所有 Tabs | 无 |



let funcConfig = {
  complete: function(...options) {
    console.log(options);
  },
  success: function(...options) {
    console.log(options);
  },
  cancel: function(...options) {
    console.log(options);
  },
  fail: function(...options) {
    console.log(options);
  },
};

路由、tab 统一 参数

const newTab = {
      title: `名称啊-${this.index}`,
      content: `名称啊-${this.index}`,
      key: `tab-${this.index}`,
      urlpath: `https://www.baidu.com?${this.index}`,
    } ;

触发

ypsdk.addTab(newTab);  

监听

ypsdk.onAddTab({success: this.onAddTab});

菜单高亮 门户用

ypsdk.onHighLightMenu({success: this.onHighLightMenu});

子应用使用

const menuOptions = {
    menuSelectedKeys: ['100000000000000068'],
    menuOpenKeys: ['100000000000000047', '100000000000000004', '100000000000000068'],
  };
ypsdk.highLightMenu(menuOptions);

路由变化

ypsdk.onRouterChange({success:function(){
    console.log('this is router subscribe success.',arguments);
}});

  
ypsdk.routerChange(newTab);
https://cdn.jsdelivr.net/npm/[email protected]/lib/ypsdk.min.js
window.setTimeout(() => {
      ypsdk.onRouterChange({
        isIframe: true,
        success: function() {
          console.log('this is componentDidMount router subscribe success.', arguments);
        }});  
    }, 300);
highLightMenu = () => {
    const menuOptions = {
      menuSelectedKeys: ['100000000000000068'],
      menuOpenKeys: ['100000000000000047', '100000000000000004', '100000000000000068'],
    };
    ypsdk.highLightMenu(menuOptions);
  }

通过CDN访问

jsdelivr

地址格式为:

https://cdn.jsdelivr.net/npm/(your packagename)@(version)/(file)

https://cdn.jsdelivr.net/npm/[email protected]/lib/ypsdk.min.js

unpkg.com

地址格式为: example

https://www.unpkg.com/[email protected]/lib/ypsdk.min.js

https://www.unpkg.com/:package@:version/:file

CDN访问慢 改成本地

通过webpack 打包

new CopyWebpackPlugin([
      {
        from: './node_modules/yg-portaljs-sdk/lib',
        to: 'lib',
      },
    ]),
<script type="test/javascript" src="/lib/ypsdk.min.js"></script>