ui-process-h5 0.1.14 → 0.1.20

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.
@@ -0,0 +1,52 @@
1
+
2
+ export const ACCESS_TOKEN :string
3
+ export const SUBJECTID :string
4
+ export const TASK_JSON :string
5
+
6
+ /**
7
+ * 设置cookie
8
+ * @param key
9
+ * @param value
10
+ * @param options
11
+ * @returns {*}
12
+ */
13
+ export function saveCookie(key: string, value: string, options: any): void
14
+
15
+ /**
16
+ * 获取cookie
17
+ * @param key cookie的key
18
+ * @param defaultValue
19
+ * @returns {*}
20
+ */
21
+ export function loadCookie(key: string, defaultValue: string): string
22
+
23
+
24
+ /**
25
+ * 删除cookie
26
+ * @param key
27
+ * @returns {string}
28
+ */
29
+ export function removeCookie (key: string): string
30
+
31
+
32
+ /**
33
+ * 设置本地存储
34
+ * @param key
35
+ * @param value
36
+ * @returns {*}
37
+ */
38
+ export function saveStorage (key: string, value: string) : string
39
+
40
+ /**
41
+ * 获取本地存储
42
+ * @param key
43
+ * @param defaultValue
44
+ * @returns {*}
45
+ */
46
+ export function loadStorage (key: string, defaultValue: string) : string
47
+ /**
48
+ * 删除本地存储
49
+ * @param key
50
+ * @returns {string}
51
+ */
52
+ export function removeStorage (key: string) : string
@@ -0,0 +1,99 @@
1
+ import Cookies from 'js-cookie'
2
+ import storage from 'good-storage'
3
+
4
+ export const ACCESS_TOKEN = 'Access_Token'// accessToken String
5
+ export const SUBJECTID = 'SUBJECTID'// accessToken String
6
+ export const TASK_JSON = "TASK_JSON"
7
+ /**
8
+ * 设置cookie
9
+ * @param key
10
+ * @param value
11
+ * @param options
12
+ * @returns {*}
13
+ */
14
+ export function saveCookie(key, value, options) {
15
+ Cookies.set(key, value, options)
16
+ return value
17
+ }
18
+
19
+ /**
20
+ * 获取cookie
21
+ * @param key
22
+ * @param defaultValue
23
+ * @returns {*}
24
+ */
25
+ export function loadCookie(key, defaultValue) {
26
+ return Cookies.get(key) || defaultValue
27
+ }
28
+
29
+ /**
30
+ * 删除cookie
31
+ * @param key
32
+ * @returns {string}
33
+ */
34
+ export function removeCookie(key) {
35
+ Cookies.remove(key)
36
+ return ''
37
+ }
38
+
39
+ /**
40
+ * 设置本地存储
41
+ * @param key
42
+ * @param value
43
+ * @returns {*}
44
+ */
45
+ export function saveStorage(key, value) {
46
+ storage.set(key, value)
47
+ return value
48
+ }
49
+
50
+ /**
51
+ * 获取本地存储
52
+ * @param key
53
+ * @param defaultValue
54
+ * @returns {*}
55
+ */
56
+ export function loadStorage(key, defaultValue) {
57
+ return storage.get(key, defaultValue)
58
+ }
59
+
60
+ /**
61
+ * 删除本地存储
62
+ * @param key
63
+ * @returns {string}
64
+ */
65
+ export function removeStorage(key) {
66
+ storage.remove(key)
67
+ return ''
68
+ }
69
+
70
+ /**
71
+ * 保存会话存储
72
+ * @param key
73
+ * @param value
74
+ * @returns {*}
75
+ */
76
+ export function saveSessionStorage(key, value) {
77
+ storage.session.set(key, value)
78
+ return value
79
+ }
80
+
81
+ /**
82
+ * 获取会话存储
83
+ * @param key
84
+ * @param defaultValue
85
+ * @returns {*}
86
+ */
87
+ export function loadSessionStorage(key, defaultValue) {
88
+ return storage.session.get(key, defaultValue)
89
+ }
90
+
91
+ /**
92
+ * 删除会话存储
93
+ * @param key
94
+ * @returns {string}
95
+ */
96
+ export function removeSessionStorage(key) {
97
+ storage.session.remove(key)
98
+ return ''
99
+ }
@@ -0,0 +1,61 @@
1
+ import axios, {
2
+ AxiosRequestConfig,
3
+ AxiosResponse,
4
+ AxiosError,
5
+ InternalAxiosRequestConfig,
6
+ } from "axios";
7
+ import { ACCESS_TOKEN, loadStorage } from "./cache";
8
+
9
+ const host = process.env.VUE_APP_BASE_URL;
10
+ // const host = "http://59.53.91.230:8102";
11
+
12
+ axios.defaults.headers["Content-Type"] = "application/json;charset=utf-8";
13
+
14
+ const opts = {
15
+ baseURL: host,
16
+ timeout: 999999999,
17
+ errorTip: true,
18
+ transformResponse: [
19
+ function (data: any, headers: any) {
20
+ if (typeof data === "string") {
21
+ try {
22
+ data = JSON.parse(data);
23
+ } catch (e) {}
24
+ }
25
+ return data;
26
+ },
27
+ ],
28
+ };
29
+
30
+ const service = axios.create(opts);
31
+
32
+ service.interceptors.request.use((config)=> {
33
+ const isToken = (config.headers || {}).isToken === false;
34
+ if (loadStorage("token", "") && !isToken) {
35
+ config.headers["Authorization"] = "Bearer " + loadStorage("token", ""); // 让每个请求携带自定义token 请根据实际情况自行修改 15c572f2-1fff-4ef2-94dc-728fc8d6fe14
36
+ }
37
+ config.headers["Authorization"] =
38
+ "Bearer " + "15c572f2-1fff-4ef2-94dc-728fc8d6fe14";
39
+ return config;
40
+ });
41
+
42
+ service.interceptors.response.use((response) => {
43
+ if (Object.prototype.toString.call(response.data) === "[object Blob]") {
44
+ return response;
45
+ }
46
+ const { data, config } = response;
47
+ const { code, success } = data;
48
+ const message = response.data.msg;
49
+ // 增加失败判断
50
+ data.fail = code !== 200 && success !== true;
51
+ if (code === 401) {
52
+ console.log("登录状态已过期");
53
+ return data;
54
+ } else if (code !== 200) {
55
+ console.log("错误");
56
+ return data;
57
+ }
58
+ return data;
59
+ });
60
+
61
+ export default service;
@@ -0,0 +1,15 @@
1
+ import { App } from "vue";
2
+ import components from "./component";
3
+
4
+ // 完整引入组件
5
+ const install = function (app: App) {
6
+ components.forEach((component) => {
7
+ app.use((component as unknown) as { install: () => any });
8
+ });
9
+ };
10
+
11
+ // 所有组件
12
+ export * from "./component";
13
+ export default {
14
+ install,
15
+ };
package/lib/demo.html DELETED
@@ -1 +0,0 @@
1
- <!doctype html><meta charset="utf-8"><title>index demo</title><script src="./index.umd.js"></script><link rel="stylesheet" href="./index.css"><script>console.log(index)</script>