|
@@ -10,9 +10,10 @@ import Fly from "flyio/dist/npm/hap";
|
|
|
import apiConfig from "./config";
|
|
|
import prompt from '@system.prompt';
|
|
|
import { getToken, clearToken } from "./utils";
|
|
|
-
|
|
|
+import it from "../helper/interface.js";
|
|
|
var fly = new Fly(fetch);
|
|
|
var qs = require('qs');
|
|
|
+var appInfo = it.getAppInfo();
|
|
|
fly.config.baseURL = apiConfig.baseURL;
|
|
|
fly.config.headers["Content-Type"] =
|
|
|
"application/x-www-form-urlencoded;charset=utf-8";
|
|
@@ -23,8 +24,13 @@ fly.interceptors.request.use(async config => {
|
|
|
// 过滤一些不需要登录的路由d
|
|
|
if (filterNoToken.indexOf(config.url) === -1) {
|
|
|
let token = await getToken();
|
|
|
- if (config.headers) config.headers.Authorization = token;
|
|
|
- else config.headers = { Authorization: token };
|
|
|
+ if (config.headers){
|
|
|
+ config.headers.Authorization = token;
|
|
|
+ config.headers["X-Version"] = appInfo.versionName;
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ config.headers = { Authorization: token,'X-Version':appInfo.versionName };
|
|
|
+ }
|
|
|
if (config.method === "POST") {
|
|
|
config.body = qs.stringify(config.body);
|
|
|
}
|