Skip to content

fix: default psd to remind change - #8210

Merged
fit2cloudwxx merged 1 commit into
v3from
pr@v3@fix_ddefaultPsdToRemindChange
Nov 27, 2026
Merged

fit2cloudwxx merged 1 commit into
v3from
pr@v3@fix_ddefaultPsdToRemindChange

Conversation

@shaohuzhang1

@shaohuzhang1 shaohuzhang1 commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

【【系统用户】用户使用默认密码MaxKB@123..登录后 没有弹出修改密码对话框】
https://www.tapd.cn/tapd_fe/45245355/bug/detail/1145245355001080421

[() => user.userInfo?.is_edit_password, changePasswordDialogRef, () => route.meta.scope],
([isDefaultPassword]) => {
if (isDefaultPassword === true) handleOpenChangePassword()
},

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.

No syntax-level issues in the diff, but there are a few logic/UX and timing concerns.

Potential issues

  1. The dialog may be reopened or reset on every scope change

    • Adding () => route.meta.scope to the watch sources means the callback runs whenever route.meta.scope changes.
    • If is_edit_password === true, handleOpenChangePassword() is called even if the dialog is already open or the user has dismissed it.
    • If open() resets form state, this can overwrite user input. Make open() idempotent, or guard it with an isOpen check or a “already prompted” flag.
  2. Template ref timing / stale dialog instance risk

    • The watcher uses changePasswordDialogRef as a readiness trigger, but the callback does not explicitly check changePasswordDialogRef.value.
    • With the default flush: 'pre', route.meta.scope can change before the DOM/template ref is updated. This can cause a no-op call or, worse, an open() call on a stale instance during route transition.
    • Prefer flush: 'post' and explicitly check the ref.
  3. Scope trigger is broader than the comment suggests

    • The comment says “workspace / system management switch”, but route.meta.scope will trigger for any change in that value, including undefined or future scope values.
    • If only workspace/system scopes should trigger, use a computed predicate or watch specific route metadata.
  4. Possible double trigger during route transitions

    • Both route.meta.scope and changePasswordDialogRef can change during the same navigation. If open() is not idempotent, this can result in two open attempts.
  5. Type safety for route.meta.scope

    • If RouteMeta is not augmented with scope, TypeScript may complain or infer unknown.
    • Add a RouteMeta module augmentation or cast/narrow the value explicitly.

Suggested adjustment

watch(
  [
    () => user.userInfo?.is_edit_password,
    changePasswordDialogRef,
    () => route.meta.scope,
  ],
  ([isDefaultPassword]) => {
    if (isDefaultPassword === true && changePasswordDialogRef.value) {
      handleOpenChangePassword()
    }
  },
  { flush: 'post' },
)

And make handleOpenChangePassword() / the dialog’s open() safe to call repeatedly, e.g.:

function handleOpenChangePassword() {
  const dialog = changePasswordDialogRef.value
  if (!dialog || dialog.isOpen) return
  dialog.open()
}

Minor optimization

If the intended behavior is only “prompt once after login or once per session”, track a flag such as hasPromptedDefaultPassword instead of relying on scope changes. Otherwise, switching between workspace/system management while the default password remains unchanged will keep reopening the dialog.

@fit2cloudwxx
fit2cloudwxx merged commit abcf9c0 into v3 Nov 27, 2026
3 of 4 checks passed
@fit2cloudwxx
fit2cloudwxx deleted the pr@v3@fix_ddefaultPsdToRemindChange branch November 27, 2026 10:24
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