quasar-app-extension-quasar-fight-group

1.1.6 • Public • Published

Quasar App Extension quasar-fight-group

Add a short description of your App Extension. What does it do? How is it beneficial? Why would someone want to use it?

npm npm

Install

quasar ext add quasar-fight-group

Quasar CLI will retrieve it from NPM and install the extension.

Prompts

If your app extension uses prompts, explain them here, otherwise remove this section and remove prompts.js file.

Uninstall

quasar ext remove quasar-fight-group

Info

Add longer information here that will help the user of your app extension.

Other Info

Add other information that's not as important to know

Donate

If you appreciate the work that went into this App Extension, please consider donating to Quasar.

License

MIT (c) Destini stdeng1224@163.com

组件属性

Name(属性名称) Type(属性类型) Description(属性描述) Default(默认值)
messages Array 消息列表 []
userId String 传入的 userId,用于判断是否是发送人 ''
isShowJC Boolean 名称是否显示机构 false
buttons Array 工具栏按钮 []
isShowTime Boolean 是否显示时间 false
timeFormat String 时间格式 'MM-DD hh:mm'
noMoreMessages Boolean 是否存在更多消息标识 false
messageTextColor String 消息文本颜色 'black'
rightMsgBgColor String 发送者消息背景颜色 'green-4'
leftMsgBgColor String 接收者消息背景颜色 'blue-2'
inputBorderColor String 输入框背景颜色 'black'
addIconColor String 工具栏旁边加号按钮颜色 'black'
fileBaseUrl String 文件地址 ''

注意事项

当noMoreMessages为false时,必须配置loadChatList事件进行请求更多消息的处理,同时这个函数接收了一个参数done,执行相关操作后必须执行**done()**才能结束,否则会出现一直加载中且无法继续加载的问题。

当noMoreMessages为true时,不会出现加载效果或请求更多消息,注意此时请求返回的messages数组一定要足够大,可以在请求时设置pageSize为100及以上。

消息头像

消息中的头像默认截取为机构名称前四位,若没有机构名称但名称为系统默认头像会显示为系统,若都不存在则为"我"。

另外,我在消息头像中放置了插槽,可自定义消息头像样式,并且存在该插槽时,会默认覆盖掉原有的消息头像样式。插槽使用方式如下:

<template v-slot:customAvatar>
	//自定义的头像内容
	<q-avatar color="primary" size="2rem" text-color="white" style="margin:0 0.5rem;">
		<span class="name">我</span>
	</q-avatar>
</template>

消息类型

在不同消息类型中,已经对多种类型进行了处理,其中消息类型为点位还抛出了一个onNav事件需要使用者自行定义处理。

另外,我在消息类型的处理中放置了插槽,以便存在更多的消息类型去进行自定义样式,并且存在该插槽时,会覆盖掉原有的消息类型样式。

举个例子:如果此时有两个消息类型名分别为要点、提示,那么可以自定义消息类型代码如下

<template v-slot:要点="{ message }">
	<div class="case-update" style="max-width: 16rem;">
		<span>要点</span>
		<div class="info" v-html="message" />
	</div>
</template>
<template v-slot:提示="{ message }">
	<div class="case-update" style="max-width: 16rem;">
		<span>提示</span>
		<div class="info" v-html="message" />
	</div>
</template>

工具栏

1.在工具栏中,我们默认配置了图片、视频、文件两种按钮,但需要你在使用组件时定义buttons属性时自行添加如下两个按钮对象,注意**type: 'image'type: 'video'或type: 'file'必须存在,此时你还需要在组件上配置@getFile="你定义的函数"**去对已选择的图片或者视频文件进行处理。

<FightGroup :messages="messages" :buttons="buttons" @getFile="getFile" @onNav="onNav" @sendText="sendText" />

const buttons = [{
  type: 'image', //类型
  name: '图片', //显示在图标下方的名称
  icon: 'bi-camera-fill', //图标
  textColor: 'blue-9' //图标颜色
},
{
  type: 'video',
  name: '视频',
  icon: 'bi-camera-reels-fill',
  textColor: 'green-7',
}]

function getFile(e){
	console.log('getFile', e.target.files[0]);
	//e.target.files[0]为已选择的文件内容
}

2.在工具栏中,如果你需要自定义按钮,请模仿下面代码:

const buttons = [{
  // type: 'location', //自定义按钮的类型可写可不写
  name: '定位', //显示在图标下方的名称
  icon: 'bi-geo-alt-fill', //图标
  textColor: 'orange-8', //图标颜色
  caseClick:
  //按钮的自定义点击事件
  () => {
    console.log('点击了定位');
  }
}]

3.在工具栏输入框中,抛出了一个sendText事件需要使用者自行定义处理

4.在工具栏中,对于输入框前面,我放置了插槽,以便存在更多自定义按钮进行处理。插槽使用方式如下:

<template v-slot:toolInputBefore>
	//自定义按钮
	<q-icon size="md" class="t-icon-[fluent--speaker-16-filled] cursor-pointer" color="white" />
</template>

5.在工具栏中,对于输入框非空时,右边的图标按钮我放置了插槽,以便存在更多自定义按钮进行处理,并且存在该插槽时,会覆盖掉原有的发送样式。插槽使用方式如下:

<template v-slot:toolBtn>
	//自定义发送样式
	<q-btn unelevated color="primary" icon="message"/>
    <q-btn unelevated color="primary" icon="bi-soundwave" style="margin-left: 0.5rem;"/>
</template>

注意事项

需要在quasar.config.js里面至少引入如下三种图标,否则可能会出现图标无法显示的清空

module.exports = function (ctx) {
  return {
    ...
    extras: [
      'mdi-v5',
      'material-icons',
      'bootstrap-icons'
    ]
	...
}

Readme

Keywords

none

Package Sidebar

Install

npm i quasar-app-extension-quasar-fight-group

Weekly Downloads

1

Version

1.1.6

License

MIT

Unpacked Size

9.26 kB

Total Files

5

Last publish

Collaborators

  • destini1224