Skip to content

fix: Front end loading sequence - #7952

Merged
shaohuzhang1 merged 1 commit into
v3from
pr@v3@fix_ui
Nov 16, 2026
Merged

shaohuzhang1 merged 1 commit into
v3from
pr@v3@fix_ui

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

fix: Front end loading sequence

Comment thread ui/src/main.ts
import router from '@/router/admin'
import { pinia, useStore } from '@/stores/admin'
import '@/styles/tailwind.css'
import '@/styles/index.scss'

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.

The change moves import router from '@/router/admin' earlier. Assessment:

  1. Circular dependency risk (high concern). The added comment claims the reorder breaks a cycle, but importing router earlier generally makes the cycle worse, not better: if router/admin imports permission (or resource-context, which imports router), then evaluating router first can mean its top-level perm read happens before permission has initialized — exactly the failure the comment describes. The comment's reasoning appears self-contradictory and should be verified with a real circular-dependency tool (madge, dpdm) rather than trusted.

  2. Fragile import ordering. Relying on ES module evaluation order to fix an init bug is brittle. Imports are hoisted and evaluated depth-first per spec; comments ("勿移动"/do not move) won't enforce this in future refactors, lint autofix, or bundler deduplication. Prefer a structural fix:

    • Break the cycle properly (lazy access via getter/function, e.g. read perm inside a guard hook rather than at module top level).
    • Or inject dependencies explicitly instead of module-level singletons.
  3. Comment quality. It mixes English and Chinese in a codebase commit hunk; ensure it matches project convention. It also asserts a causal claim that is unverified. If kept, reference the issue/ticket number.

  4. No other irregularities in the diff itself: unused imports? All still used. pinia, useStore grouping unchanged. No side-effect ordering issue for CSS (CSS imports at the end are fine for Vitest/build but note some bundlers require CSS imports before component usage — unrelated here).

  5. Optimization suggestion: add an ESLint rule (import/order with pathGroups) to encode intended ordering explicitly, so intent is enforced by tooling rather than comments. Consider dynamic import() or a factory function for router to genuinely eliminate the cycle.

Verdict: Functional correctness is uncertain; the comment's rationale looks backwards. Recommend verifying the dependency graph and solving the cycle structurally instead of via import order.

@shaohuzhang1
shaohuzhang1 merged commit 2d40226 into v3 Nov 16, 2026
3 of 4 checks passed
@shaohuzhang1
shaohuzhang1 deleted the pr@v3@fix_ui branch November 16, 2026 12:29
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.

1 participant