Skip to content

Commit 6a65a60

Browse files
authored
fix(user-head): modify mobile problem (#2699)
1 parent eb5fd89 commit 6a65a60

File tree

5 files changed

+10
-26
lines changed

5 files changed

+10
-26
lines changed

examples/sites/demos/mobile/app/user-head/basic-usage.vue

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
<div class="title">尺寸</div>
44
<div class="item-content">
55
<tiny-user-head type="label" v-model="name" :size="80" round></tiny-user-head>
6-
<tiny-user-head type="label" v-model="name" size="large" round></tiny-user-head>
7-
<tiny-user-head type="label" v-model="name" size="medium" round></tiny-user-head>
8-
<tiny-user-head type="label" v-model="namePrefix" size="small" round></tiny-user-head>
6+
<tiny-user-head type="label" v-model="name" :size="70" round></tiny-user-head>
7+
<tiny-user-head type="label" v-model="name" :size="60" round></tiny-user-head>
8+
<tiny-user-head type="label" v-model="name" :size="50" round></tiny-user-head>
99
</div>
1010

1111
<div class="title">类型</div>
@@ -35,8 +35,7 @@ export default {
3535
data() {
3636
return {
3737
imageUrl: `${import.meta.env.VITE_APP_BUILD_BASE_URL}static/images/fruit.jpg`,
38-
name: '小明',
39-
namePrefix: '小'
38+
name: '小明'
4039
}
4140
}
4241
}

examples/sites/demos/mobile/app/user-head/custom-background-color.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<tiny-user-head type="icon" background-color="var(--ti-common-color-line-active)"></tiny-user-head>
2+
<tiny-user-head type="icon" background-color="'#5E7CE0'"></tiny-user-head>
33
</template>
44

55
<script lang="jsx">

examples/sites/demos/mobile/app/user-head/webdoc/user-head.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,18 +135,6 @@ export default {
135135
},
136136
codeFiles: ['min-user-head.vue']
137137
},
138-
{
139-
demoId: 'render-user-head-in-grid',
140-
name: {
141-
'zh-CN': '渲染用户头像在网格中',
142-
'en-US': 'button type'
143-
},
144-
desc: {
145-
'zh-CN': '<p>渲染用户头像在网格中</p>',
146-
'en-US': '<p>button type</p>'
147-
},
148-
codeFiles: ['render-user-head-in-grid.vue']
149-
},
150138
{
151139
demoId: 'round-user-head',
152140
name: {

packages/mobile/components/user-head/src/renderless/index.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const computedMessage =
2727
({ props }: Pick<IUserHeadRenderlessParams, 'props'>) =>
2828
() => {
2929
let result = ''
30-
const total = Math.floor(props.messageTotal || NaN)
30+
const total = Math.floor(Number(props.messageTotal) || NaN)
3131

3232
if (props.messageType === 'details' && !isNaN(total) && total > 0) {
3333
result = String(total)
@@ -65,11 +65,7 @@ export const computedFontSize =
6565
6: `${state.size / 9}px`
6666
}
6767

68-
if (mode === 'mobile-first') {
69-
fontSize = mfsizeMap[length]
70-
} else {
71-
fontSize = sizeMap[length]
72-
}
68+
fontSize = sizeMap[length]
7369
}
7470

7571
return { fontSize }

packages/mobile/components/user-head/src/user-head.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212

1313
import type { ExtractPropTypes } from 'vue'
1414
import type { ISharedRenderlessFunctionParams, ISharedRenderlessParamUtils } from '../../../types/shared.type'
15-
export type { ISharedRenderlessParamHooks } from '../../../types/shared.type'
1615
import type { computedFontSize, computedLabel, computedMessage, computedStyle, getInternalValue } from './renderless'
1716

17+
export type { ISharedRenderlessParamHooks } from '../../../types/shared.type'
18+
1819
export const $constants = {
1920
ITEM_NAME: '.user-head-item'
2021
}
@@ -80,7 +81,7 @@ export const userHeadProps = {
8081
/**
8182
* @property {Number} - 消息计数
8283
*/
83-
messageTotal: Number,
84+
messageTotal: [Number, String],
8485

8586
/**
8687
* @property {String} [messageType=details] - 消息类型 details|basic 可选

0 commit comments

Comments
 (0)