优化页面
This commit is contained in:
137
unpackage/dist/dev/mp-weixin/TUIKit/components/TUIChat/message-input-toolbar/image-upload/index.js
vendored
Normal file
137
unpackage/dist/dev/mp-weixin/TUIKit/components/TUIChat/message-input-toolbar/image-upload/index.js
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../../../common/vendor.js");
|
||||
require("../../../../adapter-vue.js");
|
||||
const TUIKit_utils_env = require("../../../../utils/env.js");
|
||||
const common_assets = require("../../../../../common/assets.js");
|
||||
const TUIKit_components_TUIChat_utils_utils = require("../../utils/utils.js");
|
||||
const TUIKit_components_TUIChat_offlinePushInfoManager_index = require("../../offlinePushInfoManager/index.js");
|
||||
const TUIKit_components_TUIChat_config = require("../../config.js");
|
||||
if (!Math) {
|
||||
ToolbarItemContainer();
|
||||
}
|
||||
const ToolbarItemContainer = () => "../toolbar-item-container/index.js";
|
||||
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
|
||||
__name: "index",
|
||||
props: {
|
||||
// Image source: only valid for uni-app version, web version only supports selecting images from the album.
|
||||
// album: Select from album
|
||||
// camera: Take a photo using the camera
|
||||
imageSourceType: {
|
||||
type: String,
|
||||
default: "album"
|
||||
}
|
||||
},
|
||||
setup(__props) {
|
||||
const props = __props;
|
||||
const inputRef = common_vendor.ref();
|
||||
const currentConversation = common_vendor.ref();
|
||||
const theme = TUIKit_components_TUIChat_config.ChatConfig.getTheme();
|
||||
const IMAGE_TOOLBAR_SHOW_MAP = {
|
||||
web_album: {
|
||||
icon: theme === "dark" ? common_assets.imageIconDark : common_assets.imageIconLight,
|
||||
title: "图片"
|
||||
},
|
||||
uni_album: {
|
||||
icon: common_assets.imageUniIcon,
|
||||
title: "图片"
|
||||
},
|
||||
uni_camera: {
|
||||
icon: common_assets.cameraUniIcon,
|
||||
title: "拍照"
|
||||
}
|
||||
};
|
||||
common_vendor.Jt.watch(common_vendor.o.CONV, {
|
||||
currentConversation: (conversation) => {
|
||||
currentConversation.value = conversation;
|
||||
}
|
||||
});
|
||||
const imageToolbarForShow = common_vendor.computed(() => {
|
||||
if (TUIKit_utils_env.isUniFrameWork) {
|
||||
return props.imageSourceType === "camera" ? IMAGE_TOOLBAR_SHOW_MAP["uni_camera"] : IMAGE_TOOLBAR_SHOW_MAP["uni_album"];
|
||||
} else {
|
||||
return IMAGE_TOOLBAR_SHOW_MAP["web_album"];
|
||||
}
|
||||
});
|
||||
const onIconClick = () => {
|
||||
var _a, _b, _c, _d;
|
||||
if (TUIKit_utils_env.isUniFrameWork) {
|
||||
if (TUIKit_utils_env.isWeChat && ((_a = common_vendor.i) == null ? void 0 : _a.chooseMedia)) {
|
||||
(_b = common_vendor.i) == null ? void 0 : _b.chooseMedia({
|
||||
count: 1,
|
||||
mediaType: ["image"],
|
||||
sizeType: ["original", "compressed"],
|
||||
sourceType: [props.imageSourceType],
|
||||
// Use camera or select from album.
|
||||
success: function(res) {
|
||||
sendImageMessage(res);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
(_c = common_vendor.i) == null ? void 0 : _c.chooseImage({
|
||||
count: 1,
|
||||
sourceType: [props.imageSourceType],
|
||||
// Use camera or select from album.
|
||||
success: function(res) {
|
||||
sendImageMessage(res);
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if ((_d = inputRef.value) == null ? void 0 : _d.click) {
|
||||
inputRef.value.click();
|
||||
}
|
||||
}
|
||||
};
|
||||
const sendImageInWeb = (e) => {
|
||||
var _a, _b;
|
||||
if (((_b = (_a = e == null ? void 0 : e.target) == null ? void 0 : _a.files) == null ? void 0 : _b.length) <= 0) {
|
||||
return;
|
||||
}
|
||||
sendImageMessage(e == null ? void 0 : e.target);
|
||||
e.target.value = "";
|
||||
};
|
||||
const sendImageMessage = (files) => {
|
||||
var _a, _b, _c, _d, _e;
|
||||
if (!files) {
|
||||
return;
|
||||
}
|
||||
const options = {
|
||||
to: ((_b = (_a = currentConversation == null ? void 0 : currentConversation.value) == null ? void 0 : _a.groupProfile) == null ? void 0 : _b.groupID) || ((_d = (_c = currentConversation == null ? void 0 : currentConversation.value) == null ? void 0 : _c.userProfile) == null ? void 0 : _d.userID),
|
||||
conversationType: (_e = currentConversation == null ? void 0 : currentConversation.value) == null ? void 0 : _e.type,
|
||||
payload: {
|
||||
file: files
|
||||
},
|
||||
needReadReceipt: TUIKit_components_TUIChat_utils_utils.isEnabledMessageReadReceiptGlobal()
|
||||
};
|
||||
const offlinePushInfoCreateParams = {
|
||||
conversation: currentConversation.value,
|
||||
payload: options.payload,
|
||||
messageType: common_vendor.qt.TYPES.MSG_IMAGE
|
||||
};
|
||||
const sendMessageOptions = {
|
||||
offlinePushInfo: TUIKit_components_TUIChat_offlinePushInfoManager_index.OfflinePushInfoManager.create(offlinePushInfoCreateParams)
|
||||
};
|
||||
common_vendor.Qt.sendImageMessage(options, sendMessageOptions);
|
||||
};
|
||||
return (_ctx, _cache) => {
|
||||
return common_vendor.e({
|
||||
a: !common_vendor.unref(TUIKit_utils_env.isUniFrameWork)
|
||||
}, !common_vendor.unref(TUIKit_utils_env.isUniFrameWork) ? {
|
||||
b: common_vendor.o$1(sendImageInWeb),
|
||||
c: common_vendor.n(!common_vendor.unref(TUIKit_utils_env.isPC) && "image-upload-h5")
|
||||
} : {}, {
|
||||
d: common_vendor.o$1(onIconClick),
|
||||
e: common_vendor.p({
|
||||
iconFile: common_vendor.unref(imageToolbarForShow).icon,
|
||||
title: common_vendor.unref(imageToolbarForShow).title,
|
||||
iconWidth: common_vendor.unref(TUIKit_utils_env.isUniFrameWork) ? "32px" : "20px",
|
||||
iconHeight: common_vendor.unref(TUIKit_utils_env.isUniFrameWork) ? "25px" : "18px",
|
||||
needDialog: false
|
||||
})
|
||||
});
|
||||
};
|
||||
}
|
||||
});
|
||||
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-2d15f470"]]);
|
||||
wx.createComponent(Component);
|
||||
//# sourceMappingURL=../../../../../../.sourcemap/mp-weixin/TUIKit/components/TUIChat/message-input-toolbar/image-upload/index.js.map
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"toolbar-item-container": "../toolbar-item-container/index"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<toolbar-item-container wx:if="{{e}}" class="data-v-2d15f470" u-s="{{['d']}}" bindonIconClick="{{d}}" u-i="2d15f470-0" bind:__l="__l" u-p="{{e}}"><view wx:if="{{a}}" class="{{['data-v-2d15f470', 'image-upload', c]}}"><input class="data-v-2d15f470" ref="inputRef" title="图片" type="file" data-type="image" accept="image/gif,image/jpeg,image/jpg,image/png,image/bmp,image/webp" bindchange="{{b}}"></input></view></toolbar-item-container>
|
||||
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* 这里是uni-app内置的常用样式变量
|
||||
*
|
||||
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
|
||||
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
|
||||
*
|
||||
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
|
||||
*/
|
||||
/* 颜色变量 */
|
||||
/* 行为相关颜色 */
|
||||
/* 文字基本颜色 */
|
||||
/* 背景颜色 */
|
||||
/* 边框颜色 */
|
||||
/* 尺寸变量 */
|
||||
/* 文字尺寸 */
|
||||
/* 图片尺寸 */
|
||||
/* Border Radius */
|
||||
/* 水平间距 */
|
||||
/* 垂直间距 */
|
||||
/* 透明度 */
|
||||
/* 文章场景相关 */
|
||||
body.data-v-2d15f470, div.data-v-2d15f470, ul.data-v-2d15f470, ol.data-v-2d15f470, dt.data-v-2d15f470, dd.data-v-2d15f470, li.data-v-2d15f470, dl.data-v-2d15f470, h1.data-v-2d15f470, h2.data-v-2d15f470, h3.data-v-2d15f470, h4.data-v-2d15f470, p.data-v-2d15f470 {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-style: normal;
|
||||
/* font:12px/22px"\5B8B\4F53",Arial,Helvetica,sans-serif; */
|
||||
}
|
||||
ol.data-v-2d15f470, ul.data-v-2d15f470, li.data-v-2d15f470 {
|
||||
list-style: none;
|
||||
}
|
||||
img.data-v-2d15f470 {
|
||||
border: 0;
|
||||
vertical-align: middle;
|
||||
pointer-events: none;
|
||||
}
|
||||
body.data-v-2d15f470 {
|
||||
color: #000;
|
||||
background: #FFF;
|
||||
}
|
||||
.clear.data-v-2d15f470 {
|
||||
clear: both;
|
||||
height: 1px;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
margin-top: -1px;
|
||||
}
|
||||
a.data-v-2d15f470 {
|
||||
color: #000;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
a.data-v-2d15f470:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
input.data-v-2d15f470, textarea.data-v-2d15f470 {
|
||||
-webkit-user-select: auto;
|
||||
user-select: auto;
|
||||
}
|
||||
input.data-v-2d15f470:focus, input.data-v-2d15f470:active, textarea.data-v-2d15f470:focus, textarea.data-v-2d15f470:active {
|
||||
outline: none;
|
||||
}
|
||||
.chat-aside.data-v-2d15f470 {
|
||||
position: absolute;
|
||||
top: 50px;
|
||||
right: 0;
|
||||
box-sizing: border-box;
|
||||
width: 360px !important;
|
||||
border-radius: 8px 0 0 8px;
|
||||
z-index: 9999;
|
||||
max-height: calc(100% - 50px);
|
||||
}
|
||||
Reference in New Issue
Block a user