async checkLogin()

in src/libs/apiService.ts [80:133]


  async checkLogin(
    isShowError = true
  ): Promise<{ success: boolean; message?: string }> {
    try {
      let params = {
        action: 'GetErService',
        version: '2024-09-10',
        protocol: 'https',
        method: 'GET',
        authType: 'AK',
        bodyType: 'json',
        reqBodyType: 'json',
        style: 'RPC',
        pathname: '/',
        toMap: function () {
          return this;
        }
      };
      let request = new $OpenApi.OpenApiRequest({
        query: {}
      });
      let runtime = {
        toMap: function () {
          return this;
        }
      };

      const response = await this.client.callApi(params, request, runtime);

      if (response.statusCode === 200) {
        return { success: true };
      } else if (response.statusCode === 403) {
        return {
          success: false,
          message: t('login_permission_denied').d(
            'Permission denied: Access key or secret is incorrect, or does not have the necessary permissions.'
          )
        };
      } else {
        return {
          success: false,
          message: `${t('common_error_occurred').d('An error occurred')}: ${response.statusCode}`
        };
      }
    } catch (error) {
      isShowError && console.log(error);
      return {
        success: false,
        message: t('login_failed').d(
          'An error occurred while trying to log in.'
        )
      };
    }
  }