Skip to content

perf: Optimize some style issues - #7887

Merged
wangdan-fit2cloud merged 1 commit into
v2from
pr@v2@feat_style
Nov 13, 2026
Merged

wangdan-fit2cloud merged 1 commit into
v2from
pr@v2@feat_style

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

perf: Optimize some style issues

Comment thread ui/vite.config.ts
createHtmlPlugin({ template: ENV.VITE_ENTRY }),
renameHtmlPlugin(`dist${ENV.VITE_BASE_PATH}`, ENV.VITE_ENTRY),
],
server: {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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: false if 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, '/') : p

3. 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 ignores conf.command; typing param as any loses type safety. Use ConfigEnv from vite.
  • proxyConf typed as Record<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.

})
})

/**

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Here are my findings:

Potential Issues

  1. Return type inconsistency in to_rule

    • The function sometimes returns an object (from spread) and sometimes the original rule. If rule could be undefined or non-object, { ...rule } spreads nothing. Consider guarding input type.
  2. computed return 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.rules present → returns an array
      • absent → returns a single object
    • If the consumer expects an array consistently (e.g., passed to Ant Design's rules prop which accepts array or single), this is fine for antd but fragile elsewhere. Safer to wrap fallback in [...].
  3. Order of conditions in to_rule

    • The new required branch executes after the validator branch. Since validator branch returns early, that's correct. But the new branch overwrites any existing type/whitespace on the incoming rule without checking. If rule.type was already set (e.g. string), it will be overwritten. Prefer merging only when unset:
      return { type: 'string', whitespace: true, ...rule }
      so caller-supplied overrides win.
  4. Missing null-check on props.formfield

    • Accessing props.formfield.input_type assumes formfield is defined. Elsewhere it's also accessed, so probably safe, but worth verifying.
  5. whitespace: true semantics

    • 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.
  6. TextareaInput whitespace

    • Multi-line textareas legitimately receive blank lines; whitespace: true will reject purely-whitespace content. Usually desired for "required", but confirm UX.
  7. includes on possibly undefined input_type

    • ['...'].includes(undefined) returns false, so safe. Fine.
  8. Recomputing component_validator reference

    • 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 every to_rule call.
  • Consider ordering merged props to let explicit rule values take precedence:
    return { type: 'string', whitespace: true, ...rule, required: rule.required }
    Note spreading rule after 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 PasswordInput with required: true gets { type: 'string', whitespace: true } and that a custom validator still 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 {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Code Review: SCSS Button Style Changes

Summary of Changes

The diff refactors .is-link styles by:

  1. Moving border: none from the :focus variant to the base .is-link selector.
  2. Nesting &:focus inside .is-link.
  3. Removing the &.is-link:not(.is-disabled):hover rule 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-link blocks 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.

@wangdan-fit2cloud
wangdan-fit2cloud merged commit cf72476 into v2 Nov 13, 2026
4 of 5 checks passed
@wangdan-fit2cloud
wangdan-fit2cloud deleted the pr@v2@feat_style branch November 13, 2026 04:16
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