更新若干功能
This commit is contained in:
@@ -14,12 +14,13 @@ const matrix = computed(() => {
|
||||
const start = new Date(end)
|
||||
start.setDate(start.getDate() - 364)
|
||||
start.setDate(start.getDate() - start.getDay())
|
||||
const counts = new Map(props.days.map(x => [x.date, Number(x.count || 0)]))
|
||||
const counts = new Map(props.days.map(x => [x.date, x]))
|
||||
const cells = []
|
||||
for (let d = new Date(start); d <= end; d.setDate(d.getDate() + 1)) {
|
||||
const date = d.toISOString().slice(0, 10)
|
||||
const count = counts.get(date) || 0
|
||||
cells.push({ date, count, week: Math.floor((d - start) / weekMs), dow: d.getDay(), level: Math.min(4, count === 0 ? 0 : count < 2 ? 1 : count < 5 ? 2 : count < 10 ? 3 : 4) })
|
||||
const day = counts.get(date)
|
||||
const count = Number(day?.count || 0)
|
||||
cells.push({ date, count, added: Number(day?.added || 0), deleted: Number(day?.deleted || 0), week: Math.floor((d - start) / weekMs), dow: d.getDay(), level: Math.min(4, count === 0 ? 0 : count < 2 ? 1 : count < 5 ? 2 : count < 10 ? 3 : 4) })
|
||||
}
|
||||
const labels = []
|
||||
let lastMonth = -1
|
||||
@@ -58,7 +59,7 @@ function pick(cell) {
|
||||
@click="pick(cell)"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="hover" class="heat-tooltip">{{ hover.date }} · {{ hover.count }} {{ locale === 'zh-CN' ? '次提交' : 'commits' }}</div>
|
||||
<div v-if="hover" class="heat-tooltip">{{ hover.date }} · {{ hover.count }} {{ locale === 'zh-CN' ? '次提交' : 'commits' }}<template v-if="hover.count"> · <b class="positive">+{{ hover.added }}</b> <b class="negative">-{{ hover.deleted }}</b></template></div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user