|
@@ -1,16 +1,15 @@
|
|
|
// src/routes/channelRoutes.ts
|
|
// src/routes/channelRoutes.ts
|
|
|
-import { lazy } from "react";
|
|
|
|
|
|
|
+import { createElement, lazy } from "react";
|
|
|
import type { RouteObject } from "react-router";
|
|
import type { RouteObject } from "react-router";
|
|
|
import { channelLoader } from "../api/channel";
|
|
import { channelLoader } from "../api/channel";
|
|
|
|
|
+import RouteError from "../components/general/RouteError";
|
|
|
|
|
|
|
|
-const WorkspaceChannel = lazy(
|
|
|
|
|
- () => import("../pages/workspace/channel/list")
|
|
|
|
|
-);
|
|
|
|
|
|
|
+const WorkspaceChannel = lazy(() => import("../pages/workspace/channel/list"));
|
|
|
const WorkspaceChannelShow = lazy(
|
|
const WorkspaceChannelShow = lazy(
|
|
|
- () => import("../pages/workspace/channel/show")
|
|
|
|
|
|
|
+ () => import("../pages/workspace/channel/show"),
|
|
|
);
|
|
);
|
|
|
const WorkspaceChannelSetting = lazy(
|
|
const WorkspaceChannelSetting = lazy(
|
|
|
- () => import("../pages/workspace/channel/setting")
|
|
|
|
|
|
|
+ () => import("../pages/workspace/channel/setting"),
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
const channelRoutes: RouteObject[] = [
|
|
const channelRoutes: RouteObject[] = [
|
|
@@ -25,8 +24,13 @@ const channelRoutes: RouteObject[] = [
|
|
|
{
|
|
{
|
|
|
path: ":channelId",
|
|
path: ":channelId",
|
|
|
loader: channelLoader,
|
|
loader: channelLoader,
|
|
|
|
|
+ // channel 不存在(404)或看不见(v3 回 403,loader 统一抛 404)时给友好提示
|
|
|
|
|
+ errorElement: createElement(RouteError, {
|
|
|
|
|
+ backTo: "/workspace/channel",
|
|
|
|
|
+ }),
|
|
|
handle: {
|
|
handle: {
|
|
|
- crumb: (match: { data: { name: string } }) => match.data.name,
|
|
|
|
|
|
|
+ crumb: (match: { data?: { name?: string } }) =>
|
|
|
|
|
+ match.data?.name ?? "",
|
|
|
},
|
|
},
|
|
|
children: [
|
|
children: [
|
|
|
{
|
|
{
|
|
@@ -38,6 +42,17 @@ const channelRoutes: RouteObject[] = [
|
|
|
Component: WorkspaceChannelSetting,
|
|
Component: WorkspaceChannelSetting,
|
|
|
handle: { id: "workspace.channel.setting", crumb: "setting" },
|
|
handle: { id: "workspace.channel.setting", crumb: "setting" },
|
|
|
},
|
|
},
|
|
|
|
|
+ // 设置页的页签(basic / webhooks)与 webhook 详情(new 或 webhook id)
|
|
|
|
|
+ {
|
|
|
|
|
+ path: "setting/:type",
|
|
|
|
|
+ Component: WorkspaceChannelSetting,
|
|
|
|
|
+ handle: { id: "workspace.channel.setting", crumb: "setting" },
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ path: "setting/:type/:id",
|
|
|
|
|
+ Component: WorkspaceChannelSetting,
|
|
|
|
|
+ handle: { id: "workspace.channel.setting", crumb: "setting" },
|
|
|
|
|
+ },
|
|
|
],
|
|
],
|
|
|
},
|
|
},
|
|
|
],
|
|
],
|