// 解码
import router from "@/router";
export const getDecodedParams = () => {
  if (window.location.search) {
    const urlParams = new URLSearchParams(window.location.search)
    const encoded = urlParams.get('data')
    if (!encoded) return null;
    try {
      // Base64 解码
      const decoded = atob(encoded);
      const jsonStr = decodeURIComponent(decoded);
      return JSON.parse(jsonStr);
    } catch (e) {
      console.error('解码失败', e);
      return null;
    }
  } else {
    const obj = router.currentRoute.value.params
    const encoded = Object.values(obj)[0]
    if (!encoded) return null;
    try {
      // Base64 解码
      const decoded = atob(encoded);
      const jsonStr = decodeURIComponent(decoded);
      return jsonStr;
    } catch (e) {
      console.error('解码失败', e);
      return null;
    }
  }
}