giime 0.0.26 → 0.0.28
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/dist/index.css +4 -4
- package/es/components/src/composite/operateButton/OperateButton.vue2.mjs +17 -27
- package/es/components/src/composite/operateButton/OperateButton.vue2.mjs.map +1 -1
- package/es/giime/version.d.ts +1 -1
- package/es/giime/version.mjs +1 -1
- package/es/giime/version.mjs.map +1 -1
- package/es/index.css +4 -4
- package/es/utils/src/http/createAxios.mjs +9 -6
- package/es/utils/src/http/createAxios.mjs.map +1 -1
- package/lib/components/src/composite/operateButton/OperateButton.vue2.js +16 -26
- package/lib/components/src/composite/operateButton/OperateButton.vue2.js.map +1 -1
- package/lib/giime/version.d.ts +1 -1
- package/lib/giime/version.js +1 -1
- package/lib/giime/version.js.map +1 -1
- package/lib/index.css +4 -4
- package/lib/utils/src/http/createAxios.js +9 -6
- package/lib/utils/src/http/createAxios.js.map +1 -1
- package/package.json +1 -1
package/dist/index.css
CHANGED
|
@@ -5,10 +5,6 @@
|
|
|
5
5
|
.gm-flex-justify-between[data-v-d1c6dac0] {
|
|
6
6
|
justify-content: space-between;
|
|
7
7
|
}
|
|
8
|
-
[data-v-512cf874] .gmSearchForm .el-form-item {
|
|
9
|
-
margin-right: 8px;
|
|
10
|
-
margin-bottom: 8px;
|
|
11
|
-
}
|
|
12
8
|
[data-v-9f72778f] .gmTableNoBorder .el-table__body .el-table__cell {
|
|
13
9
|
border-right: none;
|
|
14
10
|
}
|
|
@@ -32,6 +28,10 @@
|
|
|
32
28
|
[data-v-9f72778f] .gmTableNoBorder .el-table__border-left-patch {
|
|
33
29
|
height: 0;
|
|
34
30
|
}
|
|
31
|
+
[data-v-512cf874] .gmSearchForm .el-form-item {
|
|
32
|
+
margin-right: 8px;
|
|
33
|
+
margin-bottom: 8px;
|
|
34
|
+
}
|
|
35
35
|
/*
|
|
36
36
|
! tailwindcss v3.4.1 | MIT License | https://tailwindcss.com
|
|
37
37
|
*//*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, resolveComponent, openBlock,
|
|
1
|
+
import { defineComponent, resolveComponent, openBlock, createBlock, withCtx, createTextVNode, toDisplayString } from 'vue';
|
|
2
2
|
import { operateButtonProps } from './operateButton.mjs';
|
|
3
3
|
|
|
4
4
|
var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
@@ -10,32 +10,22 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
10
10
|
setup(__props) {
|
|
11
11
|
return (_ctx, _cache) => {
|
|
12
12
|
const _component_gm_button = resolveComponent("gm-button");
|
|
13
|
-
return openBlock(),
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
)
|
|
30
|
-
]),
|
|
31
|
-
_: 1
|
|
32
|
-
/* STABLE */
|
|
33
|
-
}, 8, ["type"])
|
|
34
|
-
])
|
|
35
|
-
],
|
|
36
|
-
2112
|
|
37
|
-
/* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
|
|
38
|
-
);
|
|
13
|
+
return openBlock(), createBlock(_component_gm_button, {
|
|
14
|
+
type: _ctx.type,
|
|
15
|
+
size: "small",
|
|
16
|
+
link: "",
|
|
17
|
+
style: { "margin-left": "0" }
|
|
18
|
+
}, {
|
|
19
|
+
default: withCtx(() => [
|
|
20
|
+
createTextVNode(
|
|
21
|
+
toDisplayString(_ctx.label),
|
|
22
|
+
1
|
|
23
|
+
/* TEXT */
|
|
24
|
+
)
|
|
25
|
+
]),
|
|
26
|
+
_: 1
|
|
27
|
+
/* STABLE */
|
|
28
|
+
}, 8, ["type"]);
|
|
39
29
|
};
|
|
40
30
|
}
|
|
41
31
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OperateButton.vue2.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"OperateButton.vue2.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/es/giime/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.0.
|
|
1
|
+
export declare const version = "0.0.28";
|
package/es/giime/version.mjs
CHANGED
package/es/giime/version.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.mjs","sources":["../../../../packages/giime/version.ts"],"sourcesContent":["export const version = '0.0.
|
|
1
|
+
{"version":3,"file":"version.mjs","sources":["../../../../packages/giime/version.ts"],"sourcesContent":["export const version = '0.0.27';\n"],"names":[],"mappings":"AAAO,MAAM,OAAU,GAAA;;;;"}
|
package/es/index.css
CHANGED
|
@@ -5,10 +5,6 @@
|
|
|
5
5
|
.gm-flex-justify-between[data-v-d1c6dac0] {
|
|
6
6
|
justify-content: space-between;
|
|
7
7
|
}
|
|
8
|
-
[data-v-512cf874] .gmSearchForm .el-form-item {
|
|
9
|
-
margin-right: 8px;
|
|
10
|
-
margin-bottom: 8px;
|
|
11
|
-
}
|
|
12
8
|
[data-v-9f72778f] .gmTableNoBorder .el-table__body .el-table__cell {
|
|
13
9
|
border-right: none;
|
|
14
10
|
}
|
|
@@ -32,6 +28,10 @@
|
|
|
32
28
|
[data-v-9f72778f] .gmTableNoBorder .el-table__border-left-patch {
|
|
33
29
|
height: 0;
|
|
34
30
|
}
|
|
31
|
+
[data-v-512cf874] .gmSearchForm .el-form-item {
|
|
32
|
+
margin-right: 8px;
|
|
33
|
+
margin-bottom: 8px;
|
|
34
|
+
}
|
|
35
35
|
/*
|
|
36
36
|
! tailwindcss v3.4.1 | MIT License | https://tailwindcss.com
|
|
37
37
|
*//*
|
|
@@ -23,12 +23,15 @@ const createAxios = (config) => {
|
|
|
23
23
|
if (!config2.params) {
|
|
24
24
|
config2.params = {};
|
|
25
25
|
}
|
|
26
|
-
config2.params
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
if (!config2.params._token) {
|
|
27
|
+
config2.params._token = _token;
|
|
28
|
+
}
|
|
29
|
+
if (!config2.params._user) {
|
|
30
|
+
config2.params._user = _user;
|
|
31
|
+
}
|
|
32
|
+
if (!config2.headers.Authorization) {
|
|
33
|
+
config2.headers.Authorization = `Bearer ${_token}`;
|
|
34
|
+
}
|
|
32
35
|
return config2;
|
|
33
36
|
},
|
|
34
37
|
(error) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createAxios.mjs","sources":["../../../../../../packages/utils/src/http/createAxios.ts"],"sourcesContent":["import axios from 'axios';\r\nimport { ElMessage } from 'element-plus';\r\nimport Cookies from 'js-cookie';\r\nimport { res401Interceptors } from './interceptors';\r\nimport { responseErrorMessage } from './errorMessage';\r\nimport type { AxiosError, CreateAxiosDefaults } from 'axios';\r\nexport interface CreateAxiosConfig extends CreateAxiosDefaults {\r\n baseURL: string;\r\n /**服务器调用成功的code 一般是 0 或 200 */\r\n successCode: number;\r\n}\r\n\r\nexport const createAxios = (config: CreateAxiosConfig) => {\r\n const successCode = config.successCode ?? 0;\r\n const service = axios.create({\r\n withCredentials: true, // send cookies when cross-domain requests\r\n timeout: 120_000,\r\n headers: {\r\n 'content-type': 'application/json',\r\n Accept: '*/*',\r\n },\r\n ...config,\r\n });\r\n\r\n // 请求拦截器\r\n service.interceptors.request.use(\r\n config => {\r\n const _token = Cookies.get('token');\r\n const _user = Cookies.get('sso_user_id');\r\n if (!config.params) {\r\n config.params = {};\r\n }\r\n config.params
|
|
1
|
+
{"version":3,"file":"createAxios.mjs","sources":["../../../../../../packages/utils/src/http/createAxios.ts"],"sourcesContent":["import axios from 'axios';\r\nimport { ElMessage } from 'element-plus';\r\nimport Cookies from 'js-cookie';\r\nimport { res401Interceptors } from './interceptors';\r\nimport { responseErrorMessage } from './errorMessage';\r\nimport type { AxiosError, CreateAxiosDefaults } from 'axios';\r\nexport interface CreateAxiosConfig extends CreateAxiosDefaults {\r\n baseURL: string;\r\n /**服务器调用成功的code 一般是 0 或 200 */\r\n successCode: number;\r\n}\r\n\r\nexport const createAxios = (config: CreateAxiosConfig) => {\r\n const successCode = config.successCode ?? 0;\r\n const service = axios.create({\r\n withCredentials: true, // send cookies when cross-domain requests\r\n timeout: 120_000,\r\n headers: {\r\n 'content-type': 'application/json',\r\n Accept: '*/*',\r\n },\r\n ...config,\r\n });\r\n\r\n // 请求拦截器\r\n service.interceptors.request.use(\r\n config => {\r\n const _token = Cookies.get('token');\r\n const _user = Cookies.get('sso_user_id');\r\n if (!config.params) {\r\n config.params = {};\r\n }\r\n if (!config.params._token) {\r\n config.params._token = _token;\r\n }\r\n if (!config.params._user) {\r\n config.params._user = _user;\r\n }\r\n if (!config.headers.Authorization) {\r\n config.headers.Authorization = `Bearer ${_token}`;\r\n }\r\n return config;\r\n },\r\n error => {\r\n console.error('请求错误', error); // for debug\r\n return Promise.reject(error);\r\n },\r\n );\r\n // 添加响应拦截器\r\n service.interceptors.response.use(\r\n async response => {\r\n // 对响应数据做点什么\r\n const res = response.data;\r\n if (!res?.code) {\r\n return response;\r\n }\r\n if (res.code === 401) {\r\n const res = await res401Interceptors(service, response.config);\r\n return res;\r\n } else if (res.code !== successCode && res.errCode !== successCode) {\r\n ElMessage({\r\n message: res.comment ?? res.message ?? res.errMsg ?? res.msg,\r\n type: 'error',\r\n grouping: true,\r\n duration: 5 * 1000,\r\n });\r\n }\r\n return response;\r\n },\r\n async (err: AxiosError) => {\r\n console.error(err.config);\r\n if (err?.response?.status === 401 && !err.message.includes('timeout')) {\r\n const res = await res401Interceptors(service, err.config!);\r\n return res;\r\n } else {\r\n // 对响应错误做点什么\r\n responseErrorMessage(err);\r\n return Promise.reject(err);\r\n }\r\n },\r\n );\r\n\r\n return {\r\n service,\r\n };\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MAAA;AAEL,QAAA,oBAAA,CAAqB,GAAG,CAAA,CAAA;AACxB,QAAO,OAAA,OAAA,CAAQ,OAAO,GAAG,CAAA,CAAA;AAAA,OAC3B;AAAA,KACF;AAAA,GACF,CAAA;AAEA,EAAO,OAAA;AAAA,IACL,OAAA;AAAA,GACF,CAAA;AACF;;;;"}
|
|
@@ -14,32 +14,22 @@ var _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
14
14
|
setup(__props) {
|
|
15
15
|
return (_ctx, _cache) => {
|
|
16
16
|
const _component_gm_button = vue.resolveComponent("gm-button");
|
|
17
|
-
return vue.openBlock(), vue.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
)
|
|
34
|
-
]),
|
|
35
|
-
_: 1
|
|
36
|
-
/* STABLE */
|
|
37
|
-
}, 8, ["type"])
|
|
38
|
-
])
|
|
39
|
-
],
|
|
40
|
-
2112
|
|
41
|
-
/* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
|
|
42
|
-
);
|
|
17
|
+
return vue.openBlock(), vue.createBlock(_component_gm_button, {
|
|
18
|
+
type: _ctx.type,
|
|
19
|
+
size: "small",
|
|
20
|
+
link: "",
|
|
21
|
+
style: { "margin-left": "0" }
|
|
22
|
+
}, {
|
|
23
|
+
default: vue.withCtx(() => [
|
|
24
|
+
vue.createTextVNode(
|
|
25
|
+
vue.toDisplayString(_ctx.label),
|
|
26
|
+
1
|
|
27
|
+
/* TEXT */
|
|
28
|
+
)
|
|
29
|
+
]),
|
|
30
|
+
_: 1
|
|
31
|
+
/* STABLE */
|
|
32
|
+
}, 8, ["type"]);
|
|
43
33
|
};
|
|
44
34
|
}
|
|
45
35
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OperateButton.vue2.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"OperateButton.vue2.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/lib/giime/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.0.
|
|
1
|
+
export declare const version = "0.0.28";
|
package/lib/giime/version.js
CHANGED
package/lib/giime/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sources":["../../../../packages/giime/version.ts"],"sourcesContent":["export const version = '0.0.
|
|
1
|
+
{"version":3,"file":"version.js","sources":["../../../../packages/giime/version.ts"],"sourcesContent":["export const version = '0.0.27';\n"],"names":[],"mappings":";;AAAO,MAAM,OAAU,GAAA;;;;"}
|
package/lib/index.css
CHANGED
|
@@ -5,10 +5,6 @@
|
|
|
5
5
|
.gm-flex-justify-between[data-v-d1c6dac0] {
|
|
6
6
|
justify-content: space-between;
|
|
7
7
|
}
|
|
8
|
-
[data-v-512cf874] .gmSearchForm .el-form-item {
|
|
9
|
-
margin-right: 8px;
|
|
10
|
-
margin-bottom: 8px;
|
|
11
|
-
}
|
|
12
8
|
[data-v-9f72778f] .gmTableNoBorder .el-table__body .el-table__cell {
|
|
13
9
|
border-right: none;
|
|
14
10
|
}
|
|
@@ -32,6 +28,10 @@
|
|
|
32
28
|
[data-v-9f72778f] .gmTableNoBorder .el-table__border-left-patch {
|
|
33
29
|
height: 0;
|
|
34
30
|
}
|
|
31
|
+
[data-v-512cf874] .gmSearchForm .el-form-item {
|
|
32
|
+
margin-right: 8px;
|
|
33
|
+
margin-bottom: 8px;
|
|
34
|
+
}
|
|
35
35
|
/*
|
|
36
36
|
! tailwindcss v3.4.1 | MIT License | https://tailwindcss.com
|
|
37
37
|
*//*
|
|
@@ -25,12 +25,15 @@ const createAxios = (config) => {
|
|
|
25
25
|
if (!config2.params) {
|
|
26
26
|
config2.params = {};
|
|
27
27
|
}
|
|
28
|
-
config2.params
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
if (!config2.params._token) {
|
|
29
|
+
config2.params._token = _token;
|
|
30
|
+
}
|
|
31
|
+
if (!config2.params._user) {
|
|
32
|
+
config2.params._user = _user;
|
|
33
|
+
}
|
|
34
|
+
if (!config2.headers.Authorization) {
|
|
35
|
+
config2.headers.Authorization = `Bearer ${_token}`;
|
|
36
|
+
}
|
|
34
37
|
return config2;
|
|
35
38
|
},
|
|
36
39
|
(error) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createAxios.js","sources":["../../../../../../packages/utils/src/http/createAxios.ts"],"sourcesContent":["import axios from 'axios';\r\nimport { ElMessage } from 'element-plus';\r\nimport Cookies from 'js-cookie';\r\nimport { res401Interceptors } from './interceptors';\r\nimport { responseErrorMessage } from './errorMessage';\r\nimport type { AxiosError, CreateAxiosDefaults } from 'axios';\r\nexport interface CreateAxiosConfig extends CreateAxiosDefaults {\r\n baseURL: string;\r\n /**服务器调用成功的code 一般是 0 或 200 */\r\n successCode: number;\r\n}\r\n\r\nexport const createAxios = (config: CreateAxiosConfig) => {\r\n const successCode = config.successCode ?? 0;\r\n const service = axios.create({\r\n withCredentials: true, // send cookies when cross-domain requests\r\n timeout: 120_000,\r\n headers: {\r\n 'content-type': 'application/json',\r\n Accept: '*/*',\r\n },\r\n ...config,\r\n });\r\n\r\n // 请求拦截器\r\n service.interceptors.request.use(\r\n config => {\r\n const _token = Cookies.get('token');\r\n const _user = Cookies.get('sso_user_id');\r\n if (!config.params) {\r\n config.params = {};\r\n }\r\n config.params
|
|
1
|
+
{"version":3,"file":"createAxios.js","sources":["../../../../../../packages/utils/src/http/createAxios.ts"],"sourcesContent":["import axios from 'axios';\r\nimport { ElMessage } from 'element-plus';\r\nimport Cookies from 'js-cookie';\r\nimport { res401Interceptors } from './interceptors';\r\nimport { responseErrorMessage } from './errorMessage';\r\nimport type { AxiosError, CreateAxiosDefaults } from 'axios';\r\nexport interface CreateAxiosConfig extends CreateAxiosDefaults {\r\n baseURL: string;\r\n /**服务器调用成功的code 一般是 0 或 200 */\r\n successCode: number;\r\n}\r\n\r\nexport const createAxios = (config: CreateAxiosConfig) => {\r\n const successCode = config.successCode ?? 0;\r\n const service = axios.create({\r\n withCredentials: true, // send cookies when cross-domain requests\r\n timeout: 120_000,\r\n headers: {\r\n 'content-type': 'application/json',\r\n Accept: '*/*',\r\n },\r\n ...config,\r\n });\r\n\r\n // 请求拦截器\r\n service.interceptors.request.use(\r\n config => {\r\n const _token = Cookies.get('token');\r\n const _user = Cookies.get('sso_user_id');\r\n if (!config.params) {\r\n config.params = {};\r\n }\r\n if (!config.params._token) {\r\n config.params._token = _token;\r\n }\r\n if (!config.params._user) {\r\n config.params._user = _user;\r\n }\r\n if (!config.headers.Authorization) {\r\n config.headers.Authorization = `Bearer ${_token}`;\r\n }\r\n return config;\r\n },\r\n error => {\r\n console.error('请求错误', error); // for debug\r\n return Promise.reject(error);\r\n },\r\n );\r\n // 添加响应拦截器\r\n service.interceptors.response.use(\r\n async response => {\r\n // 对响应数据做点什么\r\n const res = response.data;\r\n if (!res?.code) {\r\n return response;\r\n }\r\n if (res.code === 401) {\r\n const res = await res401Interceptors(service, response.config);\r\n return res;\r\n } else if (res.code !== successCode && res.errCode !== successCode) {\r\n ElMessage({\r\n message: res.comment ?? res.message ?? res.errMsg ?? res.msg,\r\n type: 'error',\r\n grouping: true,\r\n duration: 5 * 1000,\r\n });\r\n }\r\n return response;\r\n },\r\n async (err: AxiosError) => {\r\n console.error(err.config);\r\n if (err?.response?.status === 401 && !err.message.includes('timeout')) {\r\n const res = await res401Interceptors(service, err.config!);\r\n return res;\r\n } else {\r\n // 对响应错误做点什么\r\n responseErrorMessage(err);\r\n return Promise.reject(err);\r\n }\r\n },\r\n );\r\n\r\n return {\r\n service,\r\n };\r\n};\r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