123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <template>
- <div
- class="crumbs"
- :class="{
- dark: isDarkTheme
- }"
- >
- <ul>
- <li v-if="list[0]">
- <span class="name" :title="rootName || list[0].name" @click="onClickPath(0)">{{rootName || list[0].name}}</span>
- </li>
- <li v-if="list.length > 3">...</li>
- <li v-if="list.length > 2">
- <span class="name" :title="list[list.length - 2].name" @click="onClickPath(list.length - 2)">{{list[list.length - 2].name}}</span>
- </li>
- <li v-if="list.length > 1">
- <span class="name" :title="list[list.length - 1].name" @click="onClickPath(list.length - 1)">{{list[list.length - 1].name}}</span>
- </li>
- </ul>
- </div>
- </template>
- <script>
- export default {
- props: {
- isDarkTheme: {
- type: Boolean,
- default: false,
- },
- list: {
- type: Array,
- required: true,
- },
- rootName: {
- type: String,
- required: true,
- },
- },
- methods: {
- onClickPath(idx) {
- if (idx !== this.list.length - 1) {
- this.$emit('click-path', idx)
- }
- }
- }
- }
- </script>
- <style lang="less" scoped>
- .crumbs{
- >ul{
- display: flex;
- align-items: center;
- >li{
- font-size: 14px;
- color: #969799;
- // line-height: 28px;
- .name{
- max-width: 285px;
- overflow: hidden;
- white-space: pre;
- text-overflow: ellipsis;
- cursor: pointer;
- }
- &::after {
- content: '>';
- margin-left: 7px;
- margin-right: 7px;
- }
- &:last-of-type{
- font-size: 14px;
- // font-weight: bold;
- color: #333333;
- line-height: 28px;
- .name {
- cursor: default;
- }
- &::after {
- content: '';
- }
- }
- }
- }
- }
- .crumbs.dark {
- >ul{
- >li{
- color: rgba(255, 255, 255, 0.6);
- &:last-of-type{
- color: #fff;
- }
- }
- }
- }
- </style>
|