import { useAuthStore } from "@/store/auth";
import { computed, type Ref } from "vue";

const WEB_URL = 'https://zycj.wenlvti.net';

export function useWebPageUrl(subPath: Ref<string>|string) {

  const authStore = useAuthStore();

  const src = computed(() => {
    const authInfo = {
      token: authStore.token,
      userId: authStore.userId,
      expireAt: authStore.expireAt,
      userInfo: authStore.userInfo,
      loginType: authStore.loginType,
    };
    return WEB_URL + `?inMiniProgram=true&directAuthInfo=${encodeURIComponent(JSON.stringify(authInfo))}#${typeof subPath === 'string' ? subPath : subPath.value || ''}`
  });

  return {
    src
  }
}