helpMenuActions.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import type { IPlatformService } from "@zcode/shared";
  2. import type { IntlInstance } from "@/i18n/IntlProvider.js";
  3. import type { FeedbackSubmitDraft } from "@/feedback/feedbackStore.js";
  4. import { runExportLogsAction } from "@/lib/exportLogsAction.js";
  5. import { ZCODE_PRODUCT_DOCS_URL } from "@/lib/productDocs.js";
  6. interface HelpMenuActionHandlers {
  7. openIssueReport: () => Promise<void>;
  8. openProductDocs: () => void;
  9. exportLogs: () => void;
  10. }
  11. export function createHelpMenuActionHandlers({
  12. platform,
  13. intl,
  14. openSubmit,
  15. }: {
  16. platform: Pick<IPlatformService, "captureWindowScreenshot" | "exportLogs" | "openExternal">;
  17. intl: IntlInstance;
  18. openSubmit: (draft?: FeedbackSubmitDraft) => void;
  19. }): HelpMenuActionHandlers {
  20. return {
  21. openIssueReport: async () => {
  22. openSubmit({
  23. type: "bug",
  24. module: "其它",
  25. severity: "P2-中",
  26. includeLogs: false,
  27. screenshots: [],
  28. });
  29. },
  30. openProductDocs: () => {
  31. platform.openExternal(ZCODE_PRODUCT_DOCS_URL);
  32. },
  33. exportLogs: () => {
  34. void runExportLogsAction(platform, intl);
  35. },
  36. };
  37. }