Repository navigation
fix: Dialogue Routing Handling #7827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,12 @@ const applicationRoutes: RouteRecordRaw[] = [ | |
| name: 'chat-login', | ||
| component: () => import('@/views/chat/login/index.vue'), | ||
| meta: { title: '登录' }, | ||
| }, | ||
| { | ||
| path: '/:accessToken', | ||
| redirect: (to) => { | ||
| return `/${to.params.accessToken}/` | ||
| }, | ||
| }, | ||
| { | ||
| path: '/:accessToken/', | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Code Review FindingsPotential Issues
Summary Suggestion{
path: '/:accessToken(\\w+)',
redirect: (to) =>
`/${encodeURIComponent(to.params.accessToken as string)}/`,
},Place it after all static top-level routes, and confirm router |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,12 +50,17 @@ const chatBasePath = CHAT_API_BASE_PATH.replace(/\/api$/, '') | |
|
|
||
| const apiDocUrl = new URL(`${CHAT_API_BASE_PATH}-doc/`, window.location.origin).href | ||
| const apiQuery=computed(()=>{ | ||
| return application.value?.work_flow?.nodes?.find(n=>n.id==='base-node')?.properties?.api_input_field_list.map((f:any)=>{ | ||
| const query=application.value?.work_flow?.nodes?.find(n=>n.id==='base-node')?.properties?.api_input_field_list.map((f:any)=>{ | ||
| return `${f.variable}=${f.default_value}` | ||
| }).join('&') | ||
| if(query){ | ||
| return '?'+query | ||
| } | ||
| return '' | ||
|
|
||
| }) | ||
| // TODO:访问链接还有问题 | ||
| const accessUrl = computed(() => (accessToken.value ? `${window.location.origin}${chatBasePath}/${accessToken.value}?${apiQuery.value}` : '')) | ||
| const accessUrl = computed(() => (accessToken.value ? `${window.location.origin}${chatBasePath}/${accessToken.value}/${apiQuery.value}` : '')) | ||
|
|
||
| function toUrl(url?: string) { | ||
| if (!url) return | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Code ReviewIssues1. URL path bug (line ~63) — the actual problem`${...}/${accessToken.value}/${apiQuery.value}`You changed The Fix: revert to concatenation without an extra slash: const accessUrl = computed(() =>
accessToken.value
? `${window.location.origin}${chatBasePath}/${accessToken.value}${apiQuery.value}`
: ''
)Also, the trailing const suffix = apiQuery.value || ''2. Missing optional chaining on
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The primary issue is that
strictis not a valid configuration option for thecreateRouter()function in Vue Router 4.Analysis
createRouter({ ..., strict: true, ... })createRouteraccepts a configuration object with keys likehistory,routes,scrollBehavior, etc. It does not acceptstrict. This property will simply be ignored by the router instance creation logic but may cause confusion, TypeScript errors (if types are strict), or linting issues./chat/aboutand/chat/about/are treated as different routes) or ensure exact route matching.Solutions
Option 1: Use
createWebHistorywith strict trailing slash handling (Recommended if supported)In recent versions of Vue Router, you can pass options to
createWebHistory. Check if your version supportsstrictinside the history creator:Note: Verify your specific Vue Router version. If
{ strict: true }isn't supported increateWebHistory, use Option 2 or 3.Option 2: Handle it in Route Definitions (Exact Match)
If you want only one canonical path (e.g., no trailing slashes), normalize paths in
chatRoutesor add a redirect/catch-all rule. This is more explicit but verbose.Option 3: Use
router.beforeEachfor NormalizationTo enforce "strict" behavior where extra trailing slashes are redirected or rejected:
Other Observations
LOGIN_ROUTE_NAMES: Defined but unused in the provided snippet. Ensure it’s used elsewhere (likely in navigation guards).window.MaxKB?.prefix || import.meta.env.VITE_BASE_PATH || '/chat/'is robust for build-time vs runtime config. Keep it.strict: trueproperty may cause a type error since it’s not part ofRouterOptions.Corrected Code (Safest Fix – Remove Invalid Property)
Unless you have a specific reason to keep
strict(and verified it’s supported in your Vue Router version viacreateWebHistoryoptions), remove it fromcreateRouter: