Repository navigation
revert: locales - #7948
revert: locales#7948
Conversation
| <el-button type="primary" @click="submitEdit">保存</el-button> | ||
| </template> | ||
| </MkDialog> | ||
| </template> |
There was a problem hiding this comment.
Review
The diff removes all vue-i18n usage and hardcodes Chinese strings. That is the main "irregularity" — everything else is minor.
Issues
1. Hardcoded Chinese strings (regression)
- Every
t(...)call was replaced with a literal Chinese string. This breaks internationalization entirely. If the project supports multiple languages, this is a functional regression. - Suggestion: if the change is intentional (e.g., a temporary demo), at least keep the keys in a central constants file so they can be re-localized later.
2. Removed confirm-button customization in handleDelete
- Before:
MsgConfirm(t('common.titles.notice'), t('dynamicForm.tree.deleteConfirm', { label: node.label }), { type: 'warning', cancelButtonText: t('common.actions.cancel'), confirmButtonText: t('common.actions.delete'), })
- After:
MsgConfirm('提示', `确定删除「${node.label}」吗?`, { type: 'warning' })
cancelButtonText/confirmButtonTextare now default values. This is a behavior change (localized buttons → default labels). Also, using template literals with user-providednode.labelis fine here because it goes to a dialog, but be awareMsgConfirmshould escape HTML if it renders viav-html.
3. String interpolation risk
`确定删除「${node.label}」吗?`— ifMsgConfirmever renders content as HTML,node.labelbecomes an XSS vector. Prefer concatenating via a safe helper or ensure the message component escapes text. (Previously the i18n substitution also had this consideration, but worth verifying.)
4. blur: 'change' in the rules object
-
:rules="[{ required: true, message: '请添加选项', blur: 'change', type: 'array', min: 1 }]"
blur: 'change'is not a valid rule option (looks like a merge artifact oftrigger: 'blur'andtrigger: 'change'). Element Plus ignores unknown keys, but it's dead code → remove it or usetrigger: ['blur', 'change'].
5. Formatting
- The rules line was collapsed into a long single line, making it harder to read and review. Keep one attribute per line for readability (or run the formatter).
6. el-checkbox :label= semantics
- In Element Plus 2.6+,
labelis deprecated as the value/display prop; usevaluefor the bound value and put display text as slot content. Current usage (label="允许多选"without:value) relies on legacy behavior and may warn or break on upgrade:(Verify against the Element Plus version pinned in the project.)<el-checkbox v-model="formValue.multiple" value="multiple">允许多选</el-checkbox>
7. Lost context in error messaging
- Replacing
t('common.messages.saved')with'保存成功'etc. is fine, but the generic'未找到父节点'loses the specific component context previously provided by the i18n key namespace. Minor.
8. No optimization concerns
- Removing
useI18nactually slightly reduces reactive overhead (twas called inside template/rules). But that gain is negligible and not worth the i18n loss.
Summary
| Severity | Issue |
|---|---|
| High | All i18n removed → localization broken |
| Medium | Delete-confirm button texts no longer customized/localized |
| Medium | blur: 'change' invalid rule option |
| Low | Potential interpolation/XSS in confirm message |
| Low | el-checkbox :label deprecation |
| Nit | Overly long :rules line hurts readability |
If the goal is truly to drop i18n, this diff is acceptable functionally — just fix item #4 and #6, and decide deliberately about #2.
| 删除 | ||
| </MkDropdownItem> | ||
| </MkTableMoreDropdown> | ||
| </div> |
There was a problem hiding this comment.
Issues & Suggestions
1. i18n removal breaks internationalization (highest priority)
The diff removes useI18n and replaces all t(...) calls with hardcoded Chinese strings. This is a regression if the app supports multiple locales:
searchFields,message contents, table column labels, filter labels, buttons, etc. are now untranslatable.- If this is intentional (single-language product), it's acceptable — but confirm it's deliberate and not an accidental revert.
2. modelTypeOptions lost reactivity
// Before: computed -> reactive
const modelTypeOptions = computed(() => ...)
// After: plain array evaluated once at setup
const modelTypeOptions = Object.entries(MODEL_TYPE_LABELS).map(...)If MODEL_TYPE_LABELS ever changes at runtime (or if labels were locale-dependent), the options won't update. When i18n is present, this must remain a computed. Even without i18n, prefer computed for consistency.
3. Removal of explicit confirm/cancel button text
// Removed: { cancelButtonText, confirmButtonText }Now relies on MsgConfirm's default button labels. Verify the defaults are correct/localized; otherwise users see wrong-language buttons.
4. MkViewLayout title removed
- <MkViewLayout :title="t('model.title')">
+ <MkViewLayout>The slot still receives { Header, title } and renders <h4>{{ title }}</h4>. Without :title, title may be empty/undefined. Confirm the layout falls back correctly (e.g., from route meta), otherwise the page header shows blank.
5. Null-coalescing / truthiness change
// Before
MODEL_TYPE_LABELS[row.model_type] ? t(...) : row.model_type
// After
MODEL_TYPE_LABELS[row.model_type] ?? row.model_typeBehavior differs only for falsy-but-present values (''). Old code fell back to row.model_type on empty string; new code does too via ??… actually '' is not nullish, so an empty-string label would now render blank instead of falling back. Minor, but note the semantic change.
6. Search field label hardcoded, but value: 'create_user' retained
The name search now searches by literal '模型名称' label while value is unchanged — fine, but double-check the backend column mapping (create_user vs create_username) is still correct.
7. Line-length / formatting
Several lines exceed typical lint limits after inlining (e.g., the MkTableFilter single-line usages, searchFields entries). Run the project formatter/linter — the previous multi-line formatting was likely enforced.
8. Unused imports / cleanups
- Confirm
MODEL_TYPE_LABELSimport is still needed (yes). - Confirm no other
t(references remain elsewhere in the file that now reference an undefinedt(would be a runtime error). The diff covers visible ones, but verify the whole file compiles.
9. Optimization (minor)
getProvider(row)is called twice per row (icon + name). Consider computing once.modelTypeOptionsrecomputation per render is avoided either way; keepingcomputedalso memoizes.
Recommendation
If i18n removal is intended, keep it but at minimum restore computed for modelTypeOptions, verify the layout title fallback, and double-check confirm dialog default buttons. If not intended, revert the i18n changes — they introduce a functional regression.
| <el-button type="primary" :loading="loading" @click="handleSubmit">保存</el-button> | ||
| </template> | ||
| </MkDrawer> | ||
| </template> |
There was a problem hiding this comment.
Review of the Diff
1. Internationalization (i18n) regression — most critical
The diff removes useI18n and replaces every t('...') with hardcoded Chinese strings.
- Issue: This breaks multi-language support entirely for this component. All other locales will now show Chinese.
- Also broken:
MODEL_TYPE_LABELSis now rendered as:label="label"instead of:label="t(label)". IfMODEL_TYPE_LABELScontains i18n keys (as the original code implies), the raw keys will now be displayed instead of translated labels. Verify whatMODEL_TYPE_LABELSactually contains. - Recommendation: Revert the i18n removal unless this is a deliberate, scoped decision. If the goal is to reduce bundle size / lazy-load locales, do it globally and consistently — not per-component.
2. Hardcoded strings reduce maintainability
Even if single-language is intended, hardcoding user-facing text in templates:
- Duplicates translations across components (e.g., "保存"/"取消" already exist as
common.actions.save/cancel). - Makes future changes and translation harder.
- Recommendation: Keep message strings centralized (constants or i18n), even for one language.
3. drawerTitle computed simplification
const drawerTitle = computed(() => `编辑 ${selectedProvider.value?.name ?? ''}`)- Minor: yields trailing space when provider name is empty ("编辑 "). Consider trimming or a fallback like
编辑模型. - Loses the
{ providerName }interpolation structure; acceptable if intentional, but again tied to the i18n removal.
4. Long lines / formatting
Several el-input, el-form-item, and el-select lines were collapsed into very long single lines (e.g., the el-input with v-model, maxlength, placeholder, @blur).
- Recommendation: Keep Prettier/ESLint line-wrapping consistent with the rest of the file. Re-run the formatter after edits.
5. Minor whitespace inconsistency
<span class="mk-required"> 模型名称</span>- There's a leading space inside the span (
> 模型名称). Other labels don't have this. Remove for consistency. - Also
<span class="mk-required"> 模型名称vs<span class="mk-required">模型类型— inconsistent.
6. Behavioral concerns (unchanged, worth verifying)
These weren't changed by the diff but interact with the edited code:
MsgWarning(...)on builtin fallback fires every time builtin options load, even on first open. Confirm that's desired UX (it may warn unnecessarily).credentialSnapshot:applyBaseModelOptions(..., requestCredentialSnapshot, ...)uses a snapshot taken earlier; if credentials changed between fetch start and callback, the guard may wrongly accept stale results. EnsurerequestCredentialSnapshotis captured immediately before each request.handleSubmit: no client-side validation call (formRef.validate()); relies on Element Plus rules only via template. IfhandleSubmitcan be triggered before blur/validation, invalid data may submit. Consider explicitly validating the form ref.watch/nextTickimports: verify all remain used after the edits (reactive,ref,computed,watch,nextTick). Unused imports should be removed to satisfy lint.
7. Tooltip content expansion
The model-type tooltip grew from 9 short lines to 9 long paragraphs. Consider extracting these descriptions to constants/i18n rather than inline template text — improves readability and reuse.
Summary of priority
| Priority | Item |
|---|---|
| 🔴 High | i18n removal + broken MODEL_TYPE_LABELS translation |
| 🟠 Medium | Hardcoded strings / maintainability |
| 🟡 Low | Long lines, spacing inconsistencies, empty-provider title |
| 🟡 Low | Verify validation on submit & stale credential snapshot |
If the intent was not to drop multilingual support, this diff should be reverted and reapplied without touching t(...) calls.
revert: locales