Polyv Help Center

Help Center

Announcement (New Version) Components

Updated: 2024-04-22 19:18:32

The Announcement components include the Announcement List component, Pinned Announcement component, and Pinned Announcement Bubble component. All three components use the same event system, so you only need to instantiate one Announcement SDK and pass the instance to the three different announcement components.

  • The Announcement List component provides list display and announcement detail viewing functionality.
  • The Pinned Announcement component displays pinned-type announcements.
  • The Pinned Announcement Bubble component is another display type for pinned announcements, suitable for portrait viewing pages.

Before introducing and using these functional components, you need to perform common configuration for the Interactive Function Receiver SDK. For details, see: Interactive Function Receiver UI Components - Configure SDK.

Import

Online File Import Method

// script 标签引入,根据版本号引入JS版本。
<script src="https://websdk.videocc.net/interactions-receive-sdk-ui-default/0.24.0/lib/PcBulletin/PcBulletin.umd.min.js"></script>
// PC端
<script>
  const Bulletin = window.PolyvIRScene.PcBulletin.default;
</script>
// script 标签引入,根据版本号引入JS版本。
<script src="https://websdk.videocc.net/interactions-receive-sdk-ui-default/0.24.0/lib/MobileBulletin/MobileBulletin.umd.min.js"></script>
// 移动端
<script>
  const Bulletin = window.PolyvIRScene.MobileBulletin.default;
</script>
// PC端
import Bulletin from '@polyv/interactions-receive-sdk-ui-default/lib/PcBulletin/index';
// 移动端
import Bulletin from '@polyv/interactions-receive-sdk-ui-default/lib/MobileBulletin/index';

Usage

Announcement List Component

The Announcement List component handles most of the business logic internally based on the SDK, but the list is hidden by default. The integrator needs to call the relevant APIs to display the list.

Code Example

Taking PC integration as an example:

<template>
  <div>
    <button type="button" @click="showBulletinList">打开公告列表</button>
    <div>
      <h1>{{ bulletinTitle }}</h1>
      <bulletin
        ref="bulletin"
        :lang="lang"
        :announcement-sdk="bulletinSdk"
        @title-change="onTitleChange"
      />
    </div>
  </div>
</template>

<script>
import { Announcement as BulletinSdk } from '@polyv/interactions-receive-sdk';
import Bulletin from '@polyv/interactions-receive-sdk-ui-default/lib/PcBulletin/index';

export default {
  components: {
    Bulletin,
  },

  data() {
    return {
      // 公告SDK实例
      bulletinSdk,
      // 是否展示公告
      isShowbulletin: false,
      // 外部弹窗(容器)标题
      bulletinTitle: '',
    };
  },

  created() {
    this.bulletinSdk = new BulletinSdk();
  },

  beforeDestroy() {
    this.bulletinSdk.destroy();
  },

  methods: {
    showBulletinList() {
      this.$refs.bulletin && this.$refs.bulletin.showBulletinList();
    },
    onTitleChange(title) {
      const titles = {
        list: '公告列表',
        detail: '公告',
      };
      this.bulletinTitle = titles[title] || titles.detail;
    },
  },
};
</script>

Pinned Announcement Component (Same for PC and Mobile)

<template>
  <bulletin-top
    class="plv-demo-pc-bulletin__top"
    :announcement-sdk="bulletinSdk"
    @show-top="onShowTop"
  />
</template>

<script>
import { Announcement as BulletinSdk } from '@polyv/interactions-receive-sdk';
import BulletinTop from '@polyv/interactions-receive-sdk-ui-default/lib/BulletinTop/index';

export default {
  components: {
    BulletinTop,
  },

  data() {
    return {
      // 公告SDK实例
      bulletinSdk,
    };
  },

  created() {
    this.bulletinSdk = new BulletinSdk();
  },

  methods: {
    onShowTop() {
      // 可在此处处理自己的业务逻辑
    },
  },
};
</script>

Pinned Announcement Bubble Component (Same for PC and Mobile)

<template>
  <bulletin-bubble
    :announcement-sdk="announcementSdk"
    @show-bubble="onShowBubble"
  />
</template>

<script>
import { Announcement as BulletinSdk } from '@polyv/interactions-receive-sdk';
import BulletinBubble from '@polyv/interactions-receive-sdk-ui-default/lib/BulletinBubble/index';

export default {
  components: {
    BulletinBubble,
  },

  data() {
    return {
      // 公告SDK实例
      bulletinSdk,
    };
  },

  created() {
    this.bulletinSdk = new BulletinSdk();
  },

  methods: {
    onShowBubble() {
      // 可在此处处理自己的业务逻辑
    },
  },
};
</script>

Attributes

Attribute Type Default Description
announcementSdk Object null Announcement SDK instance
lang string: 'zh_CN', 'en' 'zh_CN' Language
cacheReadedEnabled Boolean true Whether to remove strong announcement reminders (save read status to storage)

Announcement List Component Events

Event Name Parameter Type Parameter Description Description
title-change String or Undefined `'list' 'detail'`, indicates whether the list or announcement detail is currently displayed
look-over - - Triggered when clicking an announcement in the list
show-detail-from-socket Object Announcement data Triggered when a new popup announcement message is received, indicating the announcement should be displayed in a popup
show-list - - Triggered when returning to the list from a newly received announcement
hide - - Triggered when: 1. Viewing a new announcement and receiving another new pinned or popup announcement; 2. Viewing a new announcement and clicking the close button; 3. Viewing a new announcement and receiving a delete message for the current announcement

Pinned Announcement Component / Pinned Announcement Bubble Component Events

Event Name Parameter Type Parameter Description Description
show-top Object Announcement data (see show-detail-from-socket event parameter description) Triggered when a new pinned announcement is received
show-bubble Object Announcement data (see show-detail-from-socket event parameter description) Triggered when a new pinned announcement is received
show-detail-from-socket Event Parameter Description

The show-detail-from-socket event includes an object-type event parameter with the following fields.

Attribute Type Description
content String Announcement content
createTime Number Announcement creation time
id Number Announcement ID
isPop Number Whether it is a popup announcement, 1 means yes, 0 means no
isTop Number Whether it is a pinned announcement, 1 means yes, 0 means no
nick String Nickname of the announcement publisher
pic String Avatar of the announcement publisher
userId String User ID of the announcement publisher
roomId String Room ID

Methods

Method Name Parameters Description
showBulletinList No parameters Display the announcement list
markAnnounceReaded No parameters Mark as read; the same announcement will not pop up again when received next time

联系客服,在线咨询