You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
apply-assistant-v3/pages/NEUIKit/components/Appellation.vue

88 lines
1.7 KiB
Vue

5 months ago
<template>
<span
class="appellation"
:style="{ color: color, fontSize: fontSize + 'px' }"
3 months ago
>
{{ appellation }}
<span v-if="subtitle" style="color: orange;">{{ subtitle }}</span>
</span
5 months ago
>
</template>
<script lang="ts" setup>
import { autorun } from 'mobx'
import {
onUnmounted,
ref,
defineProps,
withDefaults,
} from '../utils/transformVue'
import { deepClone } from '../utils'
const appellation = ref('')
3 months ago
const { pid,account, teamId, ignoreAlias, nickFromMsg } = withDefaults(
5 months ago
defineProps<{
account: string
teamId?: string
ignoreAlias?: boolean
nickFromMsg?: string
color?: string
fontSize?: number
3 months ago
pid?: number
5 months ago
}>(),
{
teamId: undefined,
ignoreAlias: false,
nickFromMsg: '-',
color: '#333',
fontSize: 16,
3 months ago
pid:0
5 months ago
}
)
3 months ago
const subtitle = ref('');
5 months ago
const uninstallAppellationWatch = autorun(() => {
3 months ago
if(pid){
async function getUserInfo() {
try {
const res = await uni.$UIKitStore.userStore.getUserActive(pid.split('|')[2])
return res
} catch (error) {
console.error('getUserInfo error:', error)
}
}
getUserInfo().then(res => {
if(res.serverExtension){
subtitle.value = '@' + JSON.parse(res.serverExtension).fullName;
}else{
subtitle.value = '';
}
appellation.value = res.name;
3 months ago
})
3 months ago
}else{
appellation.value = deepClone(
uni.$UIKitStore.uiStore.getAppellation({
account,
teamId,
ignoreAlias,
nickFromMsg,
})
)
}
5 months ago
})
onUnmounted(() => {
uninstallAppellationWatch()
})
</script>
<style scoped lang="scss">
.appellation {
color: #333;
font-size: 16px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
</style>