Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: resolve __NEXT_DATA__ for userData #180

Merged
merged 6 commits into from
Mar 1, 2025
Merged

fix: resolve __NEXT_DATA__ for userData #180

merged 6 commits into from
Mar 1, 2025

Conversation

dragon-fish
Copy link
Member

@dragon-fish dragon-fish commented Mar 1, 2025

Sourcery 总结

Bug 修复:

  • 修复了由于 Pixiv 网站结构更改导致无法提取用户数据,进而导致登录失败的问题。
Original summary in English

Summary by Sourcery

Bug Fixes:

  • Resolves an issue where user data could not be extracted due to changes in Pixiv's website structure, causing login failures.

Copy link

vercel bot commented Mar 1, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
pixiv-now ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 1, 2025 11:44pm

Copy link
Contributor

sourcery-ai bot commented Mar 1, 2025

## Sourcery 提供的审查者指南

此拉取请求解决了一个问题,即由于网站数据结构的变化,用户数据无法被正确解析。这些更改包括添加解析 `__NEXT_DATA__` 脚本标签的逻辑、更新依赖项以及改进错误处理。

_由于更改看起来很简单,不需要可视化表示,因此未生成图表。_

### 文件级别更改

| 变更 | 详情 | 文件 |
| ------ | ------- | ----- |
| 在 `pnpm-lock.yaml` 和 `package.json` 中将依赖项更新到最新版本。 | <ul><li>将 `date-fns` 从 `^4.0.0` 更新到 `^4.1.0`。</li><li>将 `naive-ui` 从 `^2.40.4` 更新到 `^2.41.0`。</li><li>将 `pinia` 从 `^2.3.0` 更新到 `^3.0.0`。</li><li>将 `vue-i18n` 从 `^11.0.1` 更新到 `^11.1.0`。</li><li>将 `vue-waterfall-plugin-next` 从 `^2.6.4` 更新到 `^2.6.5`。</li><li>将 `@tabler/icons-vue` 从 `^3.26.0` 更新到 `^3.29.0`。</li><li>将 `@types/node` 从 `^22.10.2` 更新到 `^22.13.1`。</li><li>将 `@vercel/node` 从 `^5.0.0` 更新到 `^5.1.2`。</li><li>将 `@vueuse/core` 从 `^12.2.0` 更新到 `^12.5.0`。</li><li>将 `sass` 从 `^1.83.0` 更新到 `^1.84.0`。</li><li>将 `typescript` 从 `^5.7.2` 更新到 `^5.7.3`。</li><li>将 `vercel` 从 `^39.2.2` 更新到 `^39.4.2`。</li><li>将 `vite` 从 `^6.0.6` 更新到 `^6.1.0`。</li></ul> | `pnpm-lock.yaml`<br/>`package.json` |
| 实现了从 `__NEXT_DATA__` 脚本标签解析用户数据的逻辑。 | <ul><li>添加了一个新的函数 `resolveNextData` 来解析 `__NEXT_DATA__` 脚本并提取用户数据和令牌。</li><li>修改了主函数以检查 `__NEXT_DATA__` 是否存在,如果找到则使用 `resolveNextData`。</li><li>重构了错误处理,以提供有关错误原因的更多上下文。</li><li>为 `UserXRestrict` 枚举添加了类型定义。</li></ul> | `api/user.ts`<br/>`src/types/Users.ts` |

---

<details>
<summary>提示和命令</summary>

#### 与 Sourcery 互动

- **触发新的审查:** 在拉取请求上评论 `@sourcery-ai review`。
- **继续讨论:** 直接回复 Sourcery 的审查评论。
- **从审查评论生成 GitHub issue:** 通过回复审查评论,要求 Sourcery 从该评论创建一个 issue。您也可以回复审查评论并使用 `@sourcery-ai issue` 从该评论创建一个 issue。
- **生成拉取请求标题:** 在拉取请求标题中的任何位置写入 `@sourcery-ai` 以随时生成标题。您也可以在拉取请求上评论 `@sourcery-ai title` 以随时(重新)生成标题。
- **生成拉取请求摘要:** 在拉取请求正文中的任何位置写入 `@sourcery-ai summary` 以随时在您想要的位置生成 PR 摘要。您也可以在拉取请求上评论 `@sourcery-ai summary` 以随时(重新)生成摘要。
- **生成审查者指南:** 在拉取请求上评论 `@sourcery-ai guide` 以随时(重新)生成审查者指南。
- **解决所有 Sourcery 评论:** 在拉取请求上评论 `@sourcery-ai resolve` 以解决所有 Sourcery 评论。如果您已经解决了所有评论并且不想再看到它们,这将非常有用。
- **驳回所有 Sourcery 审查:** 在拉取请求上评论 `@sourcery-ai dismiss` 以驳回所有现有的 Sourcery 审查。如果您想从新的审查开始,这将特别有用 - 不要忘记评论 `@sourcery-ai review` 以触发新的审查!
- **为 issue 生成行动计划:** 在 issue 上评论 `@sourcery-ai plan` 以为其生成行动计划。

#### 自定义您的体验

访问您的 [仪表板](https://app.sourcery.ai) 以:
- 启用或禁用审查功能,例如 Sourcery 生成的拉取请求摘要、审查者指南等。
- 更改审查语言。
- 添加、删除或编辑自定义审查说明。
- 调整其他审查设置。

#### 获得帮助

- [联系我们的支持团队](mailto:support@sourcery.ai) 提出问题或反馈。
- 访问我们的 [文档](https://docs.sourcery.ai) 获取详细的指南和信息。
- 通过在 [X/Twitter](https://x.com/SourceryAI)、[LinkedIn](https://www.linkedin.com/company/sourcery-ai/) 或 [GitHub](https://github.com/sourcery-ai) 上关注我们,与 Sourcery 团队保持联系。

</details>
Original review guide in English

Reviewer's Guide by Sourcery

This pull request addresses an issue where user data was not being correctly resolved due to changes in the website's data structure. The changes include adding logic to parse the __NEXT_DATA__ script tag, updating dependencies, and improving error handling.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Updated dependencies in pnpm-lock.yaml and package.json to their latest versions.
  • Updated date-fns from ^4.0.0 to ^4.1.0.
  • Updated naive-ui from ^2.40.4 to ^2.41.0.
  • Updated pinia from ^2.3.0 to ^3.0.0.
  • Updated vue-i18n from ^11.0.1 to ^11.1.0.
  • Updated vue-waterfall-plugin-next from ^2.6.4 to ^2.6.5.
  • Updated @tabler/icons-vue from ^3.26.0 to ^3.29.0.
  • Updated @types/node from ^22.10.2 to ^22.13.1.
  • Updated @vercel/node from ^5.0.0 to ^5.1.2.
  • Updated @vueuse/core from ^12.2.0 to ^12.5.0.
  • Updated sass from ^1.83.0 to ^1.84.0.
  • Updated typescript from ^5.7.2 to ^5.7.3.
  • Updated vercel from ^39.2.2 to ^39.4.2.
  • Updated vite from ^6.0.6 to ^6.1.0.
pnpm-lock.yaml
package.json
Implemented logic to resolve user data from __NEXT_DATA__ script tag.
  • Added a new function resolveNextData to parse the __NEXT_DATA__ script and extract user data and token.
  • Modified the main function to check for the existence of __NEXT_DATA__ and use resolveNextData if found.
  • Refactored error handling to provide more context about the cause of the error.
  • Added type definitions for UserXRestrict enum.
api/user.ts
src/types/Users.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @dragon-fish - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding a comment explaining why both legacy and next data resolvers are needed.
  • The error handling in resolveNextData could be improved by checking if nextData?.props?.pageProps?.serverSerializedPreloadedState exists before parsing.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
@dragon-fish dragon-fish merged commit 6f44727 into master Mar 1, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants