Skip to content

Commit

Permalink
fix comment bug
Browse files Browse the repository at this point in the history
  • Loading branch information
gusibi committed Oct 14, 2024
1 parent bbee8bf commit a97c5bc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion components/CommentBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ const isLoggedIn = computed(() => {
return !!githubToken && !!githubUser && !!user.value
})
const submitComment = async () => {
if (commentText.value.trim()) {
try {
const response = await $fetch('/api/github/create-comment', {
method: 'POST',
body: {
issueNumber: route.params.id,
repoOwner: route.params.repo_owner,
repoName: route.params.repo_name,
commentText: commentText.value
}
})
Expand Down
6 changes: 3 additions & 3 deletions server/api/github/create-comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Octokit } from '@octokit/rest'
export default defineEventHandler(async (event) => {
const config = useRuntimeConfig()
const body = await readBody(event)
const { issueNumber, commentText } = body
const { issueNumber, repoOwner, repoName, commentText } = body

const token = getCookie(event, 'github_token')
const githubUser = getCookie(event, 'github_username')
Expand Down Expand Up @@ -37,8 +37,8 @@ export default defineEventHandler(async (event) => {
})
}
const response = await octokit.issues.createComment({
owner: githubUser, // 使用配置中的仓库所有者
repo: config.public.repoName, // 使用配置中的仓库名称
owner: repoOwner, // 使用URL中的仓库所有者
repo: repoName, // 使用URL中的仓库名称
issue_number: parseInt(issueNumber), // 确保 issue_number 是整数
body: commentText
})
Expand Down

0 comments on commit a97c5bc

Please sign in to comment.