Repository navigation
perf: Optimize some style issues - #7887
Conversation
| createHtmlPlugin({ template: ENV.VITE_ENTRY }), | ||
| renameHtmlPlugin(`dist${ENV.VITE_BASE_PATH}`, ENV.VITE_ENTRY), | ||
| ], | ||
| server: { |
There was a problem hiding this comment.
Here's my review of the diff:
Issues & Concerns
1. Hardcoded external proxy targets (⚠️ Most significant)
The change from http://127.0.0.1:8080 to https://mk-ee.fit2cloud.cn hardcodes a remote production/staging server into dev proxy config.
Problems:
- Developers will silently hit a shared remote backend during local dev → side effects on shared data, confusing debugging.
- No way to switch per environment. Should read from env instead:
proxyConf['/admin/api'] = { target: ENV.VITE_PROXY_TARGET ?? 'http://127.0.0.1:8080', changeOrigin: true, // enable if target uses self-signed cert secure: false, }
- Since the new target is HTTPS, you may need
secure: falseif it uses an internal/self-signed certificate, otherwise Vite will reject the TLS handshake.
2. Unnecessary /doc rewrite safety check
The /doc rewrite uses ENV.VITE_BASE_PATH — if that's empty it becomes '', and path.replace('', '/') returns / + original path, corrupting routes. Guard it:
rewrite: (p) => ENV.VITE_BASE_PATH ? p.replace(ENV.VITE_BASE_PATH, '/') : p3. Formatting-only changes are noisy
Most hunks (import { fileURLToPath, URL }, etc.) are pure whitespace/prettier formatting mixed with the functional change. Consider committing formatting separately (e.g., run Prettier once in its own commit) to keep the diff focused and reviewable via git blame.
4. Minor pre-existing observations
mode/conf: any— the config callback ignoresconf.command; typing param asanyloses type safety. UseConfigEnvfrom vite.proxyConftyped asRecord<string, string | ProxyOptions>— values are always objects here;Record<string, ProxyOptions>is more precise.- Trailing commas / no semicolons look fine but ensure project lint matches the reformatted style.
Recommendation
Revert the localhost→remote proxy change, or gate it behind an env variable (e.g., VITE_PROXY_TARGET), and add secure: false for the HTTPS case. Keep formatting changes in a separate commit.
| }) | ||
| }) | ||
|
|
||
| /** |
There was a problem hiding this comment.
Here are my findings:
Potential Issues
-
Return type inconsistency in
to_rule- The function sometimes returns an object (from spread) and sometimes the original
rule. Ifrulecould beundefinedor non-object,{ ...rule }spreads nothing. Consider guarding input type.
- The function sometimes returns an object (from spread) and sometimes the original
-
computedreturn shape mismatch- Before: fallback was an object
{ message, trigger, required }. - After: fallback is wrapped with
to_rule(...)returning an object too — consistent. But note upstream consumers (rules.map(to_rule)returns an array) now differ:props_info.value.rulespresent → returns an array- absent → returns a single object
- If the consumer expects an array consistently (e.g., passed to Ant Design's
rulesprop which accepts array or single), this is fine for antd but fragile elsewhere. Safer to wrap fallback in[...].
- Before: fallback was an object
-
Order of conditions in
to_rule- The new
requiredbranch executes after thevalidatorbranch. Sincevalidatorbranch returns early, that's correct. But the new branch overwrites any existingtype/whitespaceon the incoming rule without checking. Ifrule.typewas already set (e.g. string), it will be overwritten. Prefer merging only when unset:so caller-supplied overrides win.return { type: 'string', whitespace: true, ...rule }
- The new
-
Missing null-check on
props.formfield- Accessing
props.formfield.input_typeassumesformfieldis defined. Elsewhere it's also accessed, so probably safe, but worth verifying.
- Accessing
-
whitespace: truesemantics- For
PasswordInput, rejecting whitespace-only passwords may be intentional, but be aware some validators treat whitespace differently. Confirm product requirement — passwords with trailing spaces would now fail.
- For
-
TextareaInputwhitespace- Multi-line textareas legitimately receive blank lines;
whitespace: truewill reject purely-whitespace content. Usually desired for "required", but confirm UX.
- Multi-line textareas legitimately receive blank lines;
-
includeson possibly undefinedinput_type['...'].includes(undefined)returnsfalse, so safe. Fine.
-
Recomputing
component_validatorreference- Same as before; no change introduced.
Optimization / Style Suggestions
- Extract the list of input types to a module-level constant (
const WHITESPACE_CHECKED_INPUTS = [...]) to avoid recreating the array on everyto_rulecall. - Consider ordering merged props to let explicit rule values take precedence:
Note spreading
return { type: 'string', whitespace: true, ...rule, required: rule.required }
ruleafter resets nothing but keeps user intent separate from enforced defaults. - Ensure fallback wraps in array for consistency:
: [to_rule({ message: errMsg.value, trigger: ..., required: ... })]
- Add a unit test asserting that a
PasswordInputwithrequired: truegets{ type: 'string', whitespace: true }and that a customvalidatorstill takes priority (it does, due to the early return). - The
@@ -143,6 +143,12 @@header looks like a diff annotation pasted into source — verify it isn't accidentally committed into actual code.
| } | ||
| } | ||
| } | ||
| .el-button--text { |
There was a problem hiding this comment.
Code Review: SCSS Button Style Changes
Summary of Changes
The diff refactors .is-link styles by:
- Moving
border: nonefrom the:focusvariant to the base.is-linkselector. - Nesting
&:focusinside.is-link. - Removing the
&.is-link:not(.is-disabled):hoverrule entirely.
Issues & Concerns
🔴 1. Unintentional Removal of Hover Style (likely a bug)
- &.is-link:not(.is-disabled):hover {
- color: var(--el-color-primary);
- }This hover rule is deleted with no replacement. If this was meant to be refactored rather than removed, link buttons will lose their primary-color hover feedback. This is likely an accidental deletion. Verify whether hover styling is now handled elsewhere; if not, restore it (e.g., nested under .is-link).
🟡 2. border: none Now Applied to All States
Previously border: none only applied on :focus. Now it applies to all .is-link states including hover/active/disabled. Usually desirable for link buttons, but confirm it doesn't override a needed border on :active or disabled states defined in other rules.
🟡 3. Redundant Declarations in :focus
&:focus {
background: none;
border: none; // redundant — already set on .is-link parent
}Since border: none is inherited from the parent .is-link block, redeclaring it in :focus is redundant. Can be removed.
🟢 4. Use of !important (pre-existing)
outline: none !important;Not introduced here, but !important on outline harms accessibility (removes visible focus indicator). Consider using a custom visible focus style instead for keyboard users.
🟢 5. Stylelint Max-Nesting-Depth
Moving :focus inside .is-link increases nesting depth. Typically fine, but check your project's linter config (max-nesting-depth) and CSS specificity budget.
Suggested Refactor
&.is-link {
border: none;
&:focus {
background: none;
}
&:not(.is-disabled):hover {
color: var(--el-color-primary); // restored
}
}Optimization Notes
- Consolidate the split
.is-linkblocks into one block (currently scattered) to reduce selector duplication. - Prefer logical properties / minimal nesting where specificty allows.
- Confirm the removal of the hover rule was intentional and documented in the commit message.
perf: Optimize some style issues