@nebulars/sseengine 1.3.51 → 1.3.53
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/package.json
CHANGED
|
@@ -34,6 +34,14 @@
|
|
|
34
34
|
|
|
35
35
|
<template>
|
|
36
36
|
<div class="fqa-chat" :style="theme">
|
|
37
|
+
<!-- Fullscreen -->
|
|
38
|
+
<fqa-fullscreen v-model:visible="sseengine.fullscreen">
|
|
39
|
+
<div v-html="sseengine.cloner"></div>
|
|
40
|
+
</fqa-fullscreen>
|
|
41
|
+
|
|
42
|
+
<!-- Snapshot -->
|
|
43
|
+
<fqa-snapshot v-model:visible="sseengine.snapshot" :snap="sseengine.snap"></fqa-snapshot>
|
|
44
|
+
|
|
37
45
|
<!-- Recursion -->
|
|
38
46
|
<sse-recursion :source="sseengine.info?.history" />
|
|
39
47
|
|
|
@@ -106,14 +114,42 @@ export default {
|
|
|
106
114
|
// Open Attach - For Web
|
|
107
115
|
await this.$store.dispatch('adapter/STATE_UPDATE', { attach: { type: true } });
|
|
108
116
|
},
|
|
117
|
+
|
|
118
|
+
async tubHandler({ target }) {
|
|
119
|
+
// Get Container
|
|
120
|
+
const container = this.$util.closest(target, '.markdown-table-ops', true);
|
|
121
|
+
|
|
122
|
+
// Get Element by Closest
|
|
123
|
+
const element = this.$util.closest(target, '[data-event]', true);
|
|
124
|
+
|
|
125
|
+
// No Element
|
|
126
|
+
if (!container || !element) return;
|
|
127
|
+
|
|
128
|
+
// Get Event by Element
|
|
129
|
+
const { event, snap } = element?.dataset;
|
|
130
|
+
|
|
131
|
+
// Namespace
|
|
132
|
+
const namespace = event.toUpperCase();
|
|
133
|
+
|
|
134
|
+
// Decode Markdown
|
|
135
|
+
const markdown = snap ? decodeURIComponent(snap) : null;
|
|
136
|
+
|
|
137
|
+
// Get Table
|
|
138
|
+
const { nextSibling: table } = container;
|
|
139
|
+
|
|
140
|
+
// Trigger Action
|
|
141
|
+
await this.$store.dispatch(`sseengine/TUB_${namespace}`, { table, markdown });
|
|
142
|
+
},
|
|
109
143
|
},
|
|
110
144
|
|
|
111
145
|
mounted() {
|
|
112
146
|
document.addEventListener('click', this.supHandler);
|
|
147
|
+
document.addEventListener('click', this.tubHandler);
|
|
113
148
|
},
|
|
114
149
|
|
|
115
150
|
beforeUnmount() {
|
|
116
151
|
document.removeEventListener('click', this.supHandler);
|
|
152
|
+
document.removeEventListener('click', this.tubHandler);
|
|
117
153
|
},
|
|
118
154
|
};
|
|
119
155
|
</script>
|
package/src/store/index.js
CHANGED
|
@@ -16,6 +16,9 @@ import { default as INFO } from './info';
|
|
|
16
16
|
// Use Sup
|
|
17
17
|
import { default as SUP } from './sup';
|
|
18
18
|
|
|
19
|
+
// Use Tub
|
|
20
|
+
import { default as TUB } from './tub';
|
|
21
|
+
|
|
19
22
|
// Use Session
|
|
20
23
|
import { default as SESSION } from './session';
|
|
21
24
|
|
|
@@ -130,6 +133,18 @@ export default (proxy = {}) => {
|
|
|
130
133
|
|
|
131
134
|
// Special Hover
|
|
132
135
|
sevani: null,
|
|
136
|
+
|
|
137
|
+
// Fullscreen
|
|
138
|
+
fullscreen: false,
|
|
139
|
+
|
|
140
|
+
// Cloner
|
|
141
|
+
cloner: '',
|
|
142
|
+
|
|
143
|
+
// Snapshot
|
|
144
|
+
snapshot: false,
|
|
145
|
+
|
|
146
|
+
// Snap
|
|
147
|
+
snap: '',
|
|
133
148
|
};
|
|
134
149
|
|
|
135
150
|
// Reset
|
|
@@ -166,6 +181,9 @@ export default (proxy = {}) => {
|
|
|
166
181
|
// Sup
|
|
167
182
|
...SUP(proxy),
|
|
168
183
|
|
|
184
|
+
// Tub
|
|
185
|
+
...TUB(proxy),
|
|
186
|
+
|
|
169
187
|
// One Session
|
|
170
188
|
...SESSION(proxy),
|
|
171
189
|
|
package/src/store/tub.js
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
export default ({ http, closest, copy, toimg, download, excel, toast, $ }) => {
|
|
2
|
+
return {
|
|
3
|
+
async TUB_FULLSCREEN({ state }, { table }) {
|
|
4
|
+
// Set Cloner
|
|
5
|
+
const cloner = $(table).clone().prop('outerHTML');
|
|
6
|
+
|
|
7
|
+
// Set Fullscreen
|
|
8
|
+
const fullscreen = true;
|
|
9
|
+
|
|
10
|
+
// Update
|
|
11
|
+
return {
|
|
12
|
+
fullscreen,
|
|
13
|
+
cloner,
|
|
14
|
+
};
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
async TUB_COPY({ dispatch }, { markdown }) {
|
|
18
|
+
// Get TSV
|
|
19
|
+
const tsv = await dispatch('TSV_CREATE', markdown);
|
|
20
|
+
|
|
21
|
+
// Copy
|
|
22
|
+
copy(tsv);
|
|
23
|
+
|
|
24
|
+
// Toast
|
|
25
|
+
toast.success('复制成功');
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
async TUB_SHOT({ dispatch }, { table }) {
|
|
29
|
+
// Get Base64
|
|
30
|
+
const snap = await dispatch('SNAP_CREATE', table);
|
|
31
|
+
|
|
32
|
+
// Set Snapshot
|
|
33
|
+
const snapshot = true;
|
|
34
|
+
|
|
35
|
+
// Update
|
|
36
|
+
return {
|
|
37
|
+
snap,
|
|
38
|
+
snapshot,
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
async TUB_DOWNLOAD({ dispatch }, { markdown, table }) {
|
|
43
|
+
// Get TSV
|
|
44
|
+
const tsv = await dispatch('TSV_CREATE', markdown);
|
|
45
|
+
|
|
46
|
+
// Set Rows
|
|
47
|
+
const rows = tsv.split('\n').map(row => row.split('\t'));
|
|
48
|
+
|
|
49
|
+
// Set Book
|
|
50
|
+
const [book, sheet] = [excel.utils.book_new(), excel.utils.aoa_to_sheet(rows)];
|
|
51
|
+
|
|
52
|
+
// Set Widths
|
|
53
|
+
const widths = rows[0].map((_, index) => ({
|
|
54
|
+
wch: Math.max(...rows.map(row => (row[index] ? row[index].length : 10))),
|
|
55
|
+
}));
|
|
56
|
+
|
|
57
|
+
// Set Sheet
|
|
58
|
+
sheet['!cols'] = widths;
|
|
59
|
+
|
|
60
|
+
// Set Book
|
|
61
|
+
excel.utils.book_append_sheet(book, sheet, 'Gold Data');
|
|
62
|
+
|
|
63
|
+
// Get ID
|
|
64
|
+
// const query = closest(table, '[query-id]', true).getAttribute('query-id');
|
|
65
|
+
const answer = closest(table, '[answer-id]', true).getAttribute('answer-id');
|
|
66
|
+
|
|
67
|
+
// Write Excel
|
|
68
|
+
excel.writeFile(book, `${answer}.xlsx`);
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
async TSV_CREATE({}, markdown) {
|
|
72
|
+
// Reset Markdown
|
|
73
|
+
const content = markdown.replace(/<sup[\w\s\-\=\"]+\>\d+\<\/sup>/g, '');
|
|
74
|
+
|
|
75
|
+
// Set Lines
|
|
76
|
+
const lines = content.trim().split('\n');
|
|
77
|
+
|
|
78
|
+
// Get TSV
|
|
79
|
+
return (
|
|
80
|
+
lines
|
|
81
|
+
// Mapping
|
|
82
|
+
.map(line => {
|
|
83
|
+
// Ignore Gaps
|
|
84
|
+
if (/^\s*\|?[-| :]+\|?\s*$/.test(line)) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Join
|
|
89
|
+
return (
|
|
90
|
+
line
|
|
91
|
+
// Remove No Need
|
|
92
|
+
.replace(/^\||\|$/g, '')
|
|
93
|
+
// Add Split
|
|
94
|
+
.split('|')
|
|
95
|
+
// Remove Trim
|
|
96
|
+
.map(c => c.trim())
|
|
97
|
+
// Join Enter
|
|
98
|
+
.join('\t')
|
|
99
|
+
);
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
// No Empty
|
|
103
|
+
.filter(v => v)
|
|
104
|
+
|
|
105
|
+
// Add Enter
|
|
106
|
+
.join('\n')
|
|
107
|
+
);
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
async SNAP_CREATE({}, table) {
|
|
111
|
+
return await toimg.toPng(table, {
|
|
112
|
+
width: table.scrollWidth,
|
|
113
|
+
height: table.scrollHeight,
|
|
114
|
+
|
|
115
|
+
style: {
|
|
116
|
+
overflow: 'visible',
|
|
117
|
+
'max-height': 'none',
|
|
118
|
+
'max-width': 'none',
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
filter(node) {
|
|
122
|
+
// No Sup
|
|
123
|
+
if (node.tagName === 'SUP') {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Any
|
|
128
|
+
return true;
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
async SNAP_DOWNLOAD({}, snap) {
|
|
134
|
+
// Download
|
|
135
|
+
download(snap);
|
|
136
|
+
|
|
137
|
+
// Toast
|
|
138
|
+
toast.success('下载成功');
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
};
|