-
Notifications
You must be signed in to change notification settings - Fork 3
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
Conversation
Walkthrough此次更改包括在 Changes
Possibly related PRs
Suggested reviewers
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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 = ` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"mediawiki", "ascii"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已更改
建议不要把本地开发环境里的东西全作为PR提交。另开一个干净的branch、确认打算放进PR的内容与标题相关再申请合并。 |
There was a problem hiding this 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
权限才能使用此功能。考虑到这是一个显示用户头像的功能,建议重新评估是否真的需要编辑权限。建议考虑:
- 是否应该允许所有已登录用户使用此功能
- 是否需要创建更细粒度的权限控制
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 艺术字符串的处理方式
- 变量名
ascll
拼写错误,应为ascii
- 建议将大型 ASCII 艺术字符串移至单独的文件中
建议创建单独的资源文件:
- 创建
ascii-template.ts
:export const ASCII_LOGO_TEMPLATE = ` ██╗ ██╗ ██████╗ ██╗ ██╗██╗ ██╗ // ... 其余 ASCII 艺术内容 `;
- 在主文件中导入并使用:
- 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
⛔ 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 的溢出问题,实现方案合理。选择器的特异性适中,不会造成样式污染。
(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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
需要增加错误处理和类型安全
当前实现存在以下问题:
- API 调用缺少错误处理
- 类型断言不安全
- 没有加载状态处理
建议按如下方式修改:
(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.
Summary by CodeRabbit
新功能
NavbarAvatar
功能的配置,默认启用,允许具有编辑权限的用户在导航栏中查看用户头像。样式
文档