|
@@ -19,9 +19,6 @@ import {
|
|
|
TipitakaIcon,
|
|
TipitakaIcon,
|
|
|
} from "../../assets/icon";
|
|
} from "../../assets/icon";
|
|
|
import React, { useState } from "react";
|
|
import React, { useState } from "react";
|
|
|
-import { useAppSelector } from "../../hooks";
|
|
|
|
|
-import { currentUser } from "../../reducers/current-user";
|
|
|
|
|
-import { useRecent } from "../../hooks/useRecent.ts";
|
|
|
|
|
import RecentModal from "../recent/RecentModal.tsx";
|
|
import RecentModal from "../recent/RecentModal.tsx";
|
|
|
import SettingModal from "../setting/SettingModal.tsx";
|
|
import SettingModal from "../setting/SettingModal.tsx";
|
|
|
import { useIntl } from "react-intl";
|
|
import { useIntl } from "react-intl";
|
|
@@ -125,21 +122,10 @@ const Widget = ({ onSearch }: Props) => {
|
|
|
|
|
|
|
|
const navigate = useNavigate();
|
|
const navigate = useNavigate();
|
|
|
const routeId = useCurrentRouteId();
|
|
const routeId = useCurrentRouteId();
|
|
|
- const currUser = useAppSelector(currentUser);
|
|
|
|
|
|
|
|
|
|
- const { data } = useRecent(currUser?.id, 5, 0);
|
|
|
|
|
const [recentOpen, setRecentOpen] = useState(false);
|
|
const [recentOpen, setRecentOpen] = useState(false);
|
|
|
const [openSetting, setOpenSetting] = useState(false);
|
|
const [openSetting, setOpenSetting] = useState(false);
|
|
|
|
|
|
|
|
- const recentList: MenuItem[] = data
|
|
|
|
|
- ? data?.data.rows.map((item) => {
|
|
|
|
|
- return {
|
|
|
|
|
- key: `recent-${item.id}`,
|
|
|
|
|
- label: item.title,
|
|
|
|
|
- };
|
|
|
|
|
- })
|
|
|
|
|
- : [];
|
|
|
|
|
-
|
|
|
|
|
/* ================= 菜单配置 ================= */
|
|
/* ================= 菜单配置 ================= */
|
|
|
|
|
|
|
|
const items: MenuItem[] = [
|
|
const items: MenuItem[] = [
|
|
@@ -195,13 +181,6 @@ const Widget = ({ onSearch }: Props) => {
|
|
|
label: intl.formatMessage({
|
|
label: intl.formatMessage({
|
|
|
id: "columns.studio.recent.title",
|
|
id: "columns.studio.recent.title",
|
|
|
}),
|
|
}),
|
|
|
- children: [
|
|
|
|
|
- ...recentList,
|
|
|
|
|
- {
|
|
|
|
|
- key: "/workspace/recent/list",
|
|
|
|
|
- label: "更多……",
|
|
|
|
|
- },
|
|
|
|
|
- ],
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
{
|
|
{
|
|
@@ -353,18 +332,12 @@ const Widget = ({ onSearch }: Props) => {
|
|
|
if (key === "search") {
|
|
if (key === "search") {
|
|
|
onSearch?.();
|
|
onSearch?.();
|
|
|
return;
|
|
return;
|
|
|
- } else if (key === "/workspace/recent/list") {
|
|
|
|
|
|
|
+ } else if (key === "/workspace/recent") {
|
|
|
setRecentOpen(true);
|
|
setRecentOpen(true);
|
|
|
return;
|
|
return;
|
|
|
} else if (key === "/workspace/setting") {
|
|
} else if (key === "/workspace/setting") {
|
|
|
setOpenSetting(true);
|
|
setOpenSetting(true);
|
|
|
return;
|
|
return;
|
|
|
- } else if (key.startsWith("recent-")) {
|
|
|
|
|
- const row = data?.data.rows.find((item) => `recent-${item.id}` === key);
|
|
|
|
|
- if (row) {
|
|
|
|
|
- navigate(recentPath(row.type, row.article_id));
|
|
|
|
|
- }
|
|
|
|
|
- return;
|
|
|
|
|
}
|
|
}
|
|
|
navigate(key);
|
|
navigate(key);
|
|
|
};
|
|
};
|