diff --git a/src/actions/WaiAction.js b/src/actions/WaiAction.js index a674906..c3ad892 100644 --- a/src/actions/WaiAction.js +++ b/src/actions/WaiAction.js @@ -1,9 +1,10 @@ import { fetchJSON, postForm, postJSON } from '@/utils/request' -import { API_HOST, WAI_HOST } from '@/config' import { usingStorage } from '@/utils/usingStorage' const WAI_SERVER_KEY = 'G-STR:WAI_SERVER' +const WAI_API_VER = '/api/v1' + export const postSendMsg = async (body) => { const { waiServer } = usingStorage(WAI_SERVER_KEY) const { attaList = [], atta, content, ...bodyData } = body @@ -14,11 +15,11 @@ export const postSendMsg = async (body) => { attaList.forEach(function (item) { formData.append('attachment', item) }) - const { result } = await postJSON(`${waiServer}/messages/send`, body) + const { result } = await postJSON(`${waiServer}${WAI_API_VER}/messages/send`, body) return result } export const fetchQRCode = (phone) => { const { waiServer } = usingStorage(WAI_SERVER_KEY) - return fetchJSON(`${waiServer}/channels/qrcode`, { phone }) + return fetchJSON(`${waiServer}${WAI_API_VER}/channels/qrcode`, { phone }) } diff --git a/src/stores/AuthStore.js b/src/stores/AuthStore.js index 4459321..1c856db 100644 --- a/src/stores/AuthStore.js +++ b/src/stores/AuthStore.js @@ -68,7 +68,8 @@ const useAuthStore = create(devtools((set, get) => ({ if (json.errcode === 0 && isNotEmpty(json.result.opisn)) { // TODO:保存个人 WhatsApp 服务器地址 - // setStorage('G-STR:WAI_SERVER', ) + const waiServer = json.result.whatsappinfo.length > 0 ? json.result.whatsappinfo[0].wai_server : '' + setStorage('G-STR:WAI_SERVER', waiServer) set(() => ({ loginUser: { userId: json.result.opisn,