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

修复tabber在档案馆infobox中溢出的问题 #42

Closed
wants to merge 5 commits into from

Conversation

ajdgg
Copy link
Member

@ajdgg ajdgg commented Nov 12, 2024

Summary by CodeRabbit

  • 新功能

    • 新增一个控制台打印的ASCII艺术logo,包含当前年份和MediaWiki版本信息。
    • 引入了NavbarAvatar功能的配置,默认启用,允许具有编辑权限的用户在导航栏中查看用户头像。
  • 样式

    • 新增样式以解决信息框中的标签溢出问题,增强了标签内容的布局和可用性。
  • 文档

    • 在许可证文件中添加了许可证类型和作者归属的说明。

Copy link

coderabbitai bot commented Nov 12, 2024

Walkthrough

此次更改包括在 src/ConsolePrintWordartLogo 目录中创建了一个新的 TypeScript 文件 ConsolePrintWordartLogo.ts,该文件实现了一个立即调用的异步函数,用于从 MediaWiki API 获取站点信息并生成 ASCII 艺术标志。还新增了一个 JSON 配置文件 definition.json,用于定义 NavbarAvatar 功能的参数。此外,LICENSE 文件中添加了许可证说明,而 SkinCitizen_CSS.less 文件则引入了一个新的样式表以解决 infobox 标签的溢出问题,并在 modules 目录中创建了相应的 LESS 文件。

Changes

文件路径 更改摘要
src/ConsolePrintWordartLogo/ConsolePrintWordartLogo.ts 新建文件,包含一个异步函数,用于获取 MediaWiki 信息并生成 ASCII 艺术标志。
src/ConsolePrintWordartLogo/LICENSE 在许可证文件中添加了许可证类型和作者归属的注释。
src/ConsolePrintWordartLogo/definition.json 新增 JSON 配置文件,定义 NavbarAvatar 功能的相关参数和依赖。
src/SkinCitizen_CSS/SkinCitizen_CSS.less 在现有模块导入列表中添加了新的样式表导入语句以解决 infobox 标签的溢出问题。
src/SkinCitizen_CSS/modules/infobox-tabber-overflow-repair.less 新建 LESS 文件,定义样式以解决 infobox 中标签的溢出问题。

Possibly related PRs

  • 缓解Infobox可能出现的宽度溢出 #43: 该 PR 涉及与 .infobox 类相关的 CSS 修改,可能与主 PR 中引入的新 ASCII 艺术标志的样式方面有关,因为两者都涉及用户界面中的视觉表现。

Suggested reviewers

  • ZoruaFox

在兔子洞里,代码如花开,
新功能来临,欢声笑语在。
ASCII 艺术,版本展示,
溢出问题,样式修缮。
代码更新,乐趣无穷,
一起欢庆,兔子同乐! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot requested a review from ZoruaFox November 12, 2024 12:19
@ZoruaFox ZoruaFox closed this Nov 12, 2024
@ZoruaFox ZoruaFox reopened this Nov 12, 2024
Copy link
Member

@ZoruaFox ZoruaFox left a comment

Choose a reason for hiding this comment

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

把原仓库的dist拉下来再提交。

const generatordata = await fetch(consoleTUrl);
const generatordataJson = (await generatordata.json()) as unknown;
const mideawikiVersions = (generatordataJson as {query: {general: {generator: string}}}).query.general.generator;
const ascll = `
Copy link

@rpuboh rpuboh Nov 12, 2024

Choose a reason for hiding this comment

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

"mediawiki", "ascii"

Copy link
Member Author

Choose a reason for hiding this comment

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

已更改

@rpuboh
Copy link

rpuboh commented Nov 12, 2024

建议不要把本地开发环境里的东西全作为PR提交。另开一个干净的branch、确认打算放进PR的内容与标题相关再申请合并。

@github-actions github-actions bot requested a review from ZoruaFox November 13, 2024 01:07
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (7)
src/ConsolePrintWordartLogo/definition.json (1)

8-8: 权限设置建议

当前配置要求用户具有 edit 权限才能使用此功能。考虑到这是一个显示用户头像的功能,建议重新评估是否真的需要编辑权限。

建议考虑:

  1. 是否应该允许所有已登录用户使用此功能
  2. 是否需要创建更细粒度的权限控制
src/SkinCitizen_CSS/modules/infobox-tabber-overflow-repair.less (3)

6-8: 建议添加浏览器兼容性前缀

为了确保在不同浏览器中的一致性,建议为 flex 相关属性添加浏览器前缀。

建议修改如下:

-				display: flex;
-				flex-direction: column;
+				display: -webkit-flex;
+				display: -moz-flex;
+				display: flex;
+				-webkit-flex-direction: column;
+				-moz-flex-direction: column;
+				flex-direction: column;

9-14: 建议优化选择器性能

当前选择器嵌套较深,可以考虑优化选择器以提高性能。同时建议为导航按钮添加过渡效果,提升用户体验。

建议修改如下:

-				.tabber__header .tabber__header__prev::after,
-				.tabber__header .tabber__header__next::after {
+				.tabber__header__prev::after,
+				.tabber__header__next::after {
 					display: block;
 					width: 100%;
 					height: 100%;
+					transition: all 0.3s ease;
 				}

8-8: 建议添加垂直方向的溢出控制

目前只控制了水平方向的溢出,建议同时考虑垂直方向的溢出情况。

建议修改如下:

-				overflow-x: auto;
+				overflow: auto;
+				max-height: 80vh;
src/ConsolePrintWordartLogo/ConsolePrintWordartLogo.ts (3)

1-5: 建议添加模块说明和许可证信息

文件头部注释应该包含:

  • 模块的功能说明
  • 许可证信息
  • 依赖说明

建议添加如下注释:

 /*
  * @coding: UTF-8
  * @Author: AwAjie
  * @Date: 2024-11-09 13:48:56
+ * @Description: 控制台打印 ASCII 艺术标志
+ * @license: MIT
+ * @requires: mediawiki
  */

11-21: 建议改进 ASCII 艺术字符串的处理方式

  1. 变量名 ascll 拼写错误,应为 ascii
  2. 建议将大型 ASCII 艺术字符串移至单独的文件中

建议创建单独的资源文件:

  1. 创建 ascii-template.ts:
export const ASCII_LOGO_TEMPLATE = `
██╗     ██╗                 ██████╗ ██╗                                        ██╗██╗      ██╗
// ... 其余 ASCII 艺术内容
`;
  1. 在主文件中导入并使用:
-    const ascll = `
-    // ... ASCII art
-    ©2023-${new Date().getFullYear()} 有兽档案馆                                                ${mideawikiVersions}
-    `;
+    import { ASCII_LOGO_TEMPLATE } from './ascii-template';
+    const ascii = ASCII_LOGO_TEMPLATE.replace(
+      '${year}',
+      `©2023-${new Date().getFullYear()} 有兽档案馆                                                ${mideawikiVersions}`
+    );

22-22: 建议增加调试信息

在开发环境中,建议添加更多调试信息以便于问题排查。

-    console.log(`%c${ascll}`, 'color:#159c5a');
+    if (mw.config.get('debug')) {
+      console.group('站点信息');
+      console.log('MediaWiki 版本:', mideawikiVersions);
+      console.log('服务器:', mw.config.get('wgServer'));
+      console.groupEnd();
+    }
+    console.log(`%c${ascii}`, 'color:#159c5a');
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 79dc1a6 and 1aba12e.

⛔ Files ignored due to path filters (6)
  • dist/ParameterSettingPageStyle/ParameterSettingPageStyle.css is excluded by !**/dist/**
  • dist/SkinCitizen_CSS/SkinCitizen_CSS.css is excluded by !**/dist/**
  • dist/VariantAllyDialog/VariantAllyDialog.css is excluded by !**/dist/**
  • dist/VariantAllyDialog/VariantAllyDialog.js is excluded by !**/dist/**
  • dist/definition.txt is excluded by !**/dist/**
  • dist/store.txt is excluded by !**/dist/**
📒 Files selected for processing (5)
  • src/ConsolePrintWordartLogo/ConsolePrintWordartLogo.ts (1 hunks)
  • src/ConsolePrintWordartLogo/LICENSE (1 hunks)
  • src/ConsolePrintWordartLogo/definition.json (1 hunks)
  • src/SkinCitizen_CSS/SkinCitizen_CSS.less (1 hunks)
  • src/SkinCitizen_CSS/modules/infobox-tabber-overflow-repair.less (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • src/ConsolePrintWordartLogo/LICENSE
  • src/SkinCitizen_CSS/SkinCitizen_CSS.less
🔇 Additional comments (1)
src/SkinCitizen_CSS/modules/infobox-tabber-overflow-repair.less (1)

1-18: 代码实现清晰,解决了溢出问题

代码通过使用 flexbox 布局和溢出控制来解决 infobox 中 tabber 的溢出问题,实现方案合理。选择器的特异性适中,不会造成样式污染。

src/ConsolePrintWordartLogo/definition.json Show resolved Hide resolved
Comment on lines 6 to 10
(async function () {
const consoleTUrl = `${mw.config.get('wgServer')}/api.php?action=query&meta=siteinfo&formatversion=2&format=json`;
const generatordata = await fetch(consoleTUrl);
const generatordataJson = (await generatordata.json()) as unknown;
const mideawikiVersions = (generatordataJson as {query: {general: {generator: string}}}).query.general.generator;
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

需要增加错误处理和类型安全

当前实现存在以下问题:

  1. API 调用缺少错误处理
  2. 类型断言不安全
  3. 没有加载状态处理

建议按如下方式修改:

 (async function () {
+  try {
     const consoleTUrl = `${mw.config.get('wgServer')}/api.php?action=query&meta=siteinfo&formatversion=2&format=json`;
     const generatordata = await fetch(consoleTUrl);
+    if (!generatordata.ok) {
+      throw new Error(`API 请求失败: ${generatordata.status}`);
+    }
     const generatordataJson = (await generatordata.json()) as unknown;
-    const mideawikiVersions = (generatordataJson as {query: {general: {generator: string}}}).query.general.generator;
+    interface SiteInfo {
+      query: {
+        general: {
+          generator: string;
+        };
+      };
+    }
+    if (!isSiteInfo(generatordataJson)) {
+      throw new Error('API 响应格式错误');
+    }
+    const mideawikiVersions = generatordataJson.query.general.generator;
+  } catch (error) {
+    console.error('打印标志时发生错误:', error);
+    return;
+  }

Committable suggestion skipped: line range outside the PR's diff.

@ajdgg ajdgg closed this Nov 13, 2024
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.

3 participants