import fs from "node:fs"; import path from "node:path"; import axios from "axios"; import dotenv from "dotenv"; dotenv.config({ path: path.resolve(process.cwd(), ".env.local") }); const client = axios.create({ baseURL: "https://crm.yunvip123.com/api", headers: { "Content-Type": "application/json", Host: "crm.yunvip123.com", }, }); /** 保存响应到接口所在目录的 response.json */ export function saveResponse(dirPath: string, data: any) { const filePath = path.join(dirPath, "response.json"); fs.writeFileSync(filePath, JSON.stringify(data, null, 2), "utf-8"); console.log(`[SUCCESS] 已保存至: ${path.relative(process.cwd(), filePath)}`); } export default client;