qdmp-cli 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actions.js +1 -1
- package/api.js +12 -4
- package/package.json +1 -1
package/actions.js
CHANGED
|
@@ -133,7 +133,7 @@ export async function uploadAction(option) {
|
|
|
133
133
|
await cleanWorkSpaceFolder();
|
|
134
134
|
success(
|
|
135
135
|
`上传成功,版本号:${code},可前往官网进行小程序发布:https://${
|
|
136
|
-
option.env === "
|
|
136
|
+
option.env === "dev" ? "dev-" : ""
|
|
137
137
|
}mp.qiandao.com`
|
|
138
138
|
);
|
|
139
139
|
} catch (e) {
|
package/api.js
CHANGED
|
@@ -16,9 +16,16 @@ const API_CONFIG = {
|
|
|
16
16
|
* 基础请求函数
|
|
17
17
|
* @param {string} url - 请求地址
|
|
18
18
|
* @param {object} options - 请求选项
|
|
19
|
+
* @param {string} env - 环境
|
|
20
|
+
* @param {boolean} needAuth - 是否需要认证头,默认为true
|
|
19
21
|
* @returns {Promise} 请求结果
|
|
20
22
|
*/
|
|
21
|
-
export const request = async (
|
|
23
|
+
export const request = async (
|
|
24
|
+
url,
|
|
25
|
+
options = {},
|
|
26
|
+
env = "prod",
|
|
27
|
+
needAuth = true
|
|
28
|
+
) => {
|
|
22
29
|
const config = {
|
|
23
30
|
baseURL:
|
|
24
31
|
env === "prod"
|
|
@@ -28,8 +35,8 @@ export const request = async (url, options = {}, env = "prod") => {
|
|
|
28
35
|
headers: { ...API_CONFIG.headers },
|
|
29
36
|
...options,
|
|
30
37
|
};
|
|
31
|
-
|
|
32
|
-
if (
|
|
38
|
+
// 添加认证头(如果需要且如果有 token)
|
|
39
|
+
if (needAuth) {
|
|
33
40
|
const token = getToken();
|
|
34
41
|
if (token) {
|
|
35
42
|
config.headers["authorization"] = `Bearer ${token}`;
|
|
@@ -68,7 +75,8 @@ export const login = async (username, password, env = "prod") => {
|
|
|
68
75
|
method: "POST",
|
|
69
76
|
body: JSON.stringify({ username, password }),
|
|
70
77
|
},
|
|
71
|
-
env
|
|
78
|
+
env,
|
|
79
|
+
false // 登录时不需要认证头
|
|
72
80
|
);
|
|
73
81
|
if (result?.data?.token) {
|
|
74
82
|
saveToken(result.data.token); // 保存token
|