Skip to content

Commit

Permalink
feat: Detail组件重构完成
Browse files Browse the repository at this point in the history
  • Loading branch information
kailong321200875 committed Oct 19, 2021
1 parent 34221f3 commit 7f5ef99
Show file tree
Hide file tree
Showing 12 changed files with 833 additions and 148 deletions.
31 changes: 20 additions & 11 deletions components.d.ts
Expand Up @@ -4,18 +4,25 @@

declare module 'vue' {
export interface GlobalComponents {
404: typeof import('E:/HBuilderProjects/element-plus-admin/src/components/Error/404.vue')['default']
404: typeof import('./src/components/Error/404.vue')['default']
Aa: typeof import('E:/HBuilderProjects/element-plus-admin/src/components/aa.vue')['default']
CountTo: typeof import('E:/HBuilderProjects/element-plus-admin/src/components/CountTo/index.vue')['default']
Dialog: typeof import('E:/HBuilderProjects/element-plus-admin/src/components/Dialog/index.vue')['default']
Echart: typeof import('E:/HBuilderProjects/element-plus-admin/src/components/Echart/index.vue')['default']
Editor: typeof import('E:/HBuilderProjects/element-plus-admin/src/components/Editor/index.vue')['default']
Avatars: typeof import('./src/components/Avatars/index.vue')['default']
CountTo: typeof import('./src/components/CountTo/index.vue')['default']
Detail: typeof import('./src/components/Detail/index.vue')['default']
Dialog: typeof import('./src/components/Dialog/index.vue')['default']
Echart: typeof import('./src/components/Echart/index.vue')['default']
Editor: typeof import('./src/components/Editor/index.vue')['default']
ElAlert: typeof import('element-plus/es')['ElAlert']
ElAvatar: typeof import('element-plus/es')['ElAvatar']
ElBacktop: typeof import('element-plus/es')['ElBacktop']
ElButton: typeof import('element-plus/es')['ElButton']
ElCard: typeof import('element-plus/es')['ElCard']
ElCol: typeof import('element-plus/es')['ElCol']
ElCollapseTransition: typeof import('element-plus/es')['ElCollapseTransition']
ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider']
ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
ElDescriptions: typeof import('element-plus/es')['ElDescriptions']
ElDescriptionsItem: typeof import('element-plus/es')['ElDescriptionsItem']
ElDialog: typeof import('element-plus/es')['ElDialog']
ElDrawer: typeof import('element-plus/es')['ElDrawer']
ElDropdown: typeof import('element-plus/es')['ElDropdown']
Expand All @@ -38,16 +45,18 @@ declare module 'vue' {
ElSwitch: typeof import('element-plus/es')['ElSwitch']
ElTabPane: typeof import('element-plus/es')['ElTabPane']
ElTabs: typeof import('element-plus/es')['ElTabs']
ElTag: typeof import('element-plus/es')['ElTag']
ElTimePicker: typeof import('element-plus/es')['ElTimePicker']
ElTimeSelect: typeof import('element-plus/es')['ElTimeSelect']
ElTooltip: typeof import('element-plus/es')['ElTooltip']
Highlight: typeof import('E:/HBuilderProjects/element-plus-admin/src/components/Highlight/index.vue')['default']
ParentView: typeof import('E:/HBuilderProjects/element-plus-admin/src/components/ParentView/index.vue')['default']
Preview: typeof import('E:/HBuilderProjects/element-plus-admin/src/components/Preview/index.vue')['default']
Qrcode: typeof import('E:/HBuilderProjects/element-plus-admin/src/components/Qrcode/index.vue')['default']
Redirect: typeof import('E:/HBuilderProjects/element-plus-admin/src/components/Redirect/index.vue')['default']
Search: typeof import('E:/HBuilderProjects/element-plus-admin/src/components/Search/index.vue')['default']
SvgIcon: typeof import('E:/HBuilderProjects/element-plus-admin/src/components/SvgIcon/index.vue')['default']
Loading: typeof import('element-plus/es')['ElLoadingDirective']
ParentView: typeof import('./src/components/ParentView/index.vue')['default']
Preview: typeof import('./src/components/Preview/index.vue')['default']
Qrcode: typeof import('./src/components/Qrcode/index.vue')['default']
Redirect: typeof import('./src/components/Redirect/index.vue')['default']
Search: typeof import('./src/components/Search/index.vue')['default']
SvgIcon: typeof import('./src/components/SvgIcon/index.vue')['default']
}
}

Expand Down
18 changes: 9 additions & 9 deletions package.json
Expand Up @@ -10,7 +10,7 @@
"build:dev": "vue-tsc --noEmit && vite build --mode dev",
"build:test": "vue-tsc --noEmit && vite build --mode test",
"serve": "vite preview",
"check": "npm-check-updates",
"check": "npx npm-check-updates",
"clean": "npx rimraf docs/node_modules && npx rimraf node_modules",
"clean:docs": "npx rimraf docs/node_modules",
"clean:main": "npx rimraf node_modules",
Expand All @@ -25,12 +25,12 @@
"dependencies": {
"@element-plus/icons": "^0.0.11",
"@vueuse/core": "^6.5.3",
"axios": "^0.22.0",
"axios": "^0.23.0",
"clipboard": "^2.0.8",
"echarts": "^5.2.1",
"echarts-wordcloud": "^2.0.0",
"element-plus": "1.1.0-beta.20",
"highlight.js": "^11.2.0",
"element-plus": "1.1.0-beta.21",
"highlight.js": "^11.3.1",
"intro.js": "^4.2.2",
"lodash-es": "^4.17.21",
"mockjs": "^1.1.0",
Expand Down Expand Up @@ -76,17 +76,17 @@
"stylelint-config-prettier": "^8.0.2",
"stylelint-config-standard": "^22.0.0",
"stylelint-order": "^4.1.0",
"typescript": "^4.4.3",
"unplugin-element-plus": "^0.1.0",
"unplugin-vue-components": "^0.15.6",
"vite": "^2.6.4",
"typescript": "^4.4.4",
"unplugin-element-plus": "^0.1.3",
"unplugin-vue-components": "^0.16.0",
"vite": "^2.6.10",
"vite-plugin-commonjs-externals": "^0.1.1",
"vite-plugin-eslint": "^1.3.0",
"vite-plugin-style-import": "^1.2.1",
"vite-plugin-svg-icons": "^1.0.5",
"vite-plugin-vue-setup-extend": "^0.1.0",
"vue-eslint-parser": "^7.11.0",
"vue-tsc": "^0.3.0"
"vue-tsc": "^0.28.7"
},
"engines": {
"node": ">= 14.0.0",
Expand Down
141 changes: 141 additions & 0 deletions src/components/Avatars/index.vue
@@ -0,0 +1,141 @@
<template>
<div class="avatars-wrap">
<template v-if="tooltip">
<el-tooltip
v-for="(item, $index) in avatarsData"
:key="$index"
:content="item.text"
placement="top"
>
<div
:class="
showAvatar ? 'avatars-item-img' : ['avatars-item', `avatars-${item.type || 'default'}`]
"
>
<el-avatar v-if="showAvatar" :size="40" :src="item.url">
<img :src="defaultImg" />
</el-avatar>
<span v-else>{{ item.text.substr(0, 1) }}</span>
</div>
</el-tooltip>
<div v-if="max && data.length - max > 0" :class="['avatars-item', 'avatars-item-img']">
<span>+{{ data.length - max }}</span>
</div>
</template>
<template v-else>
<div
v-for="(item, $index) in avatarsData"
:key="$index"
:class="
showAvatar ? 'avatars-item-img' : ['avatars-item', `avatars-${item.type || 'default'}`]
"
>
<el-avatar v-if="showAvatar" :size="40" :src="item.url">
<img :src="defaultImg" />
</el-avatar>
<span v-else>{{ item.text.substr(0, 1) }}</span>
</div>
<div v-if="max && data.length - max > 0" :class="['avatars-item', 'avatars-item-img']">
<span>+{{ data.length - max }}</span>
</div>
</template>
</div>
</template>

<script setup lang="ts" name="Avatars">
import { PropType, computed } from 'vue'
import { deepClone } from '@/utils'
import { AvatarConfig } from './types'
import defaultImg from '@/assets/img/default-avatar.png'
const props = defineProps({
// 展示的数据
data: {
type: Array as PropType<AvatarConfig[]>,
default: () => []
},
// 最大展示数量
max: {
type: Number as PropType<number>,
default: 0
},
// 是否使用头像
showAvatar: {
type: Boolean as PropType<boolean>,
default: false
},
// 是否显示完整名称
tooltip: {
type: Boolean as PropType<boolean>,
default: true
}
})
const avatarsData = computed(() => {
if (props.max) {
if (props.data.length <= props.max) {
return props.data
} else {
const data = deepClone(props.data).splice(0, props.max)
return data
}
} else {
return props.data
}
})
</script>

<style lang="less" scoped>
.avatars-wrap {
display: flex;
.avatars-item {
display: inline-block;
width: 40px;
height: 40px;
line-height: 40px;
color: #fff;
text-align: center;
background: #2d8cf0;
border: 1px solid #fff;
border-radius: 50%;
}
.avatars-item-img {
display: inline-block;
border-radius: 50%;
.el-avatar--circle {
border: 1px solid #fff;
}
}
.avatars-item-img + .avatars-item-img {
margin-left: -12px;
}
.avatars-item + .avatars-item {
margin-left: -12px;
}
.avatars-default {
color: #bae7ff;
background: #096dd9;
}
.avatars-success {
color: #f6ffed;
background: #52c41a;
}
.avatars-danger {
color: #fff1f0;
background: #f5222d;
}
.avatars-warning {
color: #fffbe6;
background: #faad14;
}
}
</style>
5 changes: 5 additions & 0 deletions src/components/Avatars/types.ts
@@ -0,0 +1,5 @@
export interface AvatarConfig {
text: string
type?: string
url?: string
}

0 comments on commit 7f5ef99

Please sign in to comment.