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

user-action

v1.0.53

Published

``` npm i user-action ```

Downloads

15

Readme

行为上报

使用方法

1、下载依赖包

npm i user-action

2、引入(分为 vue2 和 vue3)

vue2 使用

import Vue from 'vue'
import { loadDirectives } from 'user-action'
loadDirectives.init({
  headers: {
    user_id: '111',
    tenant_id: '111',
    client_version: '111', // 后台可以不传
    user_name: '111',
    tenant_name: '111',
    report_module: 1 // 上报模块 1:CLIENT 2:WEB,默认或错误值为CLIENT
  },
  params: {
    whatsId: '111' // 后台可以不传
  }
})
loadDirectives.loadDirectivesV2(Vue)

vue3 使用

import { createApp } from 'vue'
import { loadDirectives } from 'user-action'
loadDirectives.init({
  headers: {
    user_id: '111',
    tenant_id: '111',
    client_version: '111',
    user_name: '111',
    tenant_name: '111',
    report_module: '1' // 上报模块 1:CLIENT 2:WEB 默认或错误值为CLIENT
  },
  params: {
    whatsId: '111'
  }
})
const app = createApp()
loadDirectives.loadDirectivesV3(app)

whatId 更改函数

// whatsId 更改
loadDirectives.update({
  whatsId: '222'
})

3、参数说明

headers

{
  "cpu_info": "amd", // cpu信息
  "video_card": "1001", // 显卡型号
  "window_version": "win7", // windows版本
  "memory_size": "18217331122", // 内存大小(G)
  "hard_memory_size": "500", // 硬盘大小(G)
  "client_version": "2", // 客户端版本
  "user_id": "200106", // 用户id - 必填
  "tenant_id": "200106", // 公司id - 必填
  "user_name": "add", // 用户名称 - 必填
  "tenant_name": "add", // 公司名称 - 必填
  "report_module": "2" // 上报模块 1:CLIENT 2:WEB,默认或错误值为CLIENT - 必填
}

params

[
  {
    "whatsId": "18217331122" // 客服号id
  }
]

行为类型(见 5 中,使用方式)

{
  "moduleCode": "OTHER", // 模块code
  "menuId": "110000", // 菜单(页面)id
  "actionType": "add" //行为类型
}
whatId 获取
// node 获取 whatsId
let whatsId = userInfo().selectWhats.userInfo.whatsId // 带有 '@' 符号
whatsId.slice(0, whatsId.indexOf('@'))

4、跨域处理

Vue2 跨域

devServer: {
  proxy: {
    '/useraction': {
      target: 'http://192.168.2.96:10013',
      changeOrigin: true,
      pathRewrite: {
        '^/useraction': '/'
      }
    },
  }
}

Vue3(vite) 跨域

proxy: {
  '/useraction': {
    target: 'http://192.168.2.96:10013',
    changeOrigin: true,
    rewrite: (path) => path.replace('/useraction', '')
  }
}

5、使用

点击事件使用

<button
  v-user-action="{ module_code: 'TXL', action_type: 'click' }"
  menu_id="300500"
>
  行为上报
</button>

tabs 使用

<el-tabs
  v-model="activeName"
  @tab-click="handleClick"
  v-user-action="{ module_code: 'TXL', action_type: 'click' }"
>
  <el-tab-pane
    v-for="(item,index) in tabsList"
    :key="index"
    :name="item.name"
    :label="item.label"
  >
    <template #label>
      <div :menu_id="item.menu_id">{{ item.label }}</div>
    </template>
  </el-tab-pane>
</el-tabs>

dropdown-menu

<el-dropdown-menu
  v-user-action="{ module_code: 'YHHX', action_type: 'unsettled' }"
>
  <el-dropdown-item @click="openMask(); addCollaboratorShowHide();">
    {{ $t('main.addCollaborator') }}
  </el-dropdown-item>
  <el-dropdown-item @click="noTransferred" menu_id="200006">
    {{ $t('main.inTheHighSeas') }}
  </el-dropdown-item>
</el-dropdown-menu>