refactor(config): simplify service definitions with factory functions
Refactored the service configuration to reduce code duplication and separate data from logic. - Created a shared `useWhatsappMsgSender` composable to handle WhatsApp URL generation and opening. - Introduced `createService` and `createPlan` helper functions to programmatically add button actions. - This eliminates the need to manually define `onClick` handlers for every pricing plan, making the service data purely declarative and easier to maintain.
This commit is contained in:
18
app/composables/whatsappMsgSender.ts
Normal file
18
app/composables/whatsappMsgSender.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { createSharedComposable } from "@vueuse/core";
|
||||
|
||||
const _useWhatsappMsgSender = () => {
|
||||
// --- WhatsApp 自动消息逻辑 ---
|
||||
const sendMessage = (message: string) => {
|
||||
const text = encodeURIComponent(message);
|
||||
const url = `https://api.whatsapp.com/send?phone=+601157753558&text=${text}`;
|
||||
window.open(url, "_blank");
|
||||
};
|
||||
|
||||
return {
|
||||
sendMessage,
|
||||
};
|
||||
};
|
||||
|
||||
export const useWhatsappMsgSender = createSharedComposable(
|
||||
_useWhatsappMsgSender
|
||||
);
|
||||
Reference in New Issue
Block a user