Repository navigation
fix: format bug - #7953
fix: format bug#7953shaohuzhang1 wants to merge 1 commit into
Conversation
| /> | ||
| </template> | ||
| </ModelCard> | ||
| </template> |
There was a problem hiding this comment.
Review
Potential issues
-
DEFAULT_MODEL_PROVIDERstill hard-codes a Chinese string (name: '全部模型'). Since the PR is i18n-izing provider names viacurrentProviderName, this default should ideally be updated too — otherwise any consumer that rendersprovider.namedirectly (e.g.,ModelProvideraside, or other code paths) will still show Chinese text. -
currentProviderNamedepends ont()inside acomputed. This works, but if the user changes locale at runtime, the computed will re-evaluate only if the underlying reactive dependency changes.useI18n().tfromvue-i18nis generally reactive to locale changes when accessed ast(...)insidecomputedin Composition API mode — but verify this holds for your setup (withlegacy: false). If usingtc/$tpatterns elsewhere, ensure consistency. -
Repeated ternaries in
currentProviderNameare getting unwieldy. Consider mapping:const PROVIDER_NAME_KEYS: Record<string, string> = { all: 'model.providers.all', shared: 'model.providers.shared', } const currentProviderName = computed(() => { const key = PROVIDER_NAME_KEYS[currentProvider.value.provider] return key ? t(key) : currentProvider.value.name })
-
searchFieldsname collision risk: fieldlabels are now translated, but there is no guarantee consumers don't match on labels for filtering/logic. Worth confirmingMkComplexSearchusesvalue(notlabel) internally for identity — the diff already keepsvalue, so this looks safe. -
Unused import check:
MODEL_TYPE_LABELSwas removed andMODEL_TYPE_MESSAGE_KEYSadded. Confirm:- The new file
./model-type-labelsactually exportsMODEL_TYPE_MESSAGE_KEYS. MODEL_TYPE_LABELSisn't used anywhere else in this file (looks clean, but verify across the repo).- Any other consumers of
MODEL_TYPE_LABELSfrom@/constantshaven't broken (only the constant itself removed here).
- The new file
-
Inconsistent i18n key prefixes in search fields: you use
common.fields.creator.labelhere, while model-specific fields usemodel.fields.*. Just make surecommon.fields.creatoris indeed a real shared key; otherwise usemodel.fields.creator.label. -
t('resource.authorization.title')andt('resource.relations.title')mix naming conventions (titlevs others using.label/ actions namespaces). Ensure these keys exist and align with whatever convention the resource module uses. -
MkViewLayout :title="t('model.title')"is static — fine, but if the layout renders a title in locales where changing language dynamically should reflect, consider making itcomputed. Minor.
Optimization suggestions
- Extract the provider-name ternary into a small helper or map (see [FEATURE]增加首次进入系统强制修改用户密码功能。 #3).
- Consider a shared composable/utility for "translate or fallback to
name" pattern if used elsewhere. - Since
currentProviderNamereturns either a translated label or a user-facing provider name, document that it may not be fully localizable for custom providers — that's expected. - If
MODEL_TYPE_MESSAGE_KEYSis static, hoist the derived options:Then only map toconst MODEL_TYPE_OPTIONS = Object.entries(MODEL_TYPE_MESSAGE_KEYS) .map(([value, key]) => ({ value, key }))
{ label: t(key), value }inside thecomputedso thetcalls remain locale-reactive.
Overall
Changes look correct and consistent with the goal of i18n-izing the component. Main action items: update DEFAULT_MODEL_PROVIDER.name, verify the new translation keys and MODEL_TYPE_MESSAGE_KEYS export exist, and simplify the provider-name ternaries.
| :placeholder="t('auth.fields.confirmPassword.placeholder')" | ||
| show-password | ||
| type="password" | ||
| /> |
There was a problem hiding this comment.
Here are my observations on this diff:
Potential Issues
-
Inconsistent i18n key namespaces (likely a bug).
The refactor intends to standardize keys underauth.fields.*, but two keys were changed to a different, inconsistent namespace:t('auth.forgotPassword.password.lengthMessage')— notepasswordis not nested underfields. Compare with other password rules that useauth.fields.password.requiredMessage.t('auth.forgotPassword.password.placeholder')in the template — same inconsistency; should likely beauth.fields.password.placeholder.
Unless these keys intentionally exist elsewhere, they will render as raw key strings. Verify against the locale files.
-
undefinedvsnullforvalidateState. You removed code that relied onfield.validateState === 'error', so this is now moot, but if you re-add locale-reactive validation later, prefer checkingfield.validateMessageor using a state enum to avoid magic strings. -
Removal of locale
watch— behavior regression.
Previously, switching language while errors were visible re-validated those fields so messages updated immediately. After this change, stale error messages persist in the old language until the user blurs/edits the field. If that UX was intentional (e.g., "keep input, only refresh shown errors"), silently dropping it may be unwanted. Consider documenting the removal or keep it behind a feature flag. -
Rule whitelist / tolerance.
emailrule useswhitespace: true+type: 'email'but nomaxlength; extremely long emails still hit the backend. Consider adding a length bound similar to password.
Optimization Suggestions
-
Avoid recreating
FormRuleson every render.forgotPasswordRulesis acomputed, good — but since the messages come fromt()(reactive only to locale), ensuretis reactive in your setup. This is fine, but considerObject.freeze-style memoization if rule objects grow. -
Consolidate duplicated
t(...)calls inside validators.validateConfirmPasswordcallst(...)each invocation; cache the two messages via computed once and reuse, reducing per-keystroke cost onblur. -
Interval cleanup check. You didn't show full
startCountdown, but confirmcountdownTimeris cleared inonBeforeUnmountand when the component unmounts mid-countdown;setIntervalleaking into a destroyed route causes warnings and wasted ticks. -
isSendCodeDisabledcomputed reading.trim()on every keystroke is negligible but consider debouncing send-button disable state only if email input grows large — usually unnecessary. -
Type safety.
validateConfirmPassword's callback is typed manually; consider using Element Plus's exportedFormItemRulevalidator type instead of ad-hoc(error?: Error) => voidto stay compatible with future versions. -
Key naming convention. Maintain a single source of truth (e.g.,
auth.fields.*) and add a CI check (script scanningt('...')strings against locale JSON) to avoid the kind of divergence seen in point build(deps): bump the pip group across 1 directory with 2 updates #1.
Summary
The main actionable concern is the i18n key inconsistency (auth.forgotPassword.password.* vs auth.fields.password.*) which is very likely a copy-paste mistake. Second is the intentional-but-undocumented removal of locale-reactive revalidation. Everything else is minor.
| permission: () => perm.application.system.chatLogRead(), | ||
| next: 'system-resource-application-access', | ||
| }, | ||
| }, |
There was a problem hiding this comment.
Here are my findings on the diff:
Potential Issues / Irregularities
-
nextpointing to a sibling instead of the next tab (likely bug)- In
system-resource-application-access,next: 'system-resource-application-access'points to itself. This will cause an infinite/self-loop when navigating forward, or point nowhere meaningful. - In
chat-userandoperation-log,next: 'system-resource-application-access'points backward to access. Given orders 30 → 40 → 50,nextfor chat-user should probably besystem-resource-application-operation-log, and operation-log'snextshould beundefined(last tab) or removed. - Fix suggestion: Set
access.next→chat-user,chat-user.next→operation-log, and remove/omitnexton the last item.
- In
-
permissionchanged from a value to a thunk — verify the contract- Changing
perm.application.system.overviewRead(a value) to() => perm.application.system.overviewRead()(a function). This is only correct if the field was originally a lazy getter and the route consumer invokes permission functions. If the consumer expects a boolean/value, passing a function will make it always truthy (permission effectively bypassed). Confirm the type ofmeta.permissioninRouteMetaand how it's evaluated (e.g.,typeof perm === 'function' ? perm() : perm).
- Changing
-
Whitespace/bracket alignment in
chat-user- The original had mismatched indentation (
next: ...not aligned). The new version fixes this — good. No functional issue, just confirm no accidental merging occurred.
- The original had mismatched indentation (
Optimization / Consistency Suggestions
-
Consistency in
meta.activeMenuactiveMenu: '/system/resource/applications'was added only to the root detail route. Ensure the child routes inherit expected menu highlighting; children typically don't need their ownactiveMenuif they share the parent layout. Verify the highlighting works for deep links (e.g., directly opening/access).
-
Repeated formatting
- All
metaobjects were reflowed multi-line. If a formatter (Prettier/eslint) is configured withprintWidth, some of these could remain single-line (e.g., the access meta line). Consider running formatter to avoid unnecessary churn in future diffs.
- All
-
Magic strings for route names
next,redirect, andnamevalues are hardcoded strings repeated across files. Consider extracting route-name constants to prevent typos (the self-referencingnextis exactly the kind of bug constants + type-checking would catch).
-
Type safety
- Since
next,activeMenu,permission, anddetailMenuVisibleare customRouteMetafields, ensure they're declared in theRouteMetamodule augmentation (e.g.,vue-router'sRouteMetainterface) so TS catches invalid names/values.
- Since
Summary
The main bug is the incorrect next links (self-reference on access, backward references on later tabs). Also verify the permission thunk change is supported by the route evaluator — otherwise permissions become permissive. The rest are style/consistency improvements.
fix: format bug