import { createSharedComposable } from "@vueuse/core";

const _useWhatsAppMsgSender = () => {
  const config = useRuntimeConfig();
  const phone = config.public.whatsappNumber;

  // --- WhatsApp 自动消息逻辑 ---
  const sendMessage = (message: string) => {
    const text = encodeURIComponent(message);
    const url = `https://api.whatsapp.com/send?phone=${phone}&text=${text}`;
    window.open(url, "_blank", "noopener,noreferrer");
  };

  return {
    sendMessage,
  };
};

export const useWhatsAppMsgSender = createSharedComposable(
  _useWhatsAppMsgSender
);
