{"record":{"id":"b18cb81c7fb284dd","repo":"jeecgboot/JeecgBoot","slug":"token-b18cb8","errorCode":null,"errorMessage":"token不存在~","messagePattern":"token不存在~","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"jeecgboot-vue3/src/views/super/online/cgform/auto/default/OnlineFormUrlDetail.vue","lineNumber":44,"sourceCode":"  // OnlineForm 这个必须引用，setup模式必须在template里面使用。否则url进入会报错\n  import OnlineForm from '../comp/OnlineForm.vue';\n  import { useMessage } from '/@/hooks/web/useMessage';\n  import { useRoute } from 'vue-router';\n  import OnlineDetailModal from './OnlineDetailModal.vue';\n  import { useOnlineTableContext } from '../../hooks/auto/useOnlineTableContext';\n  import { useListButton } from '../../hooks/auto/useListButton';\n  import { useEnhance } from '../../hooks/auto/useEnhance';\n  import { useFormUrl } from '../../hooks/auto/useFormUrl';\n  const route = useRoute();\n  const { ID, onlineTableContext, onlineExtConfigJson } = useOnlineTableContext();\n  const { createMessage: $message } = useMessage();\n  const wrapRef = ref(null);\n  const contentHeight = ref(400);\n  const loading = ref(true);\n\n  const { token } = useFormUrl();\n  if (!unref(token)) {\n    throw new Error('token不存在~');\n  }\n  if (!ID.value || !route.params.dataId) {\n    $message.warning('地址错误, 配置ID不存在!');\n    throw new Error('地址错误, 配置ID不存在!');\n  }\n  watch(\n    () => wrapRef.value,\n    (elem: HTMLElement) => {\n      // 获取页面实际高度\n      contentHeight.value = elem.offsetHeight;\n    }\n  );\n  // 处理增强\n  let { initCgEnhanceJs } = useEnhance(onlineTableContext);\n  // 处理列表button\n  const { registerDetailModal, openDetailModal } = useListButton(onlineTableContext, onlineExtConfigJson);\n  const getContainer = (node) => {\n    return document.querySelector(`.online-detail-${ID.value}`);","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/jeecgboot/JeecgBoot/blob/96fb33f5ec68516da0b0147da06b2eb0419e063a/jeecgboot-vue3/src/views/super/online/cgform/auto/default/OnlineFormUrlDetail.vue#L26-L62","documentation":"Setup guard in the URL-style online Detail form — identical contract to the Add form's token guard. Throws if `token` is still falsy after `useFormUrl()` resolves, halting render because detail-data API calls need a bearer token.","triggerScenarios":"Opening the detail URL without `?token=` while not logged in (empty `userStore.getToken`); the async token fetch in `useFormUrl` hasn't completed so the synchronous guard throws.","commonSituations":"Shared detail link without a token; session expired; incognito window; SSO redirect loop left the user store empty.","solutions":["Log in to the platform first, then reopen the detail form.","Append a valid `?token=<jwt>` to the detail URL for external use.","Ensure the login/SSO flow sets the token before the detail route mounts.","For embedding, mint a long-lived form token server-side and pass it in the URL."],"exampleFix":"// before\nconst { token } = useFormUrl();\nif (!unref(token)) { throw new Error('token不存在~'); }\n\n// after — redirect to login preserving the return path\nif (!unref(token)) {\n  router.replace({ path: '/user/login', query: { redirect: route.fullPath } });\n  return;\n}","handlingStrategy":"validation","validationCode":"// confirm token presence before relying on it\nconst { token } = useFormUrl();\nif (!unref(token)) {\n  router.replace({ path: '/user/login', query: { redirect: route.fullPath } });\n  return;\n}","typeGuard":"const hasToken = (t: unknown): t is string => typeof t === 'string' && t.length > 0;","tryCatchPattern":null,"preventionTips":["Include `?token=` on externally shared detail links.","Ensure login/SSO sets userStore.getToken before detail routes mount.","Guard url-detail routes for token presence.","Avoid the demo-token fetch path in production."],"tags":["vue3","online-cgform","auth","token","setup-guard","url-form","detail","typescript"],"backgroundTag":null,"analyzedSha":"96fb33f5ec68516da0b0147da06b2eb0419e063a","analyzedAt":"2026-08-14T00:04:16.786Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}