增加client_id登录方式

This commit is contained in:
NewTab
2022-01-19 19:39:25 +08:00
parent 6dbed6cf49
commit e8694643d8
14 changed files with 415 additions and 281 deletions

View File

@@ -29,7 +29,7 @@ class Api {
String id,
String secret,
) async {
return await Http.post<LoginBean>(
return await Http.get<LoginBean>(
Url.loginByClientId,
{
"client_id": id,

View File

@@ -1,4 +1,5 @@
import 'package:dio/dio.dart';
import 'package:qinglong_app/base/http/url.dart';
import 'package:qinglong_app/main.dart';
import '../userinfo_viewmodel.dart';
@@ -15,8 +16,10 @@ class TokenInterceptor extends Interceptor {
options.headers["User-Agent"] =
"Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1";
options.headers["Content-Type"] = "application/json;charset=UTF-8";
options.queryParameters["t"] =
(DateTime.now().millisecondsSinceEpoch ~/ 1000).toString();
if (options.path != Url.loginByClientId) {
options.queryParameters["t"] =
(DateTime.now().millisecondsSinceEpoch ~/ 1000).toString();
}
return handler.next(options);
}
}

View File

@@ -6,7 +6,7 @@ class Url {
static const loginByClientId = "/open/auth/token";
static const user = "/api/user";
static get tasks => getIt<UserInfoViewModel>().useSecretLogined ? "/open/user/login" : "/api/crons";
static get tasks => getIt<UserInfoViewModel>().useSecretLogined ? "/open/crons" : "/api/crons";
static get runTasks => getIt<UserInfoViewModel>().useSecretLogined ? "/open/crons/run" : "/api/crons/run";