Skip to content

revert: locales - #7948

Merged
fit2cloudwxx merged 1 commit into
v3from
pr@v3@revert_locales
Nov 16, 2026
Merged

fit2cloudwxx merged 1 commit into
v3from
pr@v3@revert_locales

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

revert: locales

<el-button type="primary" @click="submitEdit">保存</el-button>
</template>
</MkDialog>
</template>

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.

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 / confirmButtonText are now default values. This is a behavior change (localized buttons → default labels). Also, using template literals with user-provided node.label is fine here because it goes to a dialog, but be aware MsgConfirm should escape HTML if it renders via v-html.

3. String interpolation risk

  • `确定删除「${node.label}」吗?` — if MsgConfirm ever renders content as HTML, node.label becomes 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 of trigger: 'blur' and trigger: 'change'). Element Plus ignores unknown keys, but it's dead code → remove it or use trigger: ['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+, label is deprecated as the value/display prop; use value for 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:
    <el-checkbox v-model="formValue.multiple" value="multiple">允许多选</el-checkbox>
    (Verify against the Element Plus version pinned in the project.)

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 useI18n actually slightly reduces reactive overhead (t was 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>

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.

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_type

Behavior 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_LABELS import is still needed (yes).
  • Confirm no other t( references remain elsewhere in the file that now reference an undefined t (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.
  • modelTypeOptions recomputation per render is avoided either way; keeping computed also 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>

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.

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_LABELS is now rendered as :label="label" instead of :label="t(label)". If MODEL_TYPE_LABELS contains i18n keys (as the original code implies), the raw keys will now be displayed instead of translated labels. Verify what MODEL_TYPE_LABELS actually 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. Ensure requestCredentialSnapshot is captured immediately before each request.
  • handleSubmit: no client-side validation call (formRef.validate()); relies on Element Plus rules only via template. If handleSubmit can be triggered before blur/validation, invalid data may submit. Consider explicitly validating the form ref.
  • watch/nextTick imports: 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.

@fit2cloudwxx
fit2cloudwxx merged commit 930c8d4 into v3 Nov 16, 2026
3 of 4 checks passed
@fit2cloudwxx
fit2cloudwxx deleted the pr@v3@revert_locales branch November 16, 2026 11:09
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