消息
This commit is contained in:
75
unpackage/dist/dev/mp-weixin/TUIKit/components/common/Avatar/index.js
vendored
Normal file
75
unpackage/dist/dev/mp-weixin/TUIKit/components/common/Avatar/index.js
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../../common/vendor.js");
|
||||
require("../../../adapter-vue.js");
|
||||
const TUIKit_utils_env = require("../../../utils/env.js");
|
||||
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
|
||||
__name: "index",
|
||||
props: {
|
||||
url: { default: "https://web.sdk.qcloud.com/component/TUIKit/assets/avatar_21.png" },
|
||||
size: { default: "36px" },
|
||||
borderRadius: { default: "5px" },
|
||||
useSkeletonAnimation: { type: Boolean, default: false }
|
||||
},
|
||||
emits: ["onLoad", "onError"],
|
||||
setup(__props, { emit: __emit }) {
|
||||
const defaultAvatarUrl = common_vendor.ref("https://web.sdk.qcloud.com/component/TUIKit/assets/avatar_21.png");
|
||||
const emits = __emit;
|
||||
const props = __props;
|
||||
const {
|
||||
size: avatarSize,
|
||||
url: avatarImageUrl,
|
||||
borderRadius: avatarBorderRadius,
|
||||
useSkeletonAnimation: useAvatarSkeletonAnimation
|
||||
} = common_vendor.toRefs(props);
|
||||
let reloadAvatarTime = 0;
|
||||
const isImgLoaded = common_vendor.ref(false);
|
||||
const loadErrorInUniapp = common_vendor.ref(false);
|
||||
function avatarLoadSuccess(e) {
|
||||
isImgLoaded.value = true;
|
||||
emits("onLoad", e);
|
||||
}
|
||||
function avatarLoadFailed(e) {
|
||||
reloadAvatarTime += 1;
|
||||
if (reloadAvatarTime > 3) {
|
||||
return;
|
||||
}
|
||||
if (TUIKit_utils_env.isUniFrameWork) {
|
||||
loadErrorInUniapp.value = true;
|
||||
} else {
|
||||
e.currentTarget.src = defaultAvatarUrl.value;
|
||||
}
|
||||
emits("onError", e);
|
||||
}
|
||||
return (_ctx, _cache) => {
|
||||
return common_vendor.e({
|
||||
a: common_vendor.unref(TUIKit_utils_env.isUniFrameWork)
|
||||
}, common_vendor.unref(TUIKit_utils_env.isUniFrameWork) ? common_vendor.e({
|
||||
b: !common_vendor.unref(loadErrorInUniapp)
|
||||
}, !common_vendor.unref(loadErrorInUniapp) ? {
|
||||
c: common_vendor.unref(avatarImageUrl) || common_vendor.unref(defaultAvatarUrl),
|
||||
d: common_vendor.o$1(avatarLoadSuccess),
|
||||
e: common_vendor.o$1(avatarLoadFailed)
|
||||
} : {
|
||||
f: common_vendor.unref(defaultAvatarUrl),
|
||||
g: common_vendor.o$1(avatarLoadSuccess),
|
||||
h: common_vendor.o$1(avatarLoadFailed)
|
||||
}) : {
|
||||
i: common_vendor.unref(avatarImageUrl) || common_vendor.unref(defaultAvatarUrl),
|
||||
j: common_vendor.o$1(avatarLoadSuccess),
|
||||
k: common_vendor.o$1(avatarLoadFailed)
|
||||
}, {
|
||||
l: common_vendor.unref(useAvatarSkeletonAnimation) && !common_vendor.unref(isImgLoaded)
|
||||
}, common_vendor.unref(useAvatarSkeletonAnimation) && !common_vendor.unref(isImgLoaded) ? {
|
||||
m: common_vendor.unref(isImgLoaded) ? 1 : "",
|
||||
n: common_vendor.unref(useAvatarSkeletonAnimation) ? 1 : ""
|
||||
} : {}, {
|
||||
o: common_vendor.unref(avatarSize),
|
||||
p: common_vendor.unref(avatarSize),
|
||||
q: common_vendor.unref(avatarBorderRadius)
|
||||
});
|
||||
};
|
||||
}
|
||||
});
|
||||
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-c7c42418"]]);
|
||||
wx.createComponent(Component);
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/TUIKit/components/common/Avatar/index.js.map
|
||||
4
unpackage/dist/dev/mp-weixin/TUIKit/components/common/Avatar/index.json
vendored
Normal file
4
unpackage/dist/dev/mp-weixin/TUIKit/components/common/Avatar/index.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
1
unpackage/dist/dev/mp-weixin/TUIKit/components/common/Avatar/index.wxml
vendored
Normal file
1
unpackage/dist/dev/mp-weixin/TUIKit/components/common/Avatar/index.wxml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<view class="avatar-container data-v-c7c42418" style="{{'width:' + o + ';' + ('height:' + p) + ';' + ('border-radius:' + q)}}"><block wx:if="{{a}}"><image wx:if="{{b}}" class="avatar-image data-v-c7c42418" src="{{c}}" bindload="{{d}}" binderror="{{e}}"/><image wx:else class="avatar-image data-v-c7c42418" src="{{f}}" bindload="{{g}}" binderror="{{h}}"/></block><image wx:else class="avatar-image data-v-c7c42418" src="{{i}}" bindload="{{j}}" binderror="{{k}}"></image><view wx:if="{{l}}" class="{{['data-v-c7c42418', 'placeholder', m && 'hidden', n && 'skeleton-animation']}}"/></view>
|
||||
63
unpackage/dist/dev/mp-weixin/TUIKit/components/common/Avatar/index.wxss
vendored
Normal file
63
unpackage/dist/dev/mp-weixin/TUIKit/components/common/Avatar/index.wxss
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* 这里是uni-app内置的常用样式变量
|
||||
*
|
||||
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
|
||||
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
|
||||
*
|
||||
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
|
||||
*/
|
||||
/* 颜色变量 */
|
||||
/* 行为相关颜色 */
|
||||
/* 文字基本颜色 */
|
||||
/* 背景颜色 */
|
||||
/* 边框颜色 */
|
||||
/* 尺寸变量 */
|
||||
/* 文字尺寸 */
|
||||
/* 图片尺寸 */
|
||||
/* Border Radius */
|
||||
/* 水平间距 */
|
||||
/* 垂直间距 */
|
||||
/* 透明度 */
|
||||
/* 文章场景相关 */
|
||||
.data-v-c7c42418:not(not) {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
min-width: 0;
|
||||
}
|
||||
.avatar-container.data-v-c7c42418 {
|
||||
position: relative;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
overflow: hidden;
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
.avatar-container .placeholder.data-v-c7c42418 {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: #ececec;
|
||||
transition: opacity 0.3s, background-color 0.1s ease-out;
|
||||
}
|
||||
.avatar-container .placeholder.skeleton-animation.data-v-c7c42418 {
|
||||
animation: breath-c7c42418 2s linear 0.3s infinite;
|
||||
}
|
||||
.avatar-container .placeholder.hidden.data-v-c7c42418 {
|
||||
opacity: 0;
|
||||
}
|
||||
.avatar-container .avatar-image.data-v-c7c42418 {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
@keyframes breath-c7c42418 {
|
||||
50% {
|
||||
/* stylelint-disable-next-line scss/no-global-function-names */
|
||||
background-color: lightgray;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user