- Vue 3 + TypeScript + Element Plus 前端界面 - Pinia 状态管理 - Vue Router 4 路由管理 - Axios HTTP 客户端 - MSW (Mock Service Worker) 开发环境模拟 - 账户管理界面 (列表、详情、三科目余额展示) - 交易管理界面 (列表、详情) - 对账管理界面 (三账校验) - 完善的 API 客户端封装 - Docker 容器化配置 - Nginx 配置用于生产环境
82 lines
2.7 KiB
JavaScript
82 lines
2.7 KiB
JavaScript
import { defineComponent, ref, computed, watch, openBlock, createElementBlock, normalizeClass, normalizeStyle, createBlock, unref, withCtx, resolveDynamicComponent, renderSlot } from 'vue';
|
|
import { ElIcon } from '../../icon/index.mjs';
|
|
import { avatarProps, avatarEmits } from './avatar.mjs';
|
|
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
|
|
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
|
|
import { isString } from '@vue/shared';
|
|
import { isNumber } from '../../../utils/types.mjs';
|
|
import { addUnit } from '../../../utils/dom/style.mjs';
|
|
|
|
const _hoisted_1 = ["src", "alt", "srcset"];
|
|
const _sfc_main = defineComponent({
|
|
...{
|
|
name: "ElAvatar"
|
|
},
|
|
__name: "avatar",
|
|
props: avatarProps,
|
|
emits: avatarEmits,
|
|
setup(__props, { emit: __emit }) {
|
|
const props = __props;
|
|
const emit = __emit;
|
|
const ns = useNamespace("avatar");
|
|
const hasLoadError = ref(false);
|
|
const avatarClass = computed(() => {
|
|
const { size, icon, shape } = props;
|
|
const classList = [ns.b()];
|
|
if (isString(size))
|
|
classList.push(ns.m(size));
|
|
if (icon)
|
|
classList.push(ns.m("icon"));
|
|
if (shape)
|
|
classList.push(ns.m(shape));
|
|
return classList;
|
|
});
|
|
const sizeStyle = computed(() => {
|
|
const { size } = props;
|
|
return isNumber(size) ? ns.cssVarBlock({
|
|
size: addUnit(size)
|
|
}) : void 0;
|
|
});
|
|
const fitStyle = computed(() => ({
|
|
objectFit: props.fit
|
|
}));
|
|
watch(
|
|
() => props.src,
|
|
() => hasLoadError.value = false
|
|
);
|
|
function handleError(e) {
|
|
hasLoadError.value = true;
|
|
emit("error", e);
|
|
}
|
|
return (_ctx, _cache) => {
|
|
return openBlock(), createElementBlock(
|
|
"span",
|
|
{
|
|
class: normalizeClass(avatarClass.value),
|
|
style: normalizeStyle(sizeStyle.value)
|
|
},
|
|
[
|
|
(_ctx.src || _ctx.srcSet) && !hasLoadError.value ? (openBlock(), createElementBlock("img", {
|
|
key: 0,
|
|
src: _ctx.src,
|
|
alt: _ctx.alt,
|
|
srcset: _ctx.srcSet,
|
|
style: normalizeStyle(fitStyle.value),
|
|
onError: handleError
|
|
}, null, 44, _hoisted_1)) : _ctx.icon ? (openBlock(), createBlock(unref(ElIcon), { key: 1 }, {
|
|
default: withCtx(() => [
|
|
(openBlock(), createBlock(resolveDynamicComponent(_ctx.icon)))
|
|
]),
|
|
_: 1
|
|
})) : renderSlot(_ctx.$slots, "default", { key: 2 })
|
|
],
|
|
6
|
|
);
|
|
};
|
|
}
|
|
});
|
|
var Avatar = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/avatar/src/avatar.vue"]]);
|
|
|
|
export { Avatar as default };
|
|
//# sourceMappingURL=avatar2.mjs.map
|