import { NetRequest } from "@seayoo-web/request";
import { AuthToken, EventApi, ClubApi, CommunityApi } from "@seayoo-web/gamer-api";
import { captureException } from "@sentry/vue";
import { GamerWebAuth } from "@seayoo-web/login";
const authToken = new AuthToken(SY_GAMER_API, NetRequest);
const eventApi = new EventApi(authToken, SY_EVENT_ID);
const clubApi = new ClubApi(authToken);
const communityApi = new CommunityApi(authToken);
const loginSDK = new GamerWebAuth(autoToken, {
anonymous: false,
hidePasswordLogin: false,
// 更多配置 @seayoo-web/login
});
// 调整请求配置
authToken.req.setConfig({
messageHandler(_, message) {
toast(message);
},
errorHandler({ status, rawError, sentryError, sentryTags, sentryExtra }) {
if (status === 401) {
// 提示或直接登录
// loginSDK.login()
return;
}
// 意外错误进行上报
if (rawError) {
captureException(sentryError, {
extra: sentryExtra,
tags: sentryTags,
});
}
},
});
// 导出供其他功能使用
export { eventApi, clubApi, communityApi, loginSDK };
import { NetRequest } from "@seayoo-web/request/wx";
import { AuthToken, EventApi, ClubApi, WeixinApi } from "@seayoo-web/gamer-api";
import { GamerWeixinAuth } from "@seayoo-web/login";
const authToken = new AuthToken(SY_GAMER_API, NetRequest);
const eventApi = new EventApi(authToken, SY_EVENT_ID);
const clubApi = new ClubApi(authToken);
const communityApi = new CommunityApi(authToken);
const weixinApi = new WeixinApi(authToken, SY_APP_ID);
const loginSDK = new GamerWeixinAuth(authToken, weixinApi);
// 调整请求配置
authToken.req.setConfig({
messageHandler(_, message) {
toast(message);
},
errorHandler({ status, rawError, sentryError, sentryTags, sentryExtra }) {
if (status === 401) {
// 提示或直接登录
if(loginSDK.hasLoginToken) {
loginSDK.login()
} else {
// 跳转到用户手机号授权页面
}
return;
}
// 意外错误进行上报
if (rawError) {
captureException(sentryError, {
extra: sentryExtra,
tags: sentryTags,
});
}
},
});
// 导出供其他功能使用
export { eventApi, clubApi, communityApi, weixinApi, loginSDK };