mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Fix truncate via adding 'truncateStr'
- Because the 'truncate' function uses 'trunc-html' which seem not to function anymore like expected what has to be investigated further.
This commit is contained in:
parent
ff50273f94
commit
6f79bba69d
@ -5,7 +5,7 @@
|
|||||||
<template #index="scope">{{ scope.index + 1 }}.</template>
|
<template #index="scope">{{ scope.index + 1 }}.</template>
|
||||||
<template #id="scope">
|
<template #id="scope">
|
||||||
<nuxt-link :to="{ path: '/', query: { hashtag: encodeURI(scope.row.id) } }">
|
<nuxt-link :to="{ path: '/', query: { hashtag: encodeURI(scope.row.id) } }">
|
||||||
<b>#{{ scope.row.id | truncate(20) }}</b>
|
<b>#{{ scope.row.id | truncateStr(20) }}</b>
|
||||||
</nuxt-link>
|
</nuxt-link>
|
||||||
</template>
|
</template>
|
||||||
</ds-table>
|
</ds-table>
|
||||||
|
|||||||
@ -33,6 +33,18 @@ export default ({ app = {} }) => {
|
|||||||
}
|
}
|
||||||
return trunc(value, length).html
|
return trunc(value, length).html
|
||||||
},
|
},
|
||||||
|
truncateStr: (value = '', length = -1) => {
|
||||||
|
if (!value || typeof value !== 'string' || value.length <= 0) {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
if (length <= 0) {
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
if (length < value.length) {
|
||||||
|
return value.substring(0, length) + '…'
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
},
|
||||||
list: (value, glue = ', ', truncate = 0) => {
|
list: (value, glue = ', ', truncate = 0) => {
|
||||||
if (!Array.isArray(value) || !value.length) {
|
if (!Array.isArray(value) || !value.length) {
|
||||||
return ''
|
return ''
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user