@nebulars/sseengine 1.3.64 → 1.3.65
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
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
</template>
|
|
68
68
|
|
|
69
69
|
<!-- Feedback -->
|
|
70
|
-
<
|
|
70
|
+
<sse-feedback :id="item.id" v-model:feedback="item.feedback" :visible="!sseengine.produce" />
|
|
71
71
|
|
|
72
72
|
<!-- Next -->
|
|
73
73
|
<sse-recursion v-if="item.children.length" :source="item.children" :active="active" />
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
<style lang="less" scoped>
|
|
2
|
+
.fqa-feedback {
|
|
3
|
+
height: calc(@gap + @unit);
|
|
4
|
+
line-height: calc(@gap + @unit);
|
|
5
|
+
|
|
6
|
+
&-space {
|
|
7
|
+
cursor: pointer;
|
|
8
|
+
transition: all @fast;
|
|
9
|
+
|
|
10
|
+
&:hover {
|
|
11
|
+
color: @color-primary;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
</style>
|
|
16
|
+
|
|
17
|
+
<template>
|
|
18
|
+
<a-space :size="24" class="fqa-feedback" :class="{ notouch: sseengine.mode === 'snap' }">
|
|
19
|
+
<template v-if="visible">
|
|
20
|
+
<a-space class="fqa-feedback-space" :size="4" @click="copy">
|
|
21
|
+
<fqa-icon icon="CopyOutlined" :size="18" cursor="pointer" />
|
|
22
|
+
<span>复制</span>
|
|
23
|
+
</a-space>
|
|
24
|
+
<a-space class="fqa-feedback-space" :size="4" @click="share">
|
|
25
|
+
<fqa-icon icon="ShareAltOutlined" :size="18" cursor="pointer" />
|
|
26
|
+
<span>分享</span>
|
|
27
|
+
</a-space>
|
|
28
|
+
<a-space class="fqa-feedback-space" :size="4" :data-download="id">
|
|
29
|
+
<a-dropdown :getPopupContainer="e => e.closest('[data-download]')">
|
|
30
|
+
<div>
|
|
31
|
+
<fqa-icon icon="DownloadOutlined" :size="18" cursor="pointer" />
|
|
32
|
+
<span>下载</span>
|
|
33
|
+
</div>
|
|
34
|
+
<template #overlay>
|
|
35
|
+
<a-menu>
|
|
36
|
+
<a-menu-item>
|
|
37
|
+
<a-space :size="4" @click="e => download(e, 'word')">
|
|
38
|
+
<fqa-icon icon="FileWordOutlined" />
|
|
39
|
+
<span>Word</span>
|
|
40
|
+
</a-space>
|
|
41
|
+
</a-menu-item>
|
|
42
|
+
<a-menu-item>
|
|
43
|
+
<a-space :size="4" @click="e => download(e, 'pdf')">
|
|
44
|
+
<fqa-icon icon="FilePdfOutlined" />
|
|
45
|
+
<span>PDF</span>
|
|
46
|
+
</a-space>
|
|
47
|
+
</a-menu-item>
|
|
48
|
+
<a-menu-item>
|
|
49
|
+
<a-space :size="4" @click="e => download(e, 'markdown')">
|
|
50
|
+
<fqa-icon icon="FileMarkdownOutlined" />
|
|
51
|
+
<span>Markdown</span>
|
|
52
|
+
</a-space>
|
|
53
|
+
</a-menu-item>
|
|
54
|
+
</a-menu>
|
|
55
|
+
</template>
|
|
56
|
+
</a-dropdown>
|
|
57
|
+
</a-space>
|
|
58
|
+
<a-space class="fqa-feedback-space" :size="4" @click="feed(1)">
|
|
59
|
+
<fqa-icon :icon="feedback === 1 ? 'LikeFilled' : 'LikeOutlined'" :size="18" cursor="pointer" />
|
|
60
|
+
<span>赞</span>
|
|
61
|
+
</a-space>
|
|
62
|
+
<a-space class="fqa-feedback-space" :size="4" @click="feed(2)">
|
|
63
|
+
<fqa-icon :icon="feedback === 2 ? 'DislikeFilled' : 'DislikeOutlined'" :size="18" cursor="pointer" />
|
|
64
|
+
<span>踩</span>
|
|
65
|
+
</a-space>
|
|
66
|
+
</template>
|
|
67
|
+
|
|
68
|
+
<template v-else>
|
|
69
|
+
<div> </div>
|
|
70
|
+
</template>
|
|
71
|
+
</a-space>
|
|
72
|
+
</template>
|
|
73
|
+
|
|
74
|
+
<script>
|
|
75
|
+
export default {
|
|
76
|
+
props: {
|
|
77
|
+
id: {
|
|
78
|
+
type: [String],
|
|
79
|
+
default: '',
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
feedback: {
|
|
83
|
+
type: [Number],
|
|
84
|
+
default: 0,
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
visible: {
|
|
88
|
+
type: [Boolean],
|
|
89
|
+
default: false,
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
data() {
|
|
94
|
+
return {};
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
methods: {
|
|
98
|
+
// @param event
|
|
99
|
+
async caption({ target }) {
|
|
100
|
+
return this.$util.closest(target, '[query-id]', true).querySelector('.fqa-query-content').innerHTML;
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
// @param event
|
|
104
|
+
async context({ target }) {
|
|
105
|
+
return this.$util.closest(target, '[answer-id]', true).querySelector('[data-html]').dataset;
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
// @param event
|
|
109
|
+
async snapers({ target }) {
|
|
110
|
+
return this.$util.within(this.$util.closest(target, '[query-id]', true), 'data-checked', 'query-id');
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
async copy(e) {
|
|
114
|
+
// Get Markdown
|
|
115
|
+
const { html } = await this.context(e);
|
|
116
|
+
|
|
117
|
+
// Add to Copy
|
|
118
|
+
await this.$util.copy(html);
|
|
119
|
+
|
|
120
|
+
// Toast
|
|
121
|
+
await this.$util.toast.success('已复制到剪贴板');
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
async share(e) {
|
|
125
|
+
// Mode Change
|
|
126
|
+
await this.$store.dispatch('sseengine/SNAP_MODE');
|
|
127
|
+
|
|
128
|
+
// Get Group
|
|
129
|
+
const group = await this.$store.dispatch('sseengine/SNAP_GROUP', await this.snapers(e));
|
|
130
|
+
|
|
131
|
+
// Get Snaps
|
|
132
|
+
const snaps = await this.$store.dispatch('sseengine/SNAP_ALL', group);
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
async download(e, export_type) {
|
|
136
|
+
// Get Title
|
|
137
|
+
const title = await this.caption(e);
|
|
138
|
+
|
|
139
|
+
// Get Markdown
|
|
140
|
+
const { html: content } = await this.context(e);
|
|
141
|
+
|
|
142
|
+
// Trigger Download
|
|
143
|
+
const link = await this.$store.dispatch('sseengine/ANS_DOWNLOAD', { title, content, export_type });
|
|
144
|
+
|
|
145
|
+
// Download
|
|
146
|
+
this.$util.download(link, '_blank');
|
|
147
|
+
},
|
|
148
|
+
|
|
149
|
+
async feed(feedback = 0) {
|
|
150
|
+
if (this.feedback === feedback) {
|
|
151
|
+
feedback = 0;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Get ID from Scope
|
|
155
|
+
const { id } = this;
|
|
156
|
+
|
|
157
|
+
// Feedback
|
|
158
|
+
const { status } = await this.$store.dispatch('chat/FEEDBACK', { feedback, id });
|
|
159
|
+
|
|
160
|
+
// Success
|
|
161
|
+
if (status === 'success') {
|
|
162
|
+
// Update
|
|
163
|
+
this.$emit('update:feedback', feedback);
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
</script>
|
package/src/store/feedback.js
CHANGED
|
@@ -4,5 +4,10 @@ export default ({ http }) => {
|
|
|
4
4
|
const { data } = await http.api.sseUpdateFeedback({ feedback, answer_id });
|
|
5
5
|
return data;
|
|
6
6
|
},
|
|
7
|
+
|
|
8
|
+
async ANS_DOWNLOAD({}, { title, content, export_type }) {
|
|
9
|
+
const { data } = await http.api.shareExportContent({ title, content, export_type });
|
|
10
|
+
return data;
|
|
11
|
+
},
|
|
7
12
|
};
|
|
8
13
|
};
|
package/src/store/snap.js
CHANGED
|
@@ -47,8 +47,8 @@ export default ({ $, http, link }) => {
|
|
|
47
47
|
group.forEach(async item => await dispatch('SNAP_ADD', item));
|
|
48
48
|
},
|
|
49
49
|
|
|
50
|
-
async SNAP_GROUP({}) {
|
|
51
|
-
return $(
|
|
50
|
+
async SNAP_GROUP({}, target = $('[data-checked]')) {
|
|
51
|
+
return $(target)
|
|
52
52
|
.map((_, e) => $(e).data())
|
|
53
53
|
.get();
|
|
54
54
|
},
|