81 lines
3.0 KiB
Dart
81 lines
3.0 KiB
Dart
/*
|
|
* @Author: wangyang 1147192855@qq.com
|
|
* @Date: 2022-07-13 11:28:23
|
|
* @LastEditors: wangyang 1147192855@qq.com
|
|
* @LastEditTime: 2022-09-14 11:17:20
|
|
* @FilePath: \marking_app\lib\config\RequestConfig.dart
|
|
* @Description: 请求工具类
|
|
*/
|
|
import 'package:school_asignment_app/common/job/common/base_page.dart';
|
|
|
|
class RequestConfig {
|
|
/* 测试地址
|
|
static const devBaseUrl = "http://192.168.2.9:6600"; // 测试环境 ==> 基本请求接口
|
|
// static const devBaseUrl = "http://192.168.2.8:6700"; // 测试环境 ==> 基本请求接口
|
|
static const devLoginBaseUrl = "http://192.168.2.9:6400"; // 基本请求接口
|
|
static const devBaseUrlOfReport = "http://192.168.2.9:4000"; // 获取报告接口*/
|
|
|
|
static const devBaseUrl = "https://mk-hw.23544.com"; // 基本请求
|
|
static const devLoginBaseUrl = "https://mk-hw.23544.com"; // 登录接口
|
|
static const devBaseUrlOfReport = "https://mhw.qwit.top"; // 获取报告接口
|
|
static const proBaseUrlOfHomework = "https://mk-hw.23544.com/hw"; // 获取作业接口
|
|
|
|
/* 正式地址 */
|
|
static const proBaseUrl = "https://mk-hw.23544.com"; // 基本请求
|
|
static const proLoginBaseUrl = "https://mk-hw.23544.com"; // 登录接口
|
|
static const proBaseUrlOfReport = "https://dc-api.23544.com"; // 获取报告接口
|
|
// static const proBaseUrlOfHomework = "https://mk-hw.23544.com/hw"; // 获取作业接口
|
|
|
|
static const hwProxyKeywords = "/hw"; // 作业代理条件关键字
|
|
|
|
// https://mk-api.23544.com/hw/hw/api/Task/answer
|
|
// http://192.168.2.9:6400/hw/api/Task/answer
|
|
|
|
static RequestConfig? _instance;
|
|
String baseUrl;
|
|
String loginBaseUrl;
|
|
String baseUrlOfReport;
|
|
|
|
static const connectTimeout = 8000; // 连接超时
|
|
static const receiveTimeout = 8000; // 接收超时
|
|
|
|
static const bool requestDataPrinting = true; // 打印返回数据
|
|
static const bool printSwitch = true; // 打印返回数据
|
|
|
|
static const successCode = 200; // 返回成功code
|
|
static final BasePage basePage = BasePage(1, 10); // 分页参数
|
|
|
|
// 私有化构造函数,防止外部直接实例化
|
|
// 私有化构造函数,防止外部直接实例化
|
|
RequestConfig._(
|
|
{required this.baseUrl,
|
|
required this.baseUrlOfReport,
|
|
required this.loginBaseUrl});
|
|
|
|
factory RequestConfig() {
|
|
if (_instance == null) {
|
|
late String newBaseUrl;
|
|
late String newBaseUrlOfReport;
|
|
late String newLoginBaseUrl;
|
|
|
|
if (bool.fromEnvironment('dart.vm.product')) {
|
|
// 正式环境下的代码
|
|
|
|
newLoginBaseUrl = proLoginBaseUrl;
|
|
newBaseUrl = proBaseUrl;
|
|
newBaseUrlOfReport = proBaseUrlOfReport;
|
|
} else {
|
|
// 在生产环境下执行的代码
|
|
newBaseUrl = devBaseUrl;
|
|
newBaseUrlOfReport = devBaseUrlOfReport;
|
|
newLoginBaseUrl = devLoginBaseUrl;
|
|
}
|
|
_instance = RequestConfig._(
|
|
baseUrl: newBaseUrl,
|
|
baseUrlOfReport: newBaseUrlOfReport,
|
|
loginBaseUrl: newLoginBaseUrl);
|
|
}
|
|
return _instance!;
|
|
}
|
|
}
|