jeecgboot/JeecgBoot · error · Error
token不存在~
Error message
token不存在~
What it means
Setup guard in the URL-style online Edit form — identical contract to the Add/Detail token guard. Throws if `token` is falsy after `useFormUrl()` resolves, halting render because edit save calls need a bearer token.
Source
Thrown at jeecgboot-vue3/src/views/super/online/cgform/auto/default/OnlineFormUrlEdit.vue:46
import OnlineForm from '../comp/OnlineForm.vue';
import { useMessage } from '/@/hooks/web/useMessage';
import { useRoute, useRouter } from 'vue-router';
import OnlineAutoModal from './OnlineAutoModal.vue';
import { useOnlineTableContext } from '../../hooks/auto/useOnlineTableContext';
import { useListButton } from '../../hooks/auto/useListButton';
import { useEnhance } from '../../hooks/auto/useEnhance';
import { useFormUrl } from '../../hooks/auto/useFormUrl';
const { ID, onlineTableContext, onlineExtConfigJson, handleFormConfig } = useOnlineTableContext();
const { createMessage: $message } = useMessage();
const route = useRoute();
const wrapRef = ref(null);
const contentHeight = ref(400);
const loading = ref(true);
const router = useRouter();
const { token } = useFormUrl();
if (!unref(token)) {
throw new Error('token不存在~');
}
if (!ID.value || !route.params.dataId) {
$message.warning('地址错误, 配置ID不存在!');
throw new Error('地址错误, 配置ID不存在!');
}
// 处理增强
let { initCgEnhanceJs } = useEnhance(onlineTableContext);
watch(
() => wrapRef.value,
(elem: HTMLElement) => {
// 获取页面实际高度
contentHeight.value = elem.offsetHeight - 60;
}
);
// 处理列表button
const { registerModal, handleEdit } = useListButton(onlineTableContext, onlineExtConfigJson);
const getContainer = (node) => {
return document.querySelector(`.online-edit-${ID.value}`);View on GitHub (pinned to 96fb33f5ec)
Solutions
- Log in to the platform first, then reopen the edit form.
- Append a valid `?token=<jwt>` to the edit URL for external use.
- Ensure the login/SSO flow sets the token before the edit route mounts.
- For embedding, mint a long-lived form token server-side and pass it in the URL.
Example fix
// before
const { token } = useFormUrl();
if (!unref(token)) { throw new Error('token不存在~'); }
// after — redirect to login preserving the return path
if (!unref(token)) {
router.replace({ path: '/user/login', query: { redirect: route.fullPath } });
return;
} Defensive patterns
Strategy: validation
Validate before calling
// confirm token presence before relying on it
const { token } = useFormUrl();
if (!unref(token)) {
router.replace({ path: '/user/login', query: { redirect: route.fullPath } });
return;
} Type guard
const hasToken = (t: unknown): t is string => typeof t === 'string' && t.length > 0;
Prevention
- Include `?token=` on externally shared edit links.
- Ensure login/SSO sets userStore.getToken before edit routes mount.
- Guard url-edit routes for token presence.
- Avoid the demo-token fetch path in production.
When it happens
Trigger: Opening the edit URL without `?token=` while not logged in (empty `userStore.getToken`); the async token fetch hasn't completed so the synchronous guard throws.
Common situations: Shared edit link without a token; session expired; incognito window; SSO redirect loop left the user store empty.
Related errors
AI-assisted analysis of jeecgboot/JeecgBoot@96fb33f5ec (2026-08-14).
Data as JSON: /api/errors/2bc7f67dd81b915f.
Report an issue: GitHub.