/*
 * @Author: yangxin yangxin@weiling.cn
 * @Date: 2023-04-25 16:32:55
 * @LastEditors: yangxin yangxin@weiling.cn
 * @LastEditTime: 2023-05-12 19:58:26
 * @FilePath: \mobile-monorapo\packages\mobile-ui\src\hooks\useGetIdsFromUrl.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
/**
 * 用于获取基本配置的corp_id，agent_id，app_id，user_id
 * * 参数说明：
 * @param app_id - 公众平台id
 * @param corp_id - 企业微信中该应用对应的id
 * @param agent_id - 企业微信中该应用对应的id
 * @param user_id - 企业微信的用户id
 * @param channel - 来源，目前只有pcwebsite（官网）和 pc_xiaowei（小微）
 * @param hidden_element - 隐藏元素
 * @param operation - 是否可操作，工作台场景不能操作资料
 * @param source_type - 企业库还是个人库
 * @param need_auth - 判断是否需要授权
 * @param sid - 企业微信的用户信息id
 * @param puid - 最高优先级的sid
 * @param external_userid - 企业微信的外部联系人id
 * @param show_back - 是否显示返回按钮
 * @param show_menu - 物料详情是否显示操作菜单
 * @param show_share - 物料详情是否显示分享发送按钮
 * @param show_header - 是否显示标题
 * @param show_company_header - 是否显示公司详情头部
 * @param event_id_for_light - 将event_id对应的旅程高亮
 */
import { getQueryVariable } from "@mobileUI/utils/index";
//获取授权回调的参数并保存在本地
const useGetIdsFromUrl = () => {
  const sid = getQueryVariable("sid");
  const from = getQueryVariable("from");
  const puid = getQueryVariable("puid");
  const order = getQueryVariable("order");
  const app_id = getQueryVariable("app_id");
  const use_tp = getQueryVariable("use_tp");
  const hlt_id = getQueryVariable("hlt_id");
  const token = getQueryVariable("token");
  const corp_id = getQueryVariable("corp_id");
  const user_id = getQueryVariable("user_id");
  const channel = getQueryVariable("channel");
  const hidden_element = getQueryVariable("hidden_element");
  const agent_id = getQueryVariable("agent_id");
  const operation = getQueryVariable("operation");
  const need_auth = getQueryVariable("need_auth");
  const show_back = getQueryVariable("show_back");
  const show_menu = getQueryVariable("show_menu");
  const show_share = getQueryVariable("show_share");
  const show_header = getQueryVariable("show_header");
  const show_company_header = getQueryVariable("show_company_header");
  const external_userid = getQueryVariable("external_userid");
  const external_chatid = getQueryVariable("external_chatid");
  const event_id_for_light = getQueryVariable("event_id_for_light");
  const params = {
    sid,
    puid,
    from,
    order,
    hlt_id,
    app_id,
    use_tp,
    token,
    corp_id,
    user_id,
    channel,
    agent_id,
    operation,
    need_auth,
    show_menu,
    show_back,
    show_share,
    show_header,
    hidden_element,
    external_userid,
    external_chatid,
    event_id_for_light,
    show_company_header,
  };
  return Object.keys(params).reduce((acc, item) => {
    if (params[item] !== null && params[item] !== "" && params[item] !== undefined) {
      acc[item] = params[item];
    }
    return acc;
  }, {});
};
export default useGetIdsFromUrl;
