Skip to content

Commit

Permalink
fix: 修复文档历史插件获取日志的错误
Browse files Browse the repository at this point in the history
  • Loading branch information
simply-none committed Apr 9, 2024
1 parent 88af33d commit 8905b63
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 46 deletions.
8 changes: 3 additions & 5 deletions log2.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: 简隐 jousindea@163.com
* @Date: 2024-03-31 19:15:45
* @LastEditors: 简隐 jousindea@163.com
* @LastEditTime: 2024-03-31 23:34:05
* @LastEditTime: 2024-04-10 00:46:47
* @FilePath: \latest-blogs\log2.js
* @Description:
*
Expand All @@ -24,15 +24,14 @@ export default function GitChangelogMarkdownSection(options = {}) {
name: '@jadeq/vitefdsfsfpress-plugin-markdown-changelog',
buildStart () {
commits = gitlog.default({
repo: './',
// repo: './',
branch: 'master',
number: 1000000,
includeMergeCommitFiles: true,
fields: ["hash", "abbrevHash", "subject", "authorName", "authorDate", "committerName", "committerDate", "authorDateRel", "tag", 'rawBody'],
...options
})
commits = generateFileCommits(commits)
console.log(Object.keys(commits), 'com', Object.keys(commits).length)
},
resolveId(id) {
if (id === ResolvedVirtualModuleId) {
Expand Down Expand Up @@ -75,7 +74,6 @@ function generateFileCommits (commits) {
return commits.reduce((pre, cur) => {
cur.files.map((originFile) => {
let file = toChinese(originFile)
console.log(file, originFile)
if (!file.startsWith("docs") || !file.endsWith(".md")) {
return false;
}
Expand All @@ -92,7 +90,7 @@ function generateFileCommits (commits) {
});

return pre;
});
}, {});

}

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 28 additions & 40 deletions utils/a.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,73 +2,58 @@
* @Author: 简隐 jousindea@163.com
* @Date: 2024-03-31 19:29:53
* @LastEditors: 简隐 jousindea@163.com
* @LastEditTime: 2024-04-01 00:32:05
* @LastEditTime: 2024-04-10 01:12:01
* @FilePath: \latest-blogs\utils\a.vue
* @Description:
*
* Copyright (c) 2024 by 简隐, All Rights Reserved.
-->
<template>
<em v-if="!currentFileCommit.length" opacity="70"
>{{ "nona" }}
<button @click="onShowAllCommit">展示所有</button>
<div v-if="!showAllCommit">
上一次提交:<pre>{{ currentFileCommit[0] }}</pre>
</div>
<em v-if="!currentFileCommit.length" opacity="70">
<el-button type="primary" plain @click="onShowAllCommit(true)">展开</el-button>
<!-- <div v-if="!showAllCommit">
上一次提交:
<pre>{{ currentFileCommit[0] }}</pre>
</div> -->
</em>
<div v-else :class="['bg-$vp-custom-block-details-bg']" rounded-lg p-4>

<div
class="grid grid-cols-[30px_auto] mt-3 gap-1.5 children:my-auto -ml-1.5"
text="<sm:xs"
>

<div class="grid grid-cols-[30px_auto] mt-3 gap-1.5 children:my-auto -ml-1.5" text="<sm:xs">
<template v-for="commit of currentFileCommit" :key="commit.hash">
<template v-if="commit.tag">
<div
class="m-auto h-[1.75em] w-[1.75em] inline-flex rounded-full bg-gray-400/10 opacity-90"
>
<div
class="i-octicon:rocket-16 !h-[50%] !min-h-[50%] !min-w-[50%] !w-[50%]"
m="auto"
/>
<template v-if="commit.tag && !commit.tag.startsWith('HEAD')">
<div class="m-auto h-[1.75em] w-[1.75em] inline-flex rounded-full bg-gray-400/10 opacity-90">
<div class="i-octicon:rocket-16 !h-[50%] !min-h-[50%] !min-w-[50%] !w-[50%]" m="auto" />
</div>
<div flex items-center gap-1>
<a :href="commit.tag" target="_blank">
<code class="font-bold">{{ commit.tag }}</code>
</a>
<ClientOnly>
<span class="text-xs opacity-50">
{{ commit.authorDate }}
</span>
<span>: </span>
<span>{{ commit.rawBody }}</span>,
<span>[{{ commit.committerName }}]</span>
<span>({{ commit.committerDate }})</span>
</ClientOnly>
</div>
</template>
<template v-else>
<div
class="i-octicon:git-commit-16 m-auto rotate-90 transform opacity-30"
/>
<div class="i-octicon:git-commit-16 m-auto rotate-90 transform opacity-30" />
<div flex items-center gap-1>
<a
:href="`${commit.repo_url}/commit/${commit.hash}`"
target="_blank"
>
<code
class="text-xs text-$vp-c-brand-1 hover:text-$vp-c-brand-1"
transition="color ease-in-out"
duration-200
>
<a :href="`${commit.repo_url}/commit/${commit.hash}`" target="_blank">
<code class="text-xs text-$vp-c-brand-1 hover:text-$vp-c-brand-1" transition="color ease-in-out"
duration-200>
{{ commit.abbrevHash }}
</code>
</a>
<span>: </span>
<span>{{ commit.rawBody }}</span>,
<span>{{ commit.rawBody }}</span>,
<span>[{{ commit.committerName }}]</span>
<span>({{ commit.committerDate }})</span>
</div>
</template>
</template>
</div>
<ElButton type="primary" plain>CES</ElButton>
<ElButton type="primary" plain @click="onShowAllCommit(false)">收起</ElButton>
</div>
</template>

Expand All @@ -83,12 +68,14 @@ import Changelog from 'virtual:git-changelog'
const route = useRoute();
let showAllCommit = ref(false);
function onShowAllCommit() {
showAllCommit.value = !showAllCommit.value;
function onShowAllCommit(show) {
showAllCommit.value = show;
if (showAllCommit.value) {
filterCommit();
} else {
currentFileCommit.value = []
}
}
Expand All @@ -107,6 +94,7 @@ function useRawPath(route) {
function filterCommit() {
let path = useRawPath(route);
console.log(Changelog, 'changelog')
currentFileCommit.value = Changelog.commits[path.value] || []
}
Expand Down

0 comments on commit 8905b63

Please sign in to comment.