diff --git a/README.md b/README.md index 8ec6b9a..7fb28a7 100644 --- a/README.md +++ b/README.md @@ -39,8 +39,6 @@ import { init } from '@xuqm/vue3-sdk' init({ appKey: 'ak_your_app_key', appSecret: 'as_your_app_secret', - apiBaseUrl: 'https://api.xuqm.com', - imBaseUrl: 'wss://im.xuqm.com', debug: import.meta.env.DEV, }) ``` diff --git a/src/core/endpoints.ts b/src/core/endpoints.ts new file mode 100644 index 0000000..988b562 --- /dev/null +++ b/src/core/endpoints.ts @@ -0,0 +1,2 @@ +export const DEFAULT_API_BASE_URL = 'https://dev.xuqinmin.com' +export const DEFAULT_IM_WS_URL = 'wss://dev.xuqinmin.com/ws/im' diff --git a/src/core/sdk.ts b/src/core/sdk.ts index e178a64..263f38b 100644 --- a/src/core/sdk.ts +++ b/src/core/sdk.ts @@ -1,5 +1,6 @@ import type { SDKConfig } from '../types' import { configureHttp } from './http' +import { DEFAULT_API_BASE_URL } from './endpoints' let _config: SDKConfig | null = null let _token: string | null = null @@ -7,7 +8,7 @@ let _userId: string | null = null export function init(config: SDKConfig) { _config = config - configureHttp(config.apiBaseUrl, () => _token) + configureHttp(DEFAULT_API_BASE_URL, () => _token) if (config.debug) console.log('[XuqmSDK] initialized', config.appKey) } diff --git a/src/im/ImClient.ts b/src/im/ImClient.ts index 796276f..6ed1618 100644 --- a/src/im/ImClient.ts +++ b/src/im/ImClient.ts @@ -1,5 +1,6 @@ import type { ImMessage, SendMessageParams, ImEventMap } from '../types' import { getConfig, getToken, getUserId } from '../core/sdk' +import { DEFAULT_IM_WS_URL } from '../core/endpoints' type EventListener = ImEventMap[K] @@ -35,7 +36,7 @@ export class ImClient { if (this.destroyed) return const config = getConfig() const token = getToken() - const url = `${config.imBaseUrl}/ws/im?token=${token ?? ''}` + const url = `${DEFAULT_IM_WS_URL}?token=${token ?? ''}` this.ws = new WebSocket(url) diff --git a/src/types/index.ts b/src/types/index.ts index 09440d4..e258175 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1,8 +1,6 @@ export interface SDKConfig { appKey: string appSecret: string - apiBaseUrl: string - imBaseUrl: string debug?: boolean }