@cmstops/pro-compo 3.9.2-alpha.24 → 3.9.2-alpha.26

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.
@@ -16,6 +16,13 @@ function generateDocPreviewLink(BASE_API, params) {
16
16
  data: params
17
17
  });
18
18
  }
19
+ function generateDocPreviewLinkPC(BASE_API, params) {
20
+ return request(BASE_API, {
21
+ url: "/poplar/v3/preview/document/generate/pc",
22
+ method: "post",
23
+ data: params
24
+ });
25
+ }
19
26
  function getTimeToNow(second) {
20
27
  second = parseInt((second / 1e3).toFixed(0), 10);
21
28
  function need(value, label) {
@@ -47,22 +54,54 @@ const EXPIRE_TIME_OPTIONS = [
47
54
  function useDocPreview(BASE_API, hashid) {
48
55
  const isPublish = vue.ref(false);
49
56
  const innerUrl = vue.ref("");
57
+ const pcInnerUrl = vue.ref("");
50
58
  const shareData = vue.ref(null);
59
+ const pcShareData = vue.ref(null);
51
60
  const expireTime = vue.ref(60 * 60 * 24);
61
+ const numpc = vue.ref(0);
52
62
  const loading = vue.ref(false);
53
63
  const qrCode = vue.ref("");
54
64
  const intervalTime = vue.ref("");
65
+ const pcIntervalTime = vue.ref("");
55
66
  let interval = null;
67
+ let pcInterval = null;
56
68
  function startInterval() {
57
69
  var _a;
58
70
  if (!((_a = shareData.value) == null ? void 0 : _a.expiredAt)) {
59
71
  clearInterval(interval);
60
72
  interval = null;
73
+ intervalTime.value = "";
61
74
  return;
62
75
  }
63
76
  const now = new Date().getTime();
64
77
  const expire = new Date(shareData.value.expiredAt).getTime();
65
- intervalTime.value = getTimeToNow(expire - now);
78
+ const remaining = expire - now;
79
+ if (remaining <= 0) {
80
+ intervalTime.value = "\u5DF2\u8FC7\u671F";
81
+ clearInterval(interval);
82
+ interval = null;
83
+ return;
84
+ }
85
+ intervalTime.value = getTimeToNow(remaining);
86
+ }
87
+ function startPCInterval() {
88
+ var _a;
89
+ if (!((_a = pcShareData.value) == null ? void 0 : _a.expired_at)) {
90
+ clearInterval(pcInterval);
91
+ pcInterval = null;
92
+ pcIntervalTime.value = "";
93
+ return;
94
+ }
95
+ const now = new Date().getTime();
96
+ const expire = new Date(pcShareData.value.expired_at).getTime();
97
+ const remaining = expire - now;
98
+ if (remaining <= 0) {
99
+ pcIntervalTime.value = "\u5DF2\u8FC7\u671F";
100
+ clearInterval(pcInterval);
101
+ pcInterval = null;
102
+ return;
103
+ }
104
+ pcIntervalTime.value = getTimeToNow(remaining);
66
105
  }
67
106
  function genQrCode(shareUrl, selector) {
68
107
  innerUrl.value = shareUrl;
@@ -103,7 +142,8 @@ function useDocPreview(BASE_API, hashid) {
103
142
  };
104
143
  qrCode.value = base64;
105
144
  innerUrl.value = `${inner_url}?reqTime=${+new Date()}`;
106
- setInterval(startInterval, 1e3);
145
+ interval = setInterval(startInterval, 1e3);
146
+ startInterval();
107
147
  }
108
148
  return true;
109
149
  } catch (e) {
@@ -113,6 +153,50 @@ function useDocPreview(BASE_API, hashid) {
113
153
  loading.value = false;
114
154
  }
115
155
  }
156
+ async function generatePC(cancel2 = false) {
157
+ loading.value = true;
158
+ const params = {
159
+ force: true,
160
+ hash_id: hashid.value,
161
+ expiration: expireTime.value
162
+ };
163
+ if (cancel2)
164
+ params.expiration = 0;
165
+ try {
166
+ const { code, message } = await generateDocPreviewLinkPC(
167
+ BASE_API,
168
+ params
169
+ );
170
+ if (code !== 0)
171
+ return false;
172
+ const { expired_at, share_url, inner_url } = message;
173
+ if (cancel2) {
174
+ pcShareData.value = null;
175
+ pcInnerUrl.value = "";
176
+ clearInterval(pcInterval);
177
+ pcInterval = null;
178
+ pcIntervalTime.value = "";
179
+ } else {
180
+ pcShareData.value = message;
181
+ pcInnerUrl.value = `${inner_url}?reqTime=${+new Date()}`;
182
+ pcInterval = setInterval(startPCInterval, 1e3);
183
+ startPCInterval();
184
+ }
185
+ return true;
186
+ } catch (e) {
187
+ console.log("\u751F\u6210PC\u9884\u89C8\u94FE\u63A5\u5931\u8D25", e);
188
+ return false;
189
+ } finally {
190
+ loading.value = false;
191
+ }
192
+ }
193
+ function previewSite() {
194
+ if (isPublish.value) {
195
+ window.open(pcInnerUrl.value, "_blank");
196
+ } else {
197
+ window.open(pcInnerUrl.value, "_blank");
198
+ }
199
+ }
116
200
  async function cancel(update) {
117
201
  const flag = await generate(true);
118
202
  if (!flag)
@@ -120,6 +204,12 @@ function useDocPreview(BASE_API, hashid) {
120
204
  const text = update ? "\u5DF2\u53D6\u6D88\u9884\u89C8\uFF0C\u8BF7\u66F4\u65B0\u6709\u6548\u671F\u91CD\u65B0\u751F\u6210\u9884\u89C8\u94FE\u63A5" : "\u5DF2\u53D6\u6D88\u9884\u89C8\u94FE\u63A5";
121
205
  webVue.Message.warning(text);
122
206
  }
207
+ async function cancelPc() {
208
+ const flag = await generatePC(true);
209
+ if (!flag)
210
+ return;
211
+ webVue.Message.warning("\u5DF2\u53D6\u6D88\u9884\u89C8\u94FE\u63A5");
212
+ }
123
213
  async function copy() {
124
214
  var _a;
125
215
  if (!((_a = shareData.value) == null ? void 0 : _a.shareUrl))
@@ -129,20 +219,42 @@ function useDocPreview(BASE_API, hashid) {
129
219
  webVue.Message.success("\u590D\u5236\u6210\u529F");
130
220
  }
131
221
  }
222
+ async function copyPC() {
223
+ var _a;
224
+ if (!((_a = pcShareData.value) == null ? void 0 : _a.shareUrl))
225
+ return;
226
+ const res = await index.copyContent(pcShareData.value.shareUrl);
227
+ if (res) {
228
+ webVue.Message.success("\u590D\u5236\u6210\u529F");
229
+ }
230
+ }
231
+ function btn_device(device) {
232
+ numpc.value = device === "pc" ? 1 : 0;
233
+ }
132
234
  return {
133
235
  genQrCode,
134
236
  generate,
135
237
  cancel,
136
238
  copy,
239
+ copyPC,
137
240
  qrCode,
138
241
  isPublish,
139
242
  loading,
140
243
  expireTime,
141
244
  innerUrl,
142
245
  shareData,
143
- intervalTime
246
+ pcShareData,
247
+ intervalTime,
248
+ pcIntervalTime,
249
+ numpc,
250
+ btn_device,
251
+ pcInnerUrl,
252
+ generatePC,
253
+ previewSite,
254
+ cancelPc
144
255
  };
145
256
  }
146
257
  exports.EXPIRE_TIME_OPTIONS = EXPIRE_TIME_OPTIONS;
147
258
  exports.generateDocPreviewLink = generateDocPreviewLink;
259
+ exports.generateDocPreviewLinkPC = generateDocPreviewLinkPC;
148
260
  exports.useDocPreview = useDocPreview;
@@ -30,6 +30,33 @@
30
30
  border: none;
31
31
  outline: none;
32
32
  }
33
+ .iframe-container-pc {
34
+ position: relative;
35
+ height: 95vh;
36
+ overflow: hidden;
37
+ aspect-ratio: 1920 / 1080;
38
+ }
39
+ .iframe-container-pc img {
40
+ position: absolute;
41
+ width: 100%;
42
+ height: 100%;
43
+ }
44
+ .iframe-container-pc .iframe-content-pc {
45
+ position: absolute;
46
+ top: 70px;
47
+ left: 56px;
48
+ width: calc(100% - 106px);
49
+ height: calc(100% - 140px);
50
+ overflow: hidden;
51
+ background-color: white;
52
+ border-radius: 15px;
53
+ }
54
+ .iframe-container-pc iframe {
55
+ width: 100%;
56
+ height: 100%;
57
+ border: none;
58
+ outline: none;
59
+ }
33
60
  .doc-preview-container {
34
61
  position: fixed;
35
62
  top: 0;
@@ -147,3 +174,24 @@
147
174
  font-size: 20px;
148
175
  cursor: pointer;
149
176
  }
177
+ .v-bottom {
178
+ position: absolute;
179
+ bottom: 24px;
180
+ left: 100%;
181
+ z-index: 999;
182
+ width: 100%;
183
+ color: #fff;
184
+ font-size: 12px;
185
+ transform: translateX(-60%);
186
+ }
187
+ .v-bottom span {
188
+ width: 120px;
189
+ height: 42px;
190
+ margin-right: 16px;
191
+ padding: 10px 16px;
192
+ font-size: 12px;
193
+ background: rgba(216, 216, 216, 0.05);
194
+ background-color: #00000068;
195
+ border-radius: 6px;
196
+ opacity: 1;
197
+ }
@@ -138,3 +138,26 @@
138
138
  cursor: pointer;
139
139
  }
140
140
  }
141
+
142
+ .v-bottom {
143
+ position: absolute;
144
+ bottom: 24px;
145
+ left: 100%;
146
+ z-index: 999;
147
+ width: 100%;
148
+ color: #fff;
149
+ font-size: 12px;
150
+ transform: translateX(-60%);
151
+
152
+ span {
153
+ width: 120px;
154
+ height: 42px;
155
+ margin-right: 16px;
156
+ padding: 10px 16px;
157
+ font-size: 12px;
158
+ background: rgba(216, 216, 216, 0.05);
159
+ background-color: #00000068;
160
+ border-radius: 6px;
161
+ opacity: 1;
162
+ }
163
+ }
@@ -34,3 +34,34 @@
34
34
  }
35
35
  }
36
36
  }
37
+
38
+ .iframe-container-pc {
39
+ position: relative;
40
+ height: 95vh;
41
+ overflow: hidden;
42
+ aspect-ratio: 1920 / 1080;
43
+
44
+ img {
45
+ position: absolute;
46
+ width: 100%;
47
+ height: 100%;
48
+ }
49
+
50
+ .iframe-content-pc {
51
+ position: absolute;
52
+ top: 70px;
53
+ left: 56px;
54
+ width: calc(100% - 106px);
55
+ height: calc(100% - 140px);
56
+ overflow: hidden;
57
+ background-color: white;
58
+ border-radius: 15px;
59
+ }
60
+
61
+ iframe {
62
+ width: 100%;
63
+ height: 100%;
64
+ border: none;
65
+ outline: none;
66
+ }
67
+ }
package/lib/index.css CHANGED
@@ -4742,6 +4742,33 @@
4742
4742
  border: none;
4743
4743
  outline: none;
4744
4744
  }
4745
+ .iframe-container-pc {
4746
+ position: relative;
4747
+ height: 95vh;
4748
+ overflow: hidden;
4749
+ aspect-ratio: 1920 / 1080;
4750
+ }
4751
+ .iframe-container-pc img {
4752
+ position: absolute;
4753
+ width: 100%;
4754
+ height: 100%;
4755
+ }
4756
+ .iframe-container-pc .iframe-content-pc {
4757
+ position: absolute;
4758
+ top: 70px;
4759
+ left: 56px;
4760
+ width: calc(100% - 106px);
4761
+ height: calc(100% - 140px);
4762
+ overflow: hidden;
4763
+ background-color: white;
4764
+ border-radius: 15px;
4765
+ }
4766
+ .iframe-container-pc iframe {
4767
+ width: 100%;
4768
+ height: 100%;
4769
+ border: none;
4770
+ outline: none;
4771
+ }
4745
4772
  .doc-preview-container {
4746
4773
  position: fixed;
4747
4774
  top: 0;
@@ -4859,6 +4886,27 @@
4859
4886
  font-size: 20px;
4860
4887
  cursor: pointer;
4861
4888
  }
4889
+ .v-bottom {
4890
+ position: absolute;
4891
+ bottom: 24px;
4892
+ left: 100%;
4893
+ z-index: 999;
4894
+ width: 100%;
4895
+ color: #fff;
4896
+ font-size: 12px;
4897
+ transform: translateX(-60%);
4898
+ }
4899
+ .v-bottom span {
4900
+ width: 120px;
4901
+ height: 42px;
4902
+ margin-right: 16px;
4903
+ padding: 10px 16px;
4904
+ font-size: 12px;
4905
+ background: rgba(216, 216, 216, 0.05);
4906
+ background-color: #00000068;
4907
+ border-radius: 6px;
4908
+ opacity: 1;
4909
+ }
4862
4910
  .doc-diff-panel-wrap {
4863
4911
  box-sizing: border-box;
4864
4912
  width: 100% !important;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmstops/pro-compo",
3
- "version": "3.9.2-alpha.24",
3
+ "version": "3.9.2-alpha.26",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "vue",