修正#喵喵日历 的错误

This commit is contained in:
yoimiya-kokomi 2022-09-05 11:48:45 +08:00
parent 70d2bd50cd
commit b360827c57
4 changed files with 13 additions and 7 deletions

View File

@ -1,6 +1,7 @@
import fetch from 'node-fetch'
import moment from 'moment'
import { Character } from '../../models/index.js'
import { Data } from '../../components/index.js'
import lodash from 'lodash'
const ignoreIds = [495, // 有奖问卷调查开启!
@ -105,7 +106,7 @@ let Cal = {
}
} catch (e) {
}
Data.setCacheJSON('cache:calendar:detail', timeMap, 60 * 10)
await Data.setCacheJSON('cache:calendar:detail', timeMap, 60 * 10)
}
return { listData, timeMap }
},

View File

@ -113,8 +113,9 @@ const CharMeta = {
let lens = []
let len = 0
let descs = []
const maxChars = 26
for (let desc of inputs) {
if (len + desc.length < 56) {
if (len + desc.length < maxChars * 2) {
lens.push(desc.length)
descs.push(desc)
len += desc.length
@ -122,16 +123,20 @@ const CharMeta = {
break
}
}
if (len <= 28) {
if (len <= maxChars - 6) {
return descs.join('')
}
let ret = [[], [], []]
let ret = [[], []]
let idx = 0
for (let desc of descs) {
if (ret[idx].join(' ').length + desc.length > 28) {
if (ret[idx].join(' ').length + desc.length > maxChars) {
idx++
}
ret[idx] = ret[idx] || []
ret[idx].push(desc)
if (descs.length === 2) {
idx++
}
}
return ret[0].join('') + '</br>' + ret[1].join('')
}

View File

@ -28,7 +28,7 @@ body {
height: 500px;
}
.char-desc {
padding-left: 220px;
padding-left: 200px;
font-size: 14px;
}
.char-meta {

View File

@ -38,7 +38,7 @@ body {
}
.char-desc {
padding-left: 220px;
padding-left: 200px;
font-size: 14px;
}