0.0.72 • Published 10 months ago

@utoolkits/ui v0.0.72

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

UNI-UI

安装

npm install @utoolkits/im-sdk
npm install @utoolkits/ui
// 或
npm install @utoolkits/im-sdk
yarn add @utoolkits/ui

完整引入

import UNUI from "@utoolkits/ui";
import "@utoolkits/ui/dist/style.css";

按需引入

import { ChatList, MessageReviewList } from "@utoolkits/ui";
import "@utoolkits/ui/dist/style.css";

组件列表

IM 组件

import { ref } from "vue";
import { ChatList, MessageReviewList } from "@utoolkits/ui";
import "@utoolkits/ui/dist/style.css";
// 接收 im 实例
let env = "test";
let token =
  "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0aW1lIjoxNjgzNjc5MDkyMjA0LCJleHAiOjg2NDAxNjgzNTkyNjkyLCJ1c2VySWQiOjZ9.jcL-OX5M85m8gOCBDjQzz4UsIz5lHRGPSiRGr4YNAPE";
let liveRoomId = "1";
let imInstance = ref(null);
const onIMInstanceInitialized = (im) => {
  imInstance.value = im;
};
const members = ref([]);
const onJoin = (res) => {
  members.value.push(res);
};
const onExit = (res) => {
  const index = members.value.findIndex((item) => item.userId === res.userId);
  if (index > -1) {
    members.value.splice(index, 1);
  }
};
<div class="container">
  <div class="item">
    <ChatList
      :token="token"
      :env="env"
      :liveRoomId="liveRoomId"
      @im-instance-initialized="onIMInstanceInitialized"
      @exit="onExit"
      @join="onJoin"
    ></ChatList>
  </div>
  <div class="item">
    <MessageReviewList
      :imInstance="imInstance"
      :liveRoomId="liveRoomId"
    ></MessageReviewList>
  </div>
</div>

属性

属性描述默认值
env环境变量(必填)-
token凭证(必填)-
liveRoomId房间 ID(必填)-
chatroomNick聊天室昵称-
chatroomAvatar聊天室头像-
ext接收一个对象,扩展消息。 目前角色:(1, "用户"),(2, "助教老师"),(3, "讲师"); 比如现在是助教 { speechRole: 2 }{}
isRealUser只展示真实用户传 true, 默认为 false,显示全部消息false
channleIds只展示指定的渠道,渠道 ID 数组[]
filterFn如果上面 isRealUser,channleIds 不能满足时,可以通过过滤器函数。注意的是每次过滤条件变化,filterFn 必须是一个新的函数值,否则不会触发过滤filterFn = () => true;
themelight、darklight
sizesmall、mediummedium

事件

名称描述
im-instance-initializedim 实例化完成
join进入聊天室
exit退出聊天室
liveStart直播开始
liveEnd直播结束

审核列表组件

let messageReviewListRef = ref(null);
// 删除top10
const onDeleteTop = () => {
  messageReviewListRef.value.deleteTopMessages(10);
};
<el-button @click="onDeleteTop">删除前10条</el-button>
<MessageReviewList
  ref="messageReviewListRef"
  :imInstance="imInstance"
  :liveRoomId="liveRoomId"
></MessageReviewList>

属性

属性描述默认值
imInstanceim 实例(必填)-
liveRoomId房间 ID(必填)-
isActivate当前展示审核列表false

方法

方法描述默认值
deleteTopMessages(pos:number)删除前多少条消息-

在线用户列表

import { OnlineAudienceList } from "@utoolkits/ui";
<OnlineAudienceList
  ref="onlineAudienceListRef"
  :imInstance="imInstance"
  :liveRoomId="liveRoomId"
  show-detail-btn
></OnlineAudienceList>

属性

属性描述默认值
imInstanceim 实例(必填)-
liveRoomId房间 ID(必填)-
showDetailBtn展示详情按钮false
input搜索过滤条件""
channleIds渠道数组[]
filterFn自定义过滤函数,当希望支持更细过滤时可以考虑使用()=> true
themelight、darklight
sizesmall、mediummedium

方法

名称描述默认值
query查询-

事件

名称描述默认值
total(number)在线数-

在线助教列表

import { OnlineAssistantList } from "@utoolkits/ui";
<OnlineAssistantList
  ref="onlineAssistantListRef"
  :env="env"
  :token="token"
  :imInstance="imInstance"
  :liveRoomId="liveRoomId"
  show-detail-btn
></OnlineAssistantList>

属性

属性描述默认值
env环境变量(必填)-
token凭证(必填)-
imInstanceim 实例(必填)-
liveRoomId房间 ID(必填)-
showDetailBtn展示详情按钮false
input搜索过滤条件""
channleIds渠道数组过滤[]
filterFn自定义过滤函数,当希望支持更细过滤时可以考虑使用()=> true
themelight、darklight
sizesmall、mediummedium

方法

名称描述默认值
query查询-

事件

名称描述默认值
total(number)在线数-

表格组件

属性

属性描述默认值
loadData请求数据方法需要传入 Promise 对象
colums表格列-
selection显示多选框false
showIndex显示列表索引false
size每页展示多少条10

方法

方法描述默认值
getSelectionRows返回当前选中的行-
clearSelection清空用户的选择-

事件

事件描述默认值
selection-change当选择项发生变化时会触发该事件-

案例

<div class="container">
  <el-form :inline="true">
    <el-form-item label="姓名">
      <el-input v-model="input"></el-input>
    </el-form-item>
    <el-form-item>
      <el-button @click="onSerach" :loading="isLoading">查询</el-button>
    </el-form-item>
    <el-form-item>
      <el-button @click="onSelectionRow">获取选中行</el-button>
      <el-button @click="onClean">清空选中行</el-button>
    </el-form-item>
  </el-form>
</div>
<table
  ref="tableRef"
  :loadData="loadData"
  :colums="colums"
  selection
  showIndex
  @selection-change="onSelectionChange"
></table>
import { computed } from "vue";
import { VTable } from "@utoolkits/ui";

const input = ref("");
function getData() {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve({
        current: 1,
        records: [
          {
            id: 1,
            name: "抖音直播运营变现",
            time: "2020-12-12 12:12:12",
            status: false,
          },
          {
            id: 2,
            name: "3抖音直播运营变现",
            time: "2020-12-12 12:12:12",
            status: false,
          },
          {
            id: 3,
            name: "2抖音直播运营变现",
            time: "2020-12-12 12:12:12",
            status: true,
          },
          {
            id: 4,
            name: "1抖音直播运营变现",
            time: "2020-12-12 12:12:12",
            status: true,
          },
          {
            id: 2,
            name: "课程名称",
            time: "2020-12-12 12:12:12",
            status: false,
          },
          {
            id: 3,
            name: "课程名称",
            time: "2020-12-12 12:12:12",
            status: true,
          },
          {
            id: 4,
            name: "课程名称",
            time: "2020-12-12 12:12:12",
            status: false,
          },
        ],
        total: 100,
      });
    }, 3000);
  });
}
const colums = [
  {
    label: "ID",
    prop: "id",
  },
  {
    label: "姓名",
    prop: "name",
  },
  {
    label: "时间",
    prop: "time",
  },
  {
    label: "状态",
    prop: "status",
  },
];
const loadData = async (parameter) => {
  return getData({
    ...parameter,
    name: input.value,
  });
};
const tableRef = ref(null);
const isLoading = computed(() => tableRef.value?.isLoading);
const onSerach = () => {
  tableRef.value.query();
};
const onSelectionRow = () => {
  console.log(tableRef.value.getSelectionRows());
};
const onClean = () => {
  tableRef.value.clearSelection();
};
const onSelectionChange = (selection) => {
  console.log(selection);
};
0.0.70

10 months ago

0.0.71

10 months ago

0.0.72

10 months ago

0.0.66

10 months ago

0.0.67

10 months ago

0.0.68

10 months ago

0.0.69

10 months ago

0.0.65

11 months ago

0.0.64

11 months ago

0.0.62

11 months ago

0.0.63

11 months ago

0.0.40

11 months ago

0.0.41

11 months ago

0.0.42

11 months ago

0.0.43

11 months ago

0.0.44

11 months ago

0.0.45

11 months ago

0.0.46

11 months ago

0.0.47

11 months ago

0.0.37

11 months ago

0.0.38

11 months ago

0.0.39

11 months ago

0.0.30

12 months ago

0.0.31

12 months ago

0.0.32

12 months ago

0.0.33

12 months ago

0.0.34

12 months ago

0.0.35

11 months ago

0.0.36

11 months ago

0.0.26

12 months ago

0.0.27

12 months ago

0.0.28

12 months ago

0.0.29

12 months ago

0.0.20

12 months ago

0.0.21

12 months ago

0.0.22

12 months ago

0.0.23

12 months ago

0.0.24

12 months ago

0.0.25

12 months ago

0.0.60

11 months ago

0.0.61

11 months ago

0.0.59

11 months ago

0.0.15

12 months ago

0.0.16

12 months ago

0.0.17

12 months ago

0.0.18

12 months ago

0.0.19

12 months ago

0.0.51

11 months ago

0.0.52

11 months ago

0.0.53

11 months ago

0.0.54

11 months ago

0.0.10

12 months ago

0.0.55

11 months ago

0.0.11

12 months ago

0.0.56

11 months ago

0.0.12

12 months ago

0.0.57

11 months ago

0.0.13

12 months ago

0.0.58

11 months ago

0.0.14

12 months ago

0.0.50

11 months ago

0.0.48

11 months ago

0.0.9

12 months ago

0.0.49

11 months ago

0.0.8

12 months ago

0.0.7

12 months ago

0.0.6

12 months ago

0.0.5

12 months ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago