rexma-design 2.2.0-beta.0 → 2.2.0-beta.2
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/lib/RmaProList/index.vue2.js +113 -84
- package/lib/XinhuaClient/ClientSign.js +63 -39
- package/lib/XinhuaClient/index.js +146 -79
- package/lib/_virtual/_tslib.js +75 -0
- package/lib/getValueFromUA/index.js +5 -5
- package/lib/resolver.js +3 -3
- package/lib/useOnShow/index.js +4 -4
- package/lib/usePullDownRefresh/index.js +72 -129
- package/package.json +6 -5
|
@@ -2,119 +2,149 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var _tslib = require('../_virtual/_tslib.js');
|
|
5
6
|
var vue = require('vue');
|
|
6
7
|
var vant = require('vant');
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
var _hoisted_1 = {
|
|
9
10
|
key: 1,
|
|
10
11
|
class: "refresh-loading"
|
|
11
12
|
};
|
|
12
|
-
|
|
13
|
+
var __default__ = {
|
|
13
14
|
name: 'RmaProList',
|
|
14
15
|
};
|
|
15
|
-
var script = /*@__PURE__*/ vue.defineComponent({
|
|
16
|
-
...__default__,
|
|
17
|
-
props: {
|
|
16
|
+
var script = /*@__PURE__*/ vue.defineComponent(_tslib.__assign(_tslib.__assign({}, __default__), { props: {
|
|
18
17
|
request: { type: Function, required: true },
|
|
19
18
|
defaultCurrent: { type: Number, required: false, default: 1 },
|
|
20
19
|
defaultPageSize: { type: Number, required: false, default: 10 },
|
|
21
20
|
defaultFirstRequest: { type: Boolean, required: false, default: true },
|
|
22
21
|
rowKey: { type: String, required: false }
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
}, setup: function (__props, _a) {
|
|
23
|
+
var __expose = _a.expose;
|
|
24
|
+
var pageNum = vue.ref(1);
|
|
25
|
+
var listData = vue.ref([]);
|
|
26
|
+
var loading = vue.ref(false);
|
|
27
|
+
var hasMore = vue.ref(true);
|
|
28
|
+
var refresh = vue.ref(false);
|
|
30
29
|
// 标记是否正在重新加载第一页
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
var isReloading = vue.ref(false);
|
|
31
|
+
var props = __props;
|
|
33
32
|
// 计算是否显示 van-list 的加载状态(下拉刷新时不显示)
|
|
34
|
-
|
|
35
|
-
vue.onMounted(()
|
|
33
|
+
var showListLoading = vue.computed(function () { return loading.value && !refresh.value; });
|
|
34
|
+
vue.onMounted(function () {
|
|
36
35
|
if (props.defaultFirstRequest) {
|
|
37
36
|
reloadAndRest();
|
|
38
37
|
}
|
|
39
38
|
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
function refreshData() {
|
|
40
|
+
return _tslib.__awaiter(this, void 0, void 0, function () {
|
|
41
|
+
return _tslib.__generator(this, function (_a) {
|
|
42
|
+
switch (_a.label) {
|
|
43
|
+
case 0:
|
|
44
|
+
refresh.value = true;
|
|
45
|
+
return [4 /*yield*/, reloadAndRest()];
|
|
46
|
+
case 1:
|
|
47
|
+
_a.sent();
|
|
48
|
+
refresh.value = false;
|
|
49
|
+
return [2 /*return*/];
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
});
|
|
44
53
|
}
|
|
45
54
|
/**
|
|
46
55
|
* 重置数据并加载第一页
|
|
47
56
|
*/
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
function reloadAndRest() {
|
|
58
|
+
return _tslib.__awaiter(this, void 0, void 0, function () {
|
|
59
|
+
return _tslib.__generator(this, function (_a) {
|
|
60
|
+
switch (_a.label) {
|
|
61
|
+
case 0:
|
|
62
|
+
listData.value = [];
|
|
63
|
+
pageNum.value = 1;
|
|
64
|
+
hasMore.value = true;
|
|
65
|
+
isReloading.value = true;
|
|
66
|
+
// 不立即清空数组,等请求完成后再处理
|
|
67
|
+
return [4 /*yield*/, getListData()];
|
|
68
|
+
case 1:
|
|
69
|
+
// 不立即清空数组,等请求完成后再处理
|
|
70
|
+
_a.sent();
|
|
71
|
+
isReloading.value = false;
|
|
72
|
+
return [2 /*return*/];
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
});
|
|
56
76
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
77
|
+
function getListData() {
|
|
78
|
+
var _a;
|
|
79
|
+
return _tslib.__awaiter(this, void 0, void 0, function () {
|
|
80
|
+
var currentPageNum, res;
|
|
81
|
+
return _tslib.__generator(this, function (_b) {
|
|
82
|
+
switch (_b.label) {
|
|
83
|
+
case 0:
|
|
84
|
+
if (loading.value || !hasMore.value) {
|
|
85
|
+
return [2 /*return*/];
|
|
86
|
+
}
|
|
87
|
+
loading.value = true;
|
|
88
|
+
currentPageNum = isReloading.value ? 1 : pageNum.value;
|
|
89
|
+
return [4 /*yield*/, props.request({
|
|
90
|
+
pageNum: currentPageNum,
|
|
91
|
+
pageSize: props.defaultPageSize,
|
|
92
|
+
})];
|
|
93
|
+
case 1:
|
|
94
|
+
res = _b.sent();
|
|
95
|
+
loading.value = false;
|
|
96
|
+
if (!res) {
|
|
97
|
+
hasMore.value = false;
|
|
98
|
+
return [2 /*return*/];
|
|
99
|
+
}
|
|
100
|
+
// 根据是否是重新加载来决定如何处理数据
|
|
101
|
+
if (isReloading.value) {
|
|
102
|
+
// 重新加载第一页:直接替换整个数组
|
|
103
|
+
listData.value = res.records || [];
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
// 加载更多:追加到现有数组
|
|
107
|
+
listData.value = listData.value.concat(res.records || []);
|
|
108
|
+
}
|
|
109
|
+
hasMore.value =
|
|
110
|
+
(_a = res.hasMore) !== null && _a !== void 0 ? _a : (res.total
|
|
111
|
+
? res.total > listData.value.length
|
|
112
|
+
: (res.records || []).length >= props.defaultPageSize);
|
|
113
|
+
// 更新页码逻辑
|
|
114
|
+
if (hasMore.value) {
|
|
115
|
+
if (isReloading.value) {
|
|
116
|
+
// 重新加载完成后,下次请求应该是第2页
|
|
117
|
+
pageNum.value = 2;
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
// 加载更多完成后,页码递增
|
|
121
|
+
pageNum.value += 1;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return [2 /*return*/];
|
|
125
|
+
}
|
|
126
|
+
});
|
|
67
127
|
});
|
|
68
|
-
loading.value = false;
|
|
69
|
-
if (!res) {
|
|
70
|
-
hasMore.value = false;
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
// 根据是否是重新加载来决定如何处理数据
|
|
74
|
-
if (isReloading.value) {
|
|
75
|
-
// 重新加载第一页:直接替换整个数组
|
|
76
|
-
listData.value = res.records || [];
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
// 加载更多:追加到现有数组
|
|
80
|
-
listData.value = listData.value.concat(res.records || []);
|
|
81
|
-
}
|
|
82
|
-
hasMore.value =
|
|
83
|
-
res.hasMore ??
|
|
84
|
-
(res.total
|
|
85
|
-
? res.total > listData.value.length
|
|
86
|
-
: (res.records || []).length >= props.defaultPageSize);
|
|
87
|
-
// 更新页码逻辑
|
|
88
|
-
if (hasMore.value) {
|
|
89
|
-
if (isReloading.value) {
|
|
90
|
-
// 重新加载完成后,下次请求应该是第2页
|
|
91
|
-
pageNum.value = 2;
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
// 加载更多完成后,页码递增
|
|
95
|
-
pageNum.value += 1;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
128
|
}
|
|
99
129
|
__expose({
|
|
100
|
-
reloadAndRest,
|
|
130
|
+
reloadAndRest: reloadAndRest,
|
|
101
131
|
loadMore: getListData,
|
|
102
132
|
});
|
|
103
|
-
return (_ctx, _cache)
|
|
133
|
+
return function (_ctx, _cache) {
|
|
104
134
|
return (vue.openBlock(), vue.createBlock(vue.unref(vant.PullRefresh), {
|
|
105
135
|
modelValue: refresh.value,
|
|
106
|
-
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event)
|
|
136
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = function ($event) { return ((refresh).value = $event); }),
|
|
107
137
|
onRefresh: refreshData
|
|
108
138
|
}, {
|
|
109
|
-
default: vue.withCtx(()
|
|
139
|
+
default: vue.withCtx(function () { return [
|
|
110
140
|
vue.createVNode(vue.unref(vant.List), {
|
|
111
141
|
finished: !hasMore.value,
|
|
112
142
|
onLoad: getListData,
|
|
113
143
|
loading: showListLoading.value,
|
|
114
144
|
class: "list"
|
|
115
145
|
}, {
|
|
116
|
-
default: vue.withCtx(()
|
|
117
|
-
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(listData.value, (item)
|
|
146
|
+
default: vue.withCtx(function () { return [
|
|
147
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(listData.value, function (item) {
|
|
118
148
|
return (vue.openBlock(), vue.createElementBlock(vue.Fragment, {
|
|
119
149
|
key: item[props.rowKey || 'id']
|
|
120
150
|
}, [
|
|
@@ -124,42 +154,41 @@ var script = /*@__PURE__*/ vue.defineComponent({
|
|
|
124
154
|
}), 128 /* KEYED_FRAGMENT */)),
|
|
125
155
|
vue.createCommentVNode(" 空数据状态 - 只在非加载状态且非刷新状态下显示 "),
|
|
126
156
|
(!loading.value && !refresh.value && !hasMore.value && !listData.value.length)
|
|
127
|
-
? vue.renderSlot(_ctx.$slots, "empty", { key: 0 }, ()
|
|
157
|
+
? vue.renderSlot(_ctx.$slots, "empty", { key: 0 }, function () { return [
|
|
128
158
|
vue.createVNode(vue.unref(vant.Empty), {
|
|
129
159
|
description: "暂无数据",
|
|
130
160
|
"image-size": 80,
|
|
131
161
|
style: { "margin-top": "20px" }
|
|
132
162
|
}, {
|
|
133
|
-
image: vue.withCtx(()
|
|
163
|
+
image: vue.withCtx(function () { return _cache[1] || (_cache[1] = [
|
|
134
164
|
vue.createElementVNode("img", {
|
|
135
165
|
src: "data:image/png;base64,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",
|
|
136
166
|
alt: ""
|
|
137
167
|
}, null, -1 /* CACHED */)
|
|
138
|
-
])),
|
|
168
|
+
]); }),
|
|
139
169
|
_: 1 /* STABLE */
|
|
140
170
|
})
|
|
141
|
-
])
|
|
171
|
+
]; })
|
|
142
172
|
: vue.createCommentVNode("v-if", true),
|
|
143
173
|
vue.createCommentVNode(" 下拉刷新时的加载状态(当数据为空时) "),
|
|
144
174
|
(refresh.value && !listData.value.length)
|
|
145
175
|
? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
|
|
146
176
|
vue.createVNode(vue.unref(loading), { size: "24px" }, {
|
|
147
|
-
default: vue.withCtx(()
|
|
177
|
+
default: vue.withCtx(function () { return _cache[2] || (_cache[2] = [
|
|
148
178
|
vue.createTextVNode("加载中...")
|
|
149
|
-
])),
|
|
179
|
+
]); }),
|
|
150
180
|
_: 1 /* STABLE */,
|
|
151
181
|
__: [2]
|
|
152
182
|
})
|
|
153
183
|
]))
|
|
154
184
|
: vue.createCommentVNode("v-if", true)
|
|
155
|
-
]),
|
|
185
|
+
]; }),
|
|
156
186
|
_: 3 /* FORWARDED */
|
|
157
187
|
}, 8 /* PROPS */, ["finished", "loading"])
|
|
158
|
-
]),
|
|
188
|
+
]; }),
|
|
159
189
|
_: 3 /* FORWARDED */
|
|
160
190
|
}, 8 /* PROPS */, ["modelValue"]));
|
|
161
191
|
};
|
|
162
|
-
}
|
|
163
|
-
});
|
|
192
|
+
} }));
|
|
164
193
|
|
|
165
194
|
exports.default = script;
|
|
@@ -2,58 +2,82 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var _tslib = require('../_virtual/_tslib.js');
|
|
5
6
|
var cryptoJs = require('crypto-js');
|
|
6
7
|
var xh = require('xinhua-sdk');
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
var ClientSign = /** @class */ (function () {
|
|
10
|
+
function ClientSign() {
|
|
11
|
+
}
|
|
9
12
|
/**
|
|
10
13
|
* ASE 解密
|
|
11
14
|
* 使用加密秘钥,对 需要解密的参数 进行解密
|
|
12
15
|
* @param content - 需要解密的参数
|
|
13
16
|
* @param params - 加密信息
|
|
14
17
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
Object.defineProperty(ClientSign, "aesDecryptParams", {
|
|
19
|
+
enumerable: false,
|
|
20
|
+
configurable: true,
|
|
21
|
+
writable: true,
|
|
22
|
+
value: function (content, params) {
|
|
23
|
+
var key = params.key, offset = params.offset;
|
|
24
|
+
if (!key || !offset) {
|
|
25
|
+
throw new Error('缺少加密相关配置');
|
|
26
|
+
}
|
|
27
|
+
// 密钥 - 从 UTF-8 编码 解析出原始字符串
|
|
28
|
+
var keyUTF8 = cryptoJs.enc.Utf8.parse(key);
|
|
29
|
+
// 偏移量(在此公司内是固定的) - 从 UTF-8编码 解析出原始字符串
|
|
30
|
+
var offsetUTF8 = cryptoJs.enc.Utf8.parse(offset);
|
|
31
|
+
var bytes = cryptoJs.AES.decrypt(content, keyUTF8, {
|
|
32
|
+
iv: offsetUTF8,
|
|
33
|
+
mode: cryptoJs.mode.CBC,
|
|
34
|
+
padding: cryptoJs.pad.Pkcs7,
|
|
35
|
+
});
|
|
36
|
+
return bytes.toString(cryptoJs.enc.Utf8);
|
|
19
37
|
}
|
|
20
|
-
|
|
21
|
-
const keyUTF8 = cryptoJs.enc.Utf8.parse(key);
|
|
22
|
-
// 偏移量(在此公司内是固定的) - 从 UTF-8编码 解析出原始字符串
|
|
23
|
-
const offsetUTF8 = cryptoJs.enc.Utf8.parse(offset);
|
|
24
|
-
const bytes = cryptoJs.AES.decrypt(content, keyUTF8, {
|
|
25
|
-
iv: offsetUTF8,
|
|
26
|
-
mode: cryptoJs.mode.CBC,
|
|
27
|
-
padding: cryptoJs.pad.Pkcs7,
|
|
28
|
-
});
|
|
29
|
-
return bytes.toString(cryptoJs.enc.Utf8);
|
|
30
|
-
}
|
|
38
|
+
});
|
|
31
39
|
/**
|
|
32
40
|
* 获取客户端签名
|
|
33
41
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
Object.defineProperty(ClientSign, "getClientSign", {
|
|
43
|
+
enumerable: false,
|
|
44
|
+
configurable: true,
|
|
45
|
+
writable: true,
|
|
46
|
+
value: function (options) {
|
|
47
|
+
return _tslib.__awaiter(this, void 0, void 0, function () {
|
|
48
|
+
var developmentClientSign, key, offset, moduleCode, clientSignInfo;
|
|
49
|
+
return _tslib.__generator(this, function (_a) {
|
|
50
|
+
switch (_a.label) {
|
|
51
|
+
case 0:
|
|
52
|
+
developmentClientSign = options.developmentClientSign, key = options.key, offset = options.offset, moduleCode = options.moduleCode;
|
|
53
|
+
if (process.env.NODE_ENV === 'development' && developmentClientSign) {
|
|
54
|
+
return [2 /*return*/, developmentClientSign];
|
|
55
|
+
}
|
|
56
|
+
if (!xh.isMediaConvergenceXinhuaApp()) {
|
|
57
|
+
return [2 /*return*/, {
|
|
58
|
+
sign: '',
|
|
59
|
+
subDomain: '',
|
|
60
|
+
}];
|
|
61
|
+
}
|
|
62
|
+
return [4 /*yield*/, new Promise(function (resolve) {
|
|
63
|
+
xh.getClientSign({
|
|
64
|
+
moduleCode: moduleCode,
|
|
65
|
+
success: function (res) { return resolve(res); },
|
|
66
|
+
});
|
|
67
|
+
})];
|
|
68
|
+
case 1:
|
|
69
|
+
clientSignInfo = _a.sent();
|
|
70
|
+
return [2 /*return*/, {
|
|
71
|
+
sign: this.aesDecryptParams(clientSignInfo.cs, { key: key, offset: offset }),
|
|
72
|
+
subDomain: clientSignInfo.subDomain,
|
|
73
|
+
siteId: clientSignInfo.siteId,
|
|
74
|
+
}];
|
|
75
|
+
}
|
|
76
|
+
});
|
|
49
77
|
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
siteId: clientSignInfo.siteId,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
return ClientSign;
|
|
81
|
+
}());
|
|
58
82
|
|
|
59
83
|
exports.default = ClientSign;
|
|
@@ -2,106 +2,173 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var _tslib = require('../_virtual/_tslib.js');
|
|
5
6
|
var jsMd5 = require('js-md5');
|
|
6
7
|
var xh = require('xinhua-sdk');
|
|
7
8
|
var index = require('../getValueFromUA/index.js');
|
|
8
9
|
var ClientSign = require('./ClientSign.js');
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
static initStatus = false;
|
|
13
|
-
/** 站点 id */
|
|
14
|
-
static state = {
|
|
15
|
-
siteId: '',
|
|
16
|
-
userId: '',
|
|
17
|
-
statusBarHeight: 0,
|
|
18
|
-
clientSign: {
|
|
19
|
-
sign: '',
|
|
20
|
-
subDomain: '',
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
/** 初始化信息 */
|
|
24
|
-
static initOptions;
|
|
25
|
-
static init(options) {
|
|
26
|
-
this.initOptions = options;
|
|
11
|
+
var XinhuaClient = /** @class */ (function () {
|
|
12
|
+
function XinhuaClient() {
|
|
27
13
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
...initOptions.developmentState,
|
|
35
|
-
};
|
|
14
|
+
Object.defineProperty(XinhuaClient, "init", {
|
|
15
|
+
enumerable: false,
|
|
16
|
+
configurable: true,
|
|
17
|
+
writable: true,
|
|
18
|
+
value: function (options) {
|
|
19
|
+
this.initOptions = options;
|
|
36
20
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(XinhuaClient, "stateInit", {
|
|
23
|
+
enumerable: false,
|
|
24
|
+
configurable: true,
|
|
25
|
+
writable: true,
|
|
26
|
+
value: function () {
|
|
27
|
+
var _a;
|
|
28
|
+
return _tslib.__awaiter(this, void 0, void 0, function () {
|
|
29
|
+
var initOptions, isClientDebug, userInfo, numberStatusBarHeight, _b;
|
|
30
|
+
return _tslib.__generator(this, function (_c) {
|
|
31
|
+
switch (_c.label) {
|
|
32
|
+
case 0:
|
|
33
|
+
initOptions = this.initOptions;
|
|
34
|
+
if (process.env.NODE_ENV === 'development' && initOptions.developmentState) {
|
|
35
|
+
// 本地开发、配置的本地开发环境的数据
|
|
36
|
+
this.state = _tslib.__assign(_tslib.__assign({}, this.state), initOptions.developmentState);
|
|
37
|
+
}
|
|
38
|
+
isClientDebug = process.env.NODE_ENV === 'development' && initOptions.clientDebug;
|
|
39
|
+
if (!(xh.isMediaConvergenceXinhuaApp() && !isClientDebug)) return [3 /*break*/, 3];
|
|
40
|
+
// 客户端环境
|
|
41
|
+
this.state.siteId = index.default('currentSiteId');
|
|
42
|
+
return [4 /*yield*/, new Promise(function (resolve) {
|
|
43
|
+
var _a;
|
|
44
|
+
xh.getUserInfo({
|
|
45
|
+
goLogin: (_a = initOptions.goLogin) !== null && _a !== void 0 ? _a : false,
|
|
46
|
+
success: function (res) { return resolve(res); },
|
|
47
|
+
});
|
|
48
|
+
})];
|
|
49
|
+
case 1:
|
|
50
|
+
userInfo = _c.sent();
|
|
51
|
+
this.state.userId = (_a = userInfo === null || userInfo === void 0 ? void 0 : userInfo.info) === null || _a === void 0 ? void 0 : _a.id;
|
|
52
|
+
numberStatusBarHeight = Number(index.default('statusBarHeight'));
|
|
53
|
+
this.state.statusBarHeight = isNaN(numberStatusBarHeight) ? 0 : numberStatusBarHeight;
|
|
54
|
+
_b = this.state;
|
|
55
|
+
return [4 /*yield*/, ClientSign.default.getClientSign({
|
|
56
|
+
key: initOptions.clientSign.key,
|
|
57
|
+
offset: initOptions.clientSign.offset,
|
|
58
|
+
moduleCode: initOptions.clientSign.moduleCode,
|
|
59
|
+
})];
|
|
60
|
+
case 2:
|
|
61
|
+
_b.clientSign = _c.sent();
|
|
62
|
+
_c.label = 3;
|
|
63
|
+
case 3:
|
|
64
|
+
this.initStatus = true;
|
|
65
|
+
return [2 /*return*/];
|
|
66
|
+
}
|
|
45
67
|
});
|
|
46
68
|
});
|
|
47
|
-
this.state.userId = userInfo?.info?.id;
|
|
48
|
-
const numberStatusBarHeight = Number(index.default('statusBarHeight'));
|
|
49
|
-
this.state.statusBarHeight = isNaN(numberStatusBarHeight) ? 0 : numberStatusBarHeight;
|
|
50
|
-
this.state.clientSign = await ClientSign.default.getClientSign({
|
|
51
|
-
key: initOptions.clientSign.key,
|
|
52
|
-
offset: initOptions.clientSign.offset,
|
|
53
|
-
moduleCode: initOptions.clientSign.moduleCode,
|
|
54
|
-
});
|
|
55
69
|
}
|
|
56
|
-
|
|
57
|
-
}
|
|
70
|
+
});
|
|
58
71
|
/**
|
|
59
72
|
* 设置数据
|
|
60
73
|
*/
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
74
|
+
Object.defineProperty(XinhuaClient, "setState", {
|
|
75
|
+
enumerable: false,
|
|
76
|
+
configurable: true,
|
|
77
|
+
writable: true,
|
|
78
|
+
value: function (state) {
|
|
79
|
+
this.state = _tslib.__assign(_tslib.__assign({}, this.state), state);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
67
82
|
/**
|
|
68
83
|
* 使用数据状态
|
|
69
84
|
*/
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
85
|
+
Object.defineProperty(XinhuaClient, "useState", {
|
|
86
|
+
enumerable: false,
|
|
87
|
+
configurable: true,
|
|
88
|
+
writable: true,
|
|
89
|
+
value: function () {
|
|
90
|
+
return _tslib.__awaiter(this, void 0, void 0, function () {
|
|
91
|
+
return _tslib.__generator(this, function (_a) {
|
|
92
|
+
switch (_a.label) {
|
|
93
|
+
case 0:
|
|
94
|
+
if (!!this.initStatus) return [3 /*break*/, 2];
|
|
95
|
+
return [4 /*yield*/, this.stateInit()];
|
|
96
|
+
case 1:
|
|
97
|
+
_a.sent();
|
|
98
|
+
_a.label = 2;
|
|
99
|
+
case 2: return [2 /*return*/, this.state];
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
});
|
|
73
103
|
}
|
|
74
|
-
|
|
75
|
-
}
|
|
104
|
+
});
|
|
76
105
|
/**
|
|
77
106
|
* 生成签名参数
|
|
78
107
|
*/
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
108
|
+
Object.defineProperty(XinhuaClient, "getSignRequestParams", {
|
|
109
|
+
enumerable: false,
|
|
110
|
+
configurable: true,
|
|
111
|
+
writable: true,
|
|
112
|
+
value: function (params) {
|
|
113
|
+
return _tslib.__awaiter(this, void 0, void 0, function () {
|
|
114
|
+
var requestParams, initialState, paramsArr;
|
|
115
|
+
return _tslib.__generator(this, function (_a) {
|
|
116
|
+
switch (_a.label) {
|
|
117
|
+
case 0:
|
|
118
|
+
if (!!this.initStatus) return [3 /*break*/, 2];
|
|
119
|
+
return [4 /*yield*/, this.stateInit()];
|
|
120
|
+
case 1:
|
|
121
|
+
_a.sent();
|
|
122
|
+
_a.label = 2;
|
|
123
|
+
case 2:
|
|
124
|
+
requestParams = _tslib.__assign({}, params), initialState = this.state;
|
|
125
|
+
if (initialState.userId) {
|
|
126
|
+
requestParams.userId = initialState.userId;
|
|
127
|
+
}
|
|
128
|
+
if (initialState.siteId) {
|
|
129
|
+
requestParams.siteId = initialState.siteId;
|
|
130
|
+
}
|
|
131
|
+
requestParams.currentTimeMillis = new Date().getTime();
|
|
132
|
+
if (initialState.clientSign && initialState.clientSign.sign) {
|
|
133
|
+
paramsArr = Object.values(requestParams).map(function (item) {
|
|
134
|
+
if (item && typeof item === 'object') {
|
|
135
|
+
return JSON.stringify(item);
|
|
136
|
+
}
|
|
137
|
+
return item;
|
|
138
|
+
});
|
|
139
|
+
paramsArr.push(initialState.clientSign.sign);
|
|
140
|
+
paramsArr.sort();
|
|
141
|
+
requestParams.signature = jsMd5.md5(paramsArr.join(''));
|
|
142
|
+
}
|
|
143
|
+
return [2 /*return*/, requestParams];
|
|
144
|
+
}
|
|
145
|
+
});
|
|
97
146
|
});
|
|
98
|
-
paramsArr.push(initialState.clientSign.sign);
|
|
99
|
-
paramsArr.sort();
|
|
100
|
-
requestParams.signature = jsMd5.md5(paramsArr.join(''));
|
|
101
147
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
148
|
+
});
|
|
149
|
+
/** 数据初始化是否完成 */
|
|
150
|
+
Object.defineProperty(XinhuaClient, "initStatus", {
|
|
151
|
+
enumerable: true,
|
|
152
|
+
configurable: true,
|
|
153
|
+
writable: true,
|
|
154
|
+
value: false
|
|
155
|
+
});
|
|
156
|
+
/** 站点 id */
|
|
157
|
+
Object.defineProperty(XinhuaClient, "state", {
|
|
158
|
+
enumerable: true,
|
|
159
|
+
configurable: true,
|
|
160
|
+
writable: true,
|
|
161
|
+
value: {
|
|
162
|
+
siteId: '',
|
|
163
|
+
userId: '',
|
|
164
|
+
statusBarHeight: 0,
|
|
165
|
+
clientSign: {
|
|
166
|
+
sign: '',
|
|
167
|
+
subDomain: '',
|
|
168
|
+
},
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
return XinhuaClient;
|
|
172
|
+
}());
|
|
106
173
|
|
|
107
174
|
exports.default = XinhuaClient;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/******************************************************************************
|
|
4
|
+
Copyright (c) Microsoft Corporation.
|
|
5
|
+
|
|
6
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
7
|
+
purpose with or without fee is hereby granted.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
+
***************************************************************************** */
|
|
17
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
exports.__assign = function() {
|
|
21
|
+
exports.__assign = Object.assign || function __assign(t) {
|
|
22
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
23
|
+
s = arguments[i];
|
|
24
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
25
|
+
}
|
|
26
|
+
return t;
|
|
27
|
+
};
|
|
28
|
+
return exports.__assign.apply(this, arguments);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
32
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
33
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
34
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
35
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
36
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
37
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function __generator(thisArg, body) {
|
|
42
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
43
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
44
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
45
|
+
function step(op) {
|
|
46
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
47
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
48
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
49
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
50
|
+
switch (op[0]) {
|
|
51
|
+
case 0: case 1: t = op; break;
|
|
52
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
53
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
54
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
55
|
+
default:
|
|
56
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
57
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
58
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
59
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
60
|
+
if (t[2]) _.ops.pop();
|
|
61
|
+
_.trys.pop(); continue;
|
|
62
|
+
}
|
|
63
|
+
op = body.call(thisArg, _);
|
|
64
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
65
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
70
|
+
var e = new Error(message);
|
|
71
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
exports.__awaiter = __awaiter;
|
|
75
|
+
exports.__generator = __generator;
|
|
@@ -6,12 +6,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
6
6
|
* 从 ua 中根据 key 获取信息
|
|
7
7
|
*/
|
|
8
8
|
function getValueFromUA(name) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
var userAgent = window.navigator.userAgent;
|
|
10
|
+
var userAgentArr = userAgent.split(' ');
|
|
11
|
+
var uaValue = '';
|
|
12
12
|
if (userAgentArr) {
|
|
13
|
-
for (
|
|
14
|
-
|
|
13
|
+
for (var index in userAgentArr) {
|
|
14
|
+
var item = userAgentArr[index];
|
|
15
15
|
if (item.startsWith(name + '/')) {
|
|
16
16
|
uaValue = item.split('/')[1];
|
|
17
17
|
break;
|
package/lib/resolver.js
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
function RexmaDesignResolver() {
|
|
4
4
|
return {
|
|
5
5
|
type: 'component',
|
|
6
|
-
resolve: (name)
|
|
6
|
+
resolve: function (name) {
|
|
7
7
|
if (name.startsWith('Rma')) {
|
|
8
8
|
return {
|
|
9
|
-
name,
|
|
9
|
+
name: name,
|
|
10
10
|
from: 'rexma-design',
|
|
11
|
-
sideEffects:
|
|
11
|
+
sideEffects: "rexma-design/es/".concat(name, "/style/index"),
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
},
|
package/lib/useOnShow/index.js
CHANGED
|
@@ -5,22 +5,22 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var vue = require('vue');
|
|
6
6
|
|
|
7
7
|
function useOnShow(callback) {
|
|
8
|
-
|
|
8
|
+
var isVisible = vue.ref(true);
|
|
9
9
|
// 监听页面可见性变化
|
|
10
|
-
|
|
10
|
+
var handleVisibilityChange = function () {
|
|
11
11
|
isVisible.value = document.visibilityState === 'visible';
|
|
12
12
|
if (isVisible.value) {
|
|
13
13
|
callback();
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
|
-
vue.onMounted(()
|
|
16
|
+
vue.onMounted(function () {
|
|
17
17
|
document.addEventListener('visibilitychange', handleVisibilityChange);
|
|
18
18
|
// 初始执行一次
|
|
19
19
|
if (document.visibilityState === 'visible') {
|
|
20
20
|
callback();
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
|
-
vue.onBeforeUnmount(()
|
|
23
|
+
vue.onBeforeUnmount(function () {
|
|
24
24
|
document.removeEventListener('visibilitychange', handleVisibilityChange);
|
|
25
25
|
});
|
|
26
26
|
}
|
|
@@ -2,14 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var _tslib = require('../_virtual/_tslib.js');
|
|
5
6
|
var vue = require('vue');
|
|
6
7
|
|
|
7
|
-
function usePullDownRefresh(options
|
|
8
|
+
function usePullDownRefresh(options) {
|
|
9
|
+
var _this = this;
|
|
10
|
+
if (options === void 0) { options = {}; }
|
|
8
11
|
// 处理参数:如果直接传递函数,则认为是 onRefresh 回调
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
var normalizedOptions = typeof options === 'function' ? { onRefresh: options } : options;
|
|
13
|
+
var _a = normalizedOptions.threshold, threshold = _a === void 0 ? 60 : _a, _b = normalizedOptions.maxDistance, maxDistance = _b === void 0 ? 120 : _b, onRefresh = normalizedOptions.onRefresh, _c = normalizedOptions.disabled, disabled = _c === void 0 ? false : _c, _d = normalizedOptions.showIndicator, showIndicator = _d === void 0 ? true : _d;
|
|
11
14
|
// 响应式状态
|
|
12
|
-
|
|
15
|
+
var state = vue.ref({
|
|
13
16
|
status: 'normal',
|
|
14
17
|
distance: 0,
|
|
15
18
|
indicatorVisible: false,
|
|
@@ -17,133 +20,60 @@ function usePullDownRefresh(options = {}) {
|
|
|
17
20
|
indicatorRotation: 0,
|
|
18
21
|
});
|
|
19
22
|
// 触摸相关状态
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
var startY = 0;
|
|
24
|
+
var currentY = 0;
|
|
25
|
+
var isTracking = false;
|
|
26
|
+
var originalBodyStyle = '';
|
|
27
|
+
var indicatorElement = null;
|
|
25
28
|
// 创建顶部指示器元素
|
|
26
|
-
|
|
29
|
+
var createIndicator = function () {
|
|
27
30
|
if (!showIndicator || indicatorElement)
|
|
28
31
|
return;
|
|
29
32
|
indicatorElement = document.createElement('div');
|
|
30
33
|
indicatorElement.className = 'pull-refresh-indicator';
|
|
31
|
-
indicatorElement.innerHTML =
|
|
32
|
-
<div class="indicator-circle">
|
|
33
|
-
<div class="indicator-icon">
|
|
34
|
-
<svg width="20" height="20" viewBox="0 0 24 24" fill="none">
|
|
35
|
-
<path d="M12 4L12 20M12 4L8 8M12 4L16 8" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
36
|
-
</svg>
|
|
37
|
-
</div>
|
|
38
|
-
</div>
|
|
39
|
-
`;
|
|
34
|
+
indicatorElement.innerHTML = "\n <div class=\"indicator-circle\">\n <div class=\"indicator-icon\">\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\">\n <path d=\"M12 4L12 20M12 4L8 8M12 4L16 8\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n </svg>\n </div>\n </div>\n ";
|
|
40
35
|
// 添加样式
|
|
41
|
-
|
|
42
|
-
style.textContent =
|
|
43
|
-
.pull-refresh-indicator {
|
|
44
|
-
position: fixed;
|
|
45
|
-
top: 20px;
|
|
46
|
-
left: 50%;
|
|
47
|
-
transform: translateX(-50%) translateY(-100px);
|
|
48
|
-
z-index: 9999;
|
|
49
|
-
opacity: 0;
|
|
50
|
-
transition: opacity 0.3s ease, transform 0.3s ease;
|
|
51
|
-
pointer-events: none;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.pull-refresh-indicator.visible {
|
|
55
|
-
opacity: 1;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.indicator-circle {
|
|
59
|
-
width: 40px;
|
|
60
|
-
height: 40px;
|
|
61
|
-
background: #ffffff;
|
|
62
|
-
border-radius: 50%;
|
|
63
|
-
display: flex;
|
|
64
|
-
align-items: center;
|
|
65
|
-
justify-content: center;
|
|
66
|
-
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
|
|
67
|
-
border: 1px solid rgba(0, 0, 0, 0.06);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.indicator-icon {
|
|
71
|
-
display: flex;
|
|
72
|
-
align-items: center;
|
|
73
|
-
justify-content: center;
|
|
74
|
-
width: 20px;
|
|
75
|
-
height: 20px;
|
|
76
|
-
color: #1677ff;
|
|
77
|
-
transition: transform 0.3s ease;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.indicator-icon.rotate {
|
|
81
|
-
transform: rotate(180deg);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
.indicator-icon.loading {
|
|
85
|
-
animation: spin 1s linear infinite;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
@keyframes spin {
|
|
89
|
-
from { transform: rotate(0deg); }
|
|
90
|
-
to { transform: rotate(360deg); }
|
|
91
|
-
}
|
|
92
|
-
`;
|
|
36
|
+
var style = document.createElement('style');
|
|
37
|
+
style.textContent = "\n .pull-refresh-indicator {\n position: fixed;\n top: 20px;\n left: 50%;\n transform: translateX(-50%) translateY(-100px);\n z-index: 9999;\n opacity: 0;\n transition: opacity 0.3s ease, transform 0.3s ease;\n pointer-events: none;\n }\n \n .pull-refresh-indicator.visible {\n opacity: 1;\n }\n \n .indicator-circle {\n width: 40px;\n height: 40px;\n background: #ffffff;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);\n border: 1px solid rgba(0, 0, 0, 0.06);\n }\n \n .indicator-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 20px;\n height: 20px;\n color: #1677ff;\n transition: transform 0.3s ease;\n }\n \n .indicator-icon.rotate {\n transform: rotate(180deg);\n }\n \n .indicator-icon.loading {\n animation: spin 1s linear infinite;\n }\n \n @keyframes spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n }\n ";
|
|
93
38
|
document.head.appendChild(style);
|
|
94
39
|
document.body.appendChild(indicatorElement);
|
|
95
40
|
};
|
|
96
41
|
// 更新指示器
|
|
97
|
-
|
|
42
|
+
var updateIndicator = function () {
|
|
98
43
|
if (!indicatorElement || !showIndicator)
|
|
99
44
|
return;
|
|
100
|
-
|
|
45
|
+
var iconElement = indicatorElement.querySelector('.indicator-icon');
|
|
101
46
|
if (iconElement) {
|
|
102
47
|
iconElement.className = 'indicator-icon';
|
|
103
48
|
if (state.value.status === 'loading') {
|
|
104
49
|
iconElement.classList.add('loading');
|
|
105
|
-
iconElement.innerHTML =
|
|
106
|
-
<svg width="20" height="20" viewBox="0 0 24 24" fill="none">
|
|
107
|
-
<circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2" stroke-dasharray="31.416" stroke-dashoffset="31.416">
|
|
108
|
-
<animate attributeName="stroke-dasharray" dur="2s" values="0 31.416;15.708 15.708;0 31.416" repeatCount="indefinite"/>
|
|
109
|
-
<animate attributeName="stroke-dashoffset" dur="2s" values="0;-15.708;-31.416" repeatCount="indefinite"/>
|
|
110
|
-
</circle>
|
|
111
|
-
</svg>
|
|
112
|
-
`;
|
|
50
|
+
iconElement.innerHTML = "\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\">\n <circle cx=\"12\" cy=\"12\" r=\"10\" stroke=\"currentColor\" stroke-width=\"2\" stroke-dasharray=\"31.416\" stroke-dashoffset=\"31.416\">\n <animate attributeName=\"stroke-dasharray\" dur=\"2s\" values=\"0 31.416;15.708 15.708;0 31.416\" repeatCount=\"indefinite\"/>\n <animate attributeName=\"stroke-dashoffset\" dur=\"2s\" values=\"0;-15.708;-31.416\" repeatCount=\"indefinite\"/>\n </circle>\n </svg>\n ";
|
|
113
51
|
}
|
|
114
52
|
else if (state.value.status === 'success') {
|
|
115
|
-
iconElement.innerHTML =
|
|
116
|
-
<svg width="20" height="20" viewBox="0 0 24 24" fill="none">
|
|
117
|
-
<path d="M20 6L9 17L4 12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
118
|
-
</svg>
|
|
119
|
-
`;
|
|
53
|
+
iconElement.innerHTML = "\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\">\n <path d=\"M20 6L9 17L4 12\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n </svg>\n ";
|
|
120
54
|
}
|
|
121
55
|
else {
|
|
122
56
|
if (state.value.status === 'loosing') {
|
|
123
57
|
iconElement.classList.add('rotate');
|
|
124
58
|
}
|
|
125
|
-
iconElement.innerHTML =
|
|
126
|
-
<svg width="20" height="20" viewBox="0 0 24 24" fill="none">
|
|
127
|
-
<path d="M12 4L12 20M12 4L8 8M12 4L16 8" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
128
|
-
</svg>
|
|
129
|
-
`;
|
|
59
|
+
iconElement.innerHTML = "\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\">\n <path d=\"M12 4L12 20M12 4L8 8M12 4L16 8\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n </svg>\n ";
|
|
130
60
|
}
|
|
131
61
|
}
|
|
132
62
|
// 更新指示器位置和透明度
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
indicatorElement.style.transform =
|
|
136
|
-
indicatorElement.className =
|
|
63
|
+
var progress = Math.min(state.value.distance / threshold, 1);
|
|
64
|
+
var translateY = -100 + progress * 120; // 从 -100px 移动到 20px
|
|
65
|
+
indicatorElement.style.transform = "translateX(-50%) translateY(".concat(translateY, "px)");
|
|
66
|
+
indicatorElement.className = "pull-refresh-indicator ".concat(state.value.distance > 0 ? 'visible' : '');
|
|
137
67
|
};
|
|
138
68
|
// 移除指示器
|
|
139
|
-
|
|
69
|
+
var removeIndicator = function () {
|
|
140
70
|
if (indicatorElement) {
|
|
141
71
|
indicatorElement.remove();
|
|
142
72
|
indicatorElement = null;
|
|
143
73
|
}
|
|
144
74
|
};
|
|
145
75
|
// 更新状态
|
|
146
|
-
|
|
76
|
+
var updateState = function (status, distance) {
|
|
147
77
|
state.value.status = status;
|
|
148
78
|
state.value.distance = distance;
|
|
149
79
|
state.value.indicatorVisible = distance > 0;
|
|
@@ -169,7 +99,7 @@ function usePullDownRefresh(options = {}) {
|
|
|
169
99
|
updateIndicator();
|
|
170
100
|
};
|
|
171
101
|
// 禁用页面弹性效果
|
|
172
|
-
|
|
102
|
+
var disableBodyBounce = function () {
|
|
173
103
|
originalBodyStyle = document.body.style.cssText;
|
|
174
104
|
document.body.style.overscrollBehavior = 'none';
|
|
175
105
|
document.body.style.touchAction = 'pan-x pan-down pinch-zoom';
|
|
@@ -177,37 +107,37 @@ function usePullDownRefresh(options = {}) {
|
|
|
177
107
|
document.documentElement.style.touchAction = 'pan-x pan-down pinch-zoom';
|
|
178
108
|
};
|
|
179
109
|
// 恢复页面弹性效果
|
|
180
|
-
|
|
110
|
+
var restoreBodyBounce = function () {
|
|
181
111
|
document.body.style.cssText = originalBodyStyle;
|
|
182
112
|
document.documentElement.style.overscrollBehavior = '';
|
|
183
113
|
document.documentElement.style.touchAction = '';
|
|
184
114
|
};
|
|
185
115
|
// 检查是否可以下拉(页面级检查)
|
|
186
|
-
|
|
116
|
+
var canPullDown = function () {
|
|
187
117
|
if (disabled)
|
|
188
118
|
return false;
|
|
189
119
|
// 检查页面是否滚动到顶部
|
|
190
|
-
|
|
120
|
+
var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
|
|
191
121
|
return scrollTop === 0;
|
|
192
122
|
};
|
|
193
123
|
// 触摸开始
|
|
194
|
-
|
|
124
|
+
var onTouchStart = function (event) {
|
|
195
125
|
if (!canPullDown())
|
|
196
126
|
return;
|
|
197
127
|
startY = event.touches[0].clientY;
|
|
198
128
|
isTracking = true;
|
|
199
129
|
};
|
|
200
130
|
// 触摸移动
|
|
201
|
-
|
|
131
|
+
var onTouchMove = function (event) {
|
|
202
132
|
if (!isTracking || !canPullDown())
|
|
203
133
|
return;
|
|
204
134
|
currentY = event.touches[0].clientY;
|
|
205
|
-
|
|
135
|
+
var deltaY = currentY - startY;
|
|
206
136
|
if (deltaY > 0) {
|
|
207
137
|
// 阻止默认滚动行为和弹性效果
|
|
208
138
|
event.preventDefault();
|
|
209
139
|
// 计算下拉距离,使用阻尼效果
|
|
210
|
-
|
|
140
|
+
var distance = Math.min(deltaY * 0.6, maxDistance);
|
|
211
141
|
if (distance >= threshold && state.value.status !== 'loosing') {
|
|
212
142
|
updateState('loosing', distance);
|
|
213
143
|
}
|
|
@@ -221,7 +151,7 @@ function usePullDownRefresh(options = {}) {
|
|
|
221
151
|
}
|
|
222
152
|
};
|
|
223
153
|
// 触摸结束
|
|
224
|
-
|
|
154
|
+
var onTouchEnd = function () {
|
|
225
155
|
if (!isTracking)
|
|
226
156
|
return;
|
|
227
157
|
isTracking = false;
|
|
@@ -235,36 +165,49 @@ function usePullDownRefresh(options = {}) {
|
|
|
235
165
|
}
|
|
236
166
|
};
|
|
237
167
|
// 触发刷新
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
168
|
+
var triggerRefresh = function () { return _tslib.__awaiter(_this, void 0, void 0, function () {
|
|
169
|
+
var error_1;
|
|
170
|
+
return _tslib.__generator(this, function (_a) {
|
|
171
|
+
switch (_a.label) {
|
|
172
|
+
case 0:
|
|
173
|
+
updateState('loading', threshold);
|
|
174
|
+
_a.label = 1;
|
|
175
|
+
case 1:
|
|
176
|
+
_a.trys.push([1, 4, , 5]);
|
|
177
|
+
if (!onRefresh) return [3 /*break*/, 3];
|
|
178
|
+
return [4 /*yield*/, onRefresh()];
|
|
179
|
+
case 2:
|
|
180
|
+
_a.sent();
|
|
181
|
+
_a.label = 3;
|
|
182
|
+
case 3:
|
|
183
|
+
// 显示成功状态
|
|
184
|
+
updateState('success', threshold);
|
|
185
|
+
// 延迟重置状态
|
|
186
|
+
setTimeout(function () {
|
|
187
|
+
resetState();
|
|
188
|
+
}, 500);
|
|
189
|
+
return [3 /*break*/, 5];
|
|
190
|
+
case 4:
|
|
191
|
+
error_1 = _a.sent();
|
|
192
|
+
console.error('下拉刷新失败:', error_1);
|
|
193
|
+
resetState();
|
|
194
|
+
return [3 /*break*/, 5];
|
|
195
|
+
case 5: return [2 /*return*/];
|
|
243
196
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
// 延迟重置状态
|
|
247
|
-
setTimeout(() => {
|
|
248
|
-
resetState();
|
|
249
|
-
}, 500);
|
|
250
|
-
}
|
|
251
|
-
catch (error) {
|
|
252
|
-
console.error('下拉刷新失败:', error);
|
|
253
|
-
resetState();
|
|
254
|
-
}
|
|
255
|
-
};
|
|
197
|
+
});
|
|
198
|
+
}); };
|
|
256
199
|
// 重置状态
|
|
257
|
-
|
|
200
|
+
var resetState = function () {
|
|
258
201
|
updateState('normal', 0);
|
|
259
202
|
};
|
|
260
203
|
// 手动触发刷新
|
|
261
|
-
|
|
204
|
+
var refresh = function () {
|
|
262
205
|
if (disabled || state.value.status === 'loading')
|
|
263
206
|
return;
|
|
264
207
|
triggerRefresh();
|
|
265
208
|
};
|
|
266
209
|
// 组件挂载时添加事件监听和禁用弹性效果
|
|
267
|
-
vue.onMounted(()
|
|
210
|
+
vue.onMounted(function () {
|
|
268
211
|
disableBodyBounce();
|
|
269
212
|
createIndicator();
|
|
270
213
|
document.addEventListener('touchstart', onTouchStart, { passive: false });
|
|
@@ -272,7 +215,7 @@ function usePullDownRefresh(options = {}) {
|
|
|
272
215
|
document.addEventListener('touchend', onTouchEnd);
|
|
273
216
|
});
|
|
274
217
|
// 组件卸载时移除事件监听和恢复弹性效果
|
|
275
|
-
vue.onUnmounted(()
|
|
218
|
+
vue.onUnmounted(function () {
|
|
276
219
|
restoreBodyBounce();
|
|
277
220
|
removeIndicator();
|
|
278
221
|
document.removeEventListener('touchstart', onTouchStart);
|
|
@@ -283,9 +226,9 @@ function usePullDownRefresh(options = {}) {
|
|
|
283
226
|
/** 当前状态 */
|
|
284
227
|
state: vue.readonly(state),
|
|
285
228
|
/** 手动触发刷新 */
|
|
286
|
-
refresh,
|
|
229
|
+
refresh: refresh,
|
|
287
230
|
/** 重置状态 */
|
|
288
|
-
resetState,
|
|
231
|
+
resetState: resetState,
|
|
289
232
|
};
|
|
290
233
|
}
|
|
291
234
|
|
package/package.json
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rexma-design",
|
|
3
|
-
"version": "2.2.0-beta.
|
|
3
|
+
"version": "2.2.0-beta.2",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"start": "vue-cli-service serve",
|
|
6
6
|
"build": "vue-cli-service build",
|
|
7
|
-
"
|
|
7
|
+
"clean:lib": "rm -rf es lib",
|
|
8
|
+
"build:lib": "npm run clean:lib && npm run build:rollup && npm run types:lib",
|
|
8
9
|
"build:rollup": "rollup -c",
|
|
9
10
|
"types:lib": "vue-tsc --p tsconfig.es.json --declaration --emitDeclarationOnly && vue-tsc --p tsconfig.lib.json --declaration --emitDeclarationOnly && node scripts/postbuild-style.cjs",
|
|
10
11
|
"lint": "vue-cli-service lint",
|
|
11
12
|
"prepare": "husky install"
|
|
12
13
|
},
|
|
13
14
|
"sideEffects": [
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
15
|
+
"es/**/style/*",
|
|
16
|
+
"lib/**/style/*",
|
|
17
|
+
"*.css"
|
|
17
18
|
],
|
|
18
19
|
"main": "lib/index.js",
|
|
19
20
|
"module": "es/index.mjs",
|