import {
  openSearchShopInBackground,
  queryShopWangLinkInBackground,
  searchTaobaoShopInBackground,
  searchTaobaoSimilarShopInBackground,
} from "./taobao/background";
import { BgMessageKeys } from "../utils/constants";
import { searchTaobaoShopInEvent } from "./taobao/event";

/**
 * 注册右键点击事件
 */
export const RightClickEvent: Array<{
  id: string;
  title: string;
  contexts?:
    | chrome.contextMenus.ContextType
    | chrome.contextMenus.ContextType[];
  event: (clickData: chrome.contextMenus.OnClickData) => void;
}> = [
  {
    id: BgMessageKeys.bgSearchShops,
    title: "搜索淘宝店铺",
    contexts: ["selection"],
    event: searchTaobaoShopInEvent,
  },
];

/**
 * 注册后台运行事件
 */
export const BackgroundOnEvent: Array<{
  type: string;
  event: (params: any) => Promise<any>;
}> = [
  {
    type: BgMessageKeys.bgSearchShops,
    event: searchTaobaoShopInBackground,
  },
  {
    type: BgMessageKeys.bgSearchSimilarShops,
    event: searchTaobaoSimilarShopInBackground,
  },
  {
    type: BgMessageKeys.bgQueryShopWangLink,
    event: queryShopWangLinkInBackground,
  },
  {
    type: BgMessageKeys.bgOpenSearchShopTab,
    event: openSearchShopInBackground,
  },
];
