@waline/client 2.6.4 → 2.8.0
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/dist/component.esm.js +1 -1
- package/dist/component.esm.js.map +1 -1
- package/dist/component.js +1 -1
- package/dist/component.js.map +1 -1
- package/dist/legacy.d.ts +3 -0
- package/dist/legacy.js +1 -1
- package/dist/legacy.js.map +1 -1
- package/dist/pageview.cjs.js +1 -1
- package/dist/pageview.cjs.js.map +1 -1
- package/dist/pageview.esm.js +1 -1
- package/dist/pageview.esm.js.map +1 -1
- package/dist/pageview.js +1 -1
- package/dist/pageview.js.map +1 -1
- package/dist/shim.d.ts +8 -0
- package/dist/shim.esm.d.ts +8 -0
- package/dist/shim.esm.js +1 -1
- package/dist/shim.esm.js.map +1 -1
- package/dist/shim.js +1 -1
- package/dist/shim.js.map +1 -1
- package/dist/waline.cjs.d.ts +8 -0
- package/dist/waline.cjs.js +1 -1
- package/dist/waline.cjs.js.map +1 -1
- package/dist/waline.css +1 -1
- package/dist/waline.css.map +1 -1
- package/dist/waline.d.ts +8 -0
- package/dist/waline.esm.d.ts +8 -0
- package/dist/waline.esm.js +1 -1
- package/dist/waline.esm.js.map +1 -1
- package/dist/waline.js +1 -1
- package/dist/waline.js.map +1 -1
- package/package.json +11 -11
- package/src/components/CommentBox.vue +16 -4
- package/src/components/CommentCard.vue +35 -9
- package/src/components/Icons.ts +10 -0
- package/src/components/Waline.vue +59 -4
- package/src/config/i18n/en.ts +3 -0
- package/src/config/i18n/generate.ts +3 -0
- package/src/config/i18n/jp.ts +3 -0
- package/src/config/i18n/pt-BR.ts +3 -0
- package/src/config/i18n/ru.ts +3 -0
- package/src/config/i18n/vi-VN.ts +3 -0
- package/src/config/i18n/zh-CN.ts +3 -0
- package/src/config/i18n/zh-TW.ts +3 -0
- package/src/styles/card.scss +2 -5
- package/src/styles/layout.scss +28 -1
- package/src/typings/comment.ts +6 -0
- package/src/typings/locale.ts +3 -0
- package/src/utils/fetch.ts +11 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@waline/client",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"description": "client for waline comment system",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"valine",
|
|
@@ -80,29 +80,29 @@
|
|
|
80
80
|
]
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
|
-
"@vueuse/core": "^9.
|
|
83
|
+
"@vueuse/core": "^9.2.0",
|
|
84
84
|
"autosize": "^5.0.1",
|
|
85
85
|
"marked": "^4.1.0",
|
|
86
|
-
"vue": "^3.2.
|
|
86
|
+
"vue": "^3.2.39"
|
|
87
87
|
},
|
|
88
88
|
"devDependencies": {
|
|
89
|
-
"@babel/core": "7.
|
|
90
|
-
"@babel/preset-env": "7.
|
|
89
|
+
"@babel/core": "7.19.0",
|
|
90
|
+
"@babel/preset-env": "7.19.0",
|
|
91
91
|
"@rollup/plugin-babel": "5.3.1",
|
|
92
92
|
"@rollup/plugin-commonjs": "22.0.2",
|
|
93
|
-
"@rollup/plugin-node-resolve": "
|
|
93
|
+
"@rollup/plugin-node-resolve": "14.0.1",
|
|
94
94
|
"@rollup/plugin-replace": "4.0.0",
|
|
95
95
|
"@types/autosize": "4.0.1",
|
|
96
|
-
"@types/marked": "4.0.
|
|
97
|
-
"@types/node": "18.7.
|
|
98
|
-
"@vitejs/plugin-vue": "3.0
|
|
96
|
+
"@types/marked": "4.0.7",
|
|
97
|
+
"@types/node": "18.7.16",
|
|
98
|
+
"@vitejs/plugin-vue": "3.1.0",
|
|
99
99
|
"rimraf": "3.0.2",
|
|
100
100
|
"rollup": "2.79.0",
|
|
101
101
|
"rollup-plugin-dts": "4.2.2",
|
|
102
102
|
"rollup-plugin-terser": "7.0.2",
|
|
103
103
|
"rollup-plugin-ts": "3.0.2",
|
|
104
|
-
"typescript": "4.8.
|
|
105
|
-
"vite": "3.0
|
|
104
|
+
"typescript": "4.8.3",
|
|
105
|
+
"vite": "3.1.0"
|
|
106
106
|
},
|
|
107
107
|
"engines": {
|
|
108
108
|
"node": ">=14"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="wl-comment">
|
|
3
|
-
<div v-if="config.login !== 'disable' && isLogin" class="wl-login-info">
|
|
3
|
+
<div v-if="config.login !== 'disable' && isLogin && !edit?.objectId" class="wl-login-info">
|
|
4
4
|
<div class="wl-avatar">
|
|
5
5
|
<button class="wl-logout-btn" :title="locale.logout" @click="onLogout">
|
|
6
6
|
<CloseIcon :size="14" />
|
|
@@ -248,10 +248,10 @@
|
|
|
248
248
|
</div>
|
|
249
249
|
|
|
250
250
|
<button
|
|
251
|
-
v-if="replyId"
|
|
251
|
+
v-if="replyId || edit?.objectId"
|
|
252
252
|
class="wl-close"
|
|
253
253
|
:title="locale.cancelReply"
|
|
254
|
-
@click="$emit('cancel-reply')"
|
|
254
|
+
@click="$emit(replyId ? 'cancel-reply' : 'cancel-edit')"
|
|
255
255
|
>
|
|
256
256
|
<CloseIcon :size="24" />
|
|
257
257
|
</button>
|
|
@@ -267,6 +267,7 @@ import {
|
|
|
267
267
|
inject,
|
|
268
268
|
onMounted,
|
|
269
269
|
onUnmounted,
|
|
270
|
+
PropType,
|
|
270
271
|
reactive,
|
|
271
272
|
ref,
|
|
272
273
|
watch,
|
|
@@ -294,6 +295,7 @@ import {
|
|
|
294
295
|
|
|
295
296
|
import type { ComputedRef, DeepReadonly } from 'vue';
|
|
296
297
|
import type {
|
|
298
|
+
WalineComment,
|
|
297
299
|
WalineCommentData,
|
|
298
300
|
WalineImageUploader,
|
|
299
301
|
WalineSearchOptions,
|
|
@@ -328,9 +330,13 @@ export default defineComponent({
|
|
|
328
330
|
type: String,
|
|
329
331
|
default: '',
|
|
330
332
|
},
|
|
333
|
+
edit: {
|
|
334
|
+
type: Object as PropType<WalineComment | null>,
|
|
335
|
+
default: null,
|
|
336
|
+
},
|
|
331
337
|
},
|
|
332
338
|
|
|
333
|
-
emits: ['submit', 'cancel-reply'],
|
|
339
|
+
emits: ['submit', 'cancel-reply', 'cancel-edit'],
|
|
334
340
|
|
|
335
341
|
setup(props, { emit }) {
|
|
336
342
|
const config = inject<ComputedRef<WalineConfig>>(
|
|
@@ -510,6 +516,8 @@ export default defineComponent({
|
|
|
510
516
|
comment.pid = props.replyId;
|
|
511
517
|
comment.rid = props.rootId;
|
|
512
518
|
comment.at = props.replyUser;
|
|
519
|
+
} else if (props.edit) {
|
|
520
|
+
comment.eid = props.edit.objectId;
|
|
513
521
|
}
|
|
514
522
|
|
|
515
523
|
isSubmitting.value = true;
|
|
@@ -532,6 +540,7 @@ export default defineComponent({
|
|
|
532
540
|
previewText.value = '';
|
|
533
541
|
|
|
534
542
|
if (props.replyId) emit('cancel-reply');
|
|
543
|
+
if (props.edit?.objectId) emit('cancel-edit');
|
|
535
544
|
})
|
|
536
545
|
.catch((err: TypeError) => {
|
|
537
546
|
isSubmitting.value = false;
|
|
@@ -701,6 +710,9 @@ export default defineComponent({
|
|
|
701
710
|
onMounted(() => {
|
|
702
711
|
document.body.addEventListener('click', popupHandler);
|
|
703
712
|
window.addEventListener('message', onMessageRecive);
|
|
713
|
+
if (props.edit?.objectId) {
|
|
714
|
+
editor.value = props.edit.orig;
|
|
715
|
+
}
|
|
704
716
|
|
|
705
717
|
// watch editor
|
|
706
718
|
watch(
|
|
@@ -32,6 +32,14 @@
|
|
|
32
32
|
<span class="wl-time" v-text="time" />
|
|
33
33
|
|
|
34
34
|
<div class="wl-comment-actions">
|
|
35
|
+
<button
|
|
36
|
+
v-if="isAdmin || isOwner"
|
|
37
|
+
class="wl-edit"
|
|
38
|
+
@click="$emit('edit', comment)"
|
|
39
|
+
>
|
|
40
|
+
<EditIcon />
|
|
41
|
+
</button>
|
|
42
|
+
|
|
35
43
|
<button
|
|
36
44
|
v-if="isAdmin || isOwner"
|
|
37
45
|
class="wl-delete"
|
|
@@ -60,14 +68,14 @@
|
|
|
60
68
|
</div>
|
|
61
69
|
</div>
|
|
62
70
|
<div class="wl-meta" aria-hidden="true">
|
|
63
|
-
<span v-if="comment.addr" v-text="comment.addr" />
|
|
64
|
-
<span v-if="comment.browser" v-text="comment.browser" />
|
|
65
|
-
<span v-if="comment.os" v-text="comment.os" />
|
|
71
|
+
<span v-if="comment.addr" class="wl-addr" :data-value="comment.addr" v-text="comment.addr" />
|
|
72
|
+
<span v-if="comment.browser" class="wl-browser" :data-value="comment.browser" v-text="comment.browser" />
|
|
73
|
+
<span v-if="comment.os" class="wl-os" :data-value="comment.os" v-text="comment.os" />
|
|
66
74
|
</div>
|
|
67
75
|
<!-- eslint-disable-next-line vue/no-v-html -->
|
|
68
|
-
<div class="wl-content" v-html="comment.comment" />
|
|
76
|
+
<div v-if="!isEditingCurrent" class="wl-content" v-html="comment.comment" />
|
|
69
77
|
|
|
70
|
-
<div v-if="isAdmin" class="wl-admin-actions">
|
|
78
|
+
<div v-if="isAdmin && !isEditingCurrent" class="wl-admin-actions">
|
|
71
79
|
<span class="wl-comment-status">
|
|
72
80
|
<button
|
|
73
81
|
v-for="status in commentStatus"
|
|
@@ -88,13 +96,18 @@
|
|
|
88
96
|
</button>
|
|
89
97
|
</div>
|
|
90
98
|
|
|
91
|
-
<div
|
|
99
|
+
<div
|
|
100
|
+
v-if="isReplyingCurrent || isEditingCurrent"
|
|
101
|
+
:class="{'wl-reply-wrapper': isReplyingCurrent, 'wl-edit-wrapper': isEditingCurrent}"
|
|
102
|
+
>
|
|
92
103
|
<CommentBox
|
|
93
|
-
:
|
|
104
|
+
:edit="edit"
|
|
105
|
+
:reply-id="reply?.objectId"
|
|
94
106
|
:reply-user="comment.nick"
|
|
95
107
|
:root-id="rootId"
|
|
96
108
|
@submit="$emit('submit', $event)"
|
|
97
109
|
@cancel-reply="$emit('reply', null)"
|
|
110
|
+
@cancel-edit="$emit('edit', null)"
|
|
98
111
|
/>
|
|
99
112
|
</div>
|
|
100
113
|
<div v-if="comment.children" class="wl-quote">
|
|
@@ -103,10 +116,12 @@
|
|
|
103
116
|
:key="child.objectId"
|
|
104
117
|
:comment="child"
|
|
105
118
|
:reply="reply"
|
|
119
|
+
:edit="edit"
|
|
106
120
|
:root-id="rootId"
|
|
107
121
|
@reply="$emit('reply', $event)"
|
|
108
122
|
@submit="$emit('submit', $event)"
|
|
109
123
|
@like="$emit('like', $event)"
|
|
124
|
+
@edit="$emit('edit', $event)"
|
|
110
125
|
@delete="$emit('delete', $event)"
|
|
111
126
|
@status="$emit('status', $event)"
|
|
112
127
|
@sticky="$emit('sticky', $event)"
|
|
@@ -119,7 +134,7 @@
|
|
|
119
134
|
<script lang="ts">
|
|
120
135
|
import { computed, defineComponent, inject } from 'vue';
|
|
121
136
|
import CommentBox from './CommentBox.vue';
|
|
122
|
-
import { DeleteIcon, LikeIcon, ReplyIcon, VerifiedIcon } from './Icons';
|
|
137
|
+
import { DeleteIcon, LikeIcon, ReplyIcon, EditIcon, VerifiedIcon } from './Icons';
|
|
123
138
|
import { isLinkHttp } from '../utils';
|
|
124
139
|
import { useTimeAgo, useLikeStorage, useUserInfo } from '../composables';
|
|
125
140
|
|
|
@@ -135,6 +150,7 @@ export default defineComponent({
|
|
|
135
150
|
DeleteIcon,
|
|
136
151
|
LikeIcon,
|
|
137
152
|
ReplyIcon,
|
|
153
|
+
EditIcon,
|
|
138
154
|
VerifiedIcon,
|
|
139
155
|
},
|
|
140
156
|
|
|
@@ -151,9 +167,13 @@ export default defineComponent({
|
|
|
151
167
|
type: Object as PropType<WalineComment | null>,
|
|
152
168
|
default: null,
|
|
153
169
|
},
|
|
170
|
+
edit: {
|
|
171
|
+
type: Object as PropType<WalineComment | null>,
|
|
172
|
+
default: null,
|
|
173
|
+
}
|
|
154
174
|
},
|
|
155
175
|
|
|
156
|
-
emits: ['submit', 'reply', 'like', 'delete', 'status', 'sticky'],
|
|
176
|
+
emits: ['submit', 'reply', 'like', 'delete', 'status', 'sticky', 'edit'],
|
|
157
177
|
|
|
158
178
|
setup(props) {
|
|
159
179
|
const config = inject<ComputedRef<WalineConfig>>(
|
|
@@ -181,16 +201,22 @@ export default defineComponent({
|
|
|
181
201
|
props.comment.user_id &&
|
|
182
202
|
userInfo.value.objectId === props.comment.user_id
|
|
183
203
|
);
|
|
204
|
+
console.log('lizheming:', props.comment.user_id, userInfo.value.objectId, isOwner.value);
|
|
184
205
|
|
|
185
206
|
const isReplyingCurrent = computed(
|
|
186
207
|
() => props.comment.objectId === props.reply?.objectId
|
|
187
208
|
);
|
|
188
209
|
|
|
210
|
+
const isEditingCurrent = computed(
|
|
211
|
+
() => props.comment.objectId === props.edit?.objectId
|
|
212
|
+
)
|
|
213
|
+
|
|
189
214
|
return {
|
|
190
215
|
config,
|
|
191
216
|
locale,
|
|
192
217
|
|
|
193
218
|
isReplyingCurrent,
|
|
219
|
+
isEditingCurrent,
|
|
194
220
|
link,
|
|
195
221
|
like,
|
|
196
222
|
time,
|
package/src/components/Icons.ts
CHANGED
|
@@ -102,6 +102,16 @@ export const ReplyIcon: FunctionalComponent = () =>
|
|
|
102
102
|
})
|
|
103
103
|
);
|
|
104
104
|
|
|
105
|
+
export const EditIcon: FunctionalComponent = () =>
|
|
106
|
+
h(
|
|
107
|
+
'svg',
|
|
108
|
+
{ viewBox: '0 0 1024 1024', width: '24', height: '24'},
|
|
109
|
+
h('path', {
|
|
110
|
+
d: 'M813.039 318.772L480.53 651.278H360.718V531.463L693.227 198.961C697.904 194.284 704.027 192 710.157 192C716.302 192 722.436 194.284 727.114 198.961L813.039 284.88C817.72 289.561 820 295.684 820 301.825C820 307.95 817.72 314.093 813.039 318.772ZM710.172 261.888L420.624 551.431V591.376H460.561L750.109 301.825L710.172 261.888ZM490.517 291.845H240.906V771.09H720.156V521.479C720.156 504.947 733.559 491.529 750.109 491.529C766.653 491.529 780.063 504.947 780.063 521.479V791.059C780.063 813.118 762.18 831 740.125 831H220.937C198.882 831 181 813.118 181 791.059V271.872C181 249.817 198.882 231.935 220.937 231.935H490.517C507.06 231.935 520.47 245.352 520.47 261.888C520.47 278.424 507.06 291.845 490.517 291.845Z',
|
|
111
|
+
fill: 'currentColor',
|
|
112
|
+
})
|
|
113
|
+
);
|
|
114
|
+
|
|
105
115
|
export const VerifiedIcon: FunctionalComponent = () =>
|
|
106
116
|
h(
|
|
107
117
|
'svg',
|
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div data-waline>
|
|
3
3
|
<CommentBox v-if="!reply" @submit="onSubmit" />
|
|
4
|
-
<div class="wl-
|
|
5
|
-
<
|
|
6
|
-
|
|
4
|
+
<div class="wl-meta-head">
|
|
5
|
+
<div class="wl-count">
|
|
6
|
+
<span v-if="count" class="wl-num" v-text="count" />
|
|
7
|
+
{{ i18n.comment }}
|
|
8
|
+
</div>
|
|
9
|
+
<ul class="wl-sort">
|
|
10
|
+
<li
|
|
11
|
+
v-for="item in sortByItems"
|
|
12
|
+
:key="item.key"
|
|
13
|
+
:class="[item.key === sortBy ? 'active' : '']"
|
|
14
|
+
@click="onSortByChange(item.key)"
|
|
15
|
+
>
|
|
16
|
+
{{ i18n[item.name] }}
|
|
17
|
+
</li>
|
|
18
|
+
</ul>
|
|
7
19
|
</div>
|
|
8
20
|
|
|
9
21
|
<div class="wl-cards">
|
|
@@ -13,7 +25,9 @@
|
|
|
13
25
|
:root-id="comment.objectId"
|
|
14
26
|
:comment="comment"
|
|
15
27
|
:reply="reply"
|
|
28
|
+
:edit="edit"
|
|
16
29
|
@reply="onReply"
|
|
30
|
+
@edit="onEdit"
|
|
17
31
|
@submit="onSubmit"
|
|
18
32
|
@status="onStatusChange"
|
|
19
33
|
@delete="onDelete"
|
|
@@ -117,6 +131,24 @@ const props = [
|
|
|
117
131
|
'copyright',
|
|
118
132
|
];
|
|
119
133
|
|
|
134
|
+
type SortKeyItems = 'insertedAt_desc' | 'insertedAt_asc' | 'like_desc';
|
|
135
|
+
type SortNameItems = 'latest' | 'oldest' | 'hottest';
|
|
136
|
+
type SortByItems = { key: SortKeyItems; name: SortNameItems }[];
|
|
137
|
+
const sortByItems: SortByItems = [
|
|
138
|
+
{
|
|
139
|
+
key: 'insertedAt_desc',
|
|
140
|
+
name: 'latest',
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
key: 'insertedAt_asc',
|
|
144
|
+
name: 'oldest',
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
key: 'like_desc',
|
|
148
|
+
name: 'hottest',
|
|
149
|
+
},
|
|
150
|
+
];
|
|
151
|
+
|
|
120
152
|
const propsWithValidate = {
|
|
121
153
|
serverURL: {
|
|
122
154
|
type: String,
|
|
@@ -229,9 +261,11 @@ export default defineComponent({
|
|
|
229
261
|
const count = ref(0);
|
|
230
262
|
const page = ref(1);
|
|
231
263
|
const totalPages = ref(0);
|
|
264
|
+
const sortBy = ref<SortKeyItems>(sortByItems[0].key);
|
|
232
265
|
|
|
233
266
|
const data = ref<WalineComment[]>([]);
|
|
234
267
|
const reply = ref<WalineComment | null>(null);
|
|
268
|
+
const edit = ref<WalineComment | null>(null);
|
|
235
269
|
|
|
236
270
|
const darkmodeStyle = computed(() => getDarkStyle(config.value.dark));
|
|
237
271
|
|
|
@@ -253,6 +287,7 @@ export default defineComponent({
|
|
|
253
287
|
lang: config.value.lang,
|
|
254
288
|
path,
|
|
255
289
|
pageSize,
|
|
290
|
+
sortBy: sortBy.value,
|
|
256
291
|
page: pageNumber,
|
|
257
292
|
signal: controller.signal,
|
|
258
293
|
token: userInfo.value?.token,
|
|
@@ -282,12 +317,27 @@ export default defineComponent({
|
|
|
282
317
|
fetchComment(1);
|
|
283
318
|
};
|
|
284
319
|
|
|
320
|
+
const onSortByChange = (item: SortKeyItems): void => {
|
|
321
|
+
if (sortBy.value === item) {
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
sortBy.value = item;
|
|
325
|
+
refresh();
|
|
326
|
+
};
|
|
327
|
+
|
|
285
328
|
const onReply = (comment: WalineComment | null): void => {
|
|
286
329
|
reply.value = comment;
|
|
287
330
|
};
|
|
288
331
|
|
|
332
|
+
const onEdit = (comment: WalineComment | null): void => {
|
|
333
|
+
edit.value = comment;
|
|
334
|
+
};
|
|
335
|
+
|
|
289
336
|
const onSubmit = (comment: WalineComment): void => {
|
|
290
|
-
if (
|
|
337
|
+
if (edit.value) {
|
|
338
|
+
edit.value.comment = comment.comment;
|
|
339
|
+
edit.value.orig = comment.orig;
|
|
340
|
+
} else if (comment.rid) {
|
|
291
341
|
const repliedComment = data.value.find(
|
|
292
342
|
({ objectId }) => objectId === comment.rid
|
|
293
343
|
);
|
|
@@ -412,17 +462,22 @@ export default defineComponent({
|
|
|
412
462
|
count,
|
|
413
463
|
page,
|
|
414
464
|
totalPages,
|
|
465
|
+
sortBy,
|
|
466
|
+
sortByItems,
|
|
415
467
|
data,
|
|
416
468
|
reply,
|
|
469
|
+
edit,
|
|
417
470
|
|
|
418
471
|
loadMore,
|
|
419
472
|
refresh,
|
|
473
|
+
onSortByChange,
|
|
420
474
|
onReply,
|
|
421
475
|
onSubmit,
|
|
422
476
|
onStatusChange,
|
|
423
477
|
onDelete,
|
|
424
478
|
onSticky,
|
|
425
479
|
onLike,
|
|
480
|
+
onEdit,
|
|
426
481
|
|
|
427
482
|
version: VERSION,
|
|
428
483
|
};
|
package/src/config/i18n/en.ts
CHANGED
package/src/config/i18n/jp.ts
CHANGED
package/src/config/i18n/pt-BR.ts
CHANGED
package/src/config/i18n/ru.ts
CHANGED
package/src/config/i18n/vi-VN.ts
CHANGED
package/src/config/i18n/zh-CN.ts
CHANGED
package/src/config/i18n/zh-TW.ts
CHANGED
package/src/styles/card.scss
CHANGED
|
@@ -118,10 +118,6 @@
|
|
|
118
118
|
font-size: var(--waline-info-font-size);
|
|
119
119
|
line-height: 1.5;
|
|
120
120
|
|
|
121
|
-
@media (max-width: 520px) {
|
|
122
|
-
display: none;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
121
|
&:empty {
|
|
126
122
|
display: none;
|
|
127
123
|
}
|
|
@@ -134,7 +130,8 @@
|
|
|
134
130
|
|
|
135
131
|
.wl-delete,
|
|
136
132
|
.wl-like,
|
|
137
|
-
.wl-reply
|
|
133
|
+
.wl-reply,
|
|
134
|
+
.wl-edit {
|
|
138
135
|
display: inline-flex;
|
|
139
136
|
align-items: center;
|
|
140
137
|
|
package/src/styles/layout.scss
CHANGED
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
.wl-count {
|
|
53
|
-
padding: 0.375em;
|
|
54
53
|
font-weight: bold;
|
|
55
54
|
font-size: 1.25em;
|
|
55
|
+
flex: 1;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
.wl-empty {
|
|
@@ -76,3 +76,30 @@
|
|
|
76
76
|
font-size: var(--waline-info-font-size);
|
|
77
77
|
text-align: right;
|
|
78
78
|
}
|
|
79
|
+
|
|
80
|
+
.wl-meta-head {
|
|
81
|
+
display: flex;
|
|
82
|
+
flex-direction: row;
|
|
83
|
+
align-items: center;
|
|
84
|
+
padding: 0.375em;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
ul.wl-sort {
|
|
88
|
+
list-style-type: none;
|
|
89
|
+
margin: 0;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.wl-sort li {
|
|
93
|
+
display: inline-block;
|
|
94
|
+
font-size: 0.75em;
|
|
95
|
+
color: var(--waline-info-color);
|
|
96
|
+
cursor: pointer;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.wl-sort li + li {
|
|
100
|
+
margin-left: 1em;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.wl-sort li.active {
|
|
104
|
+
color: var(--waline-theme-color);
|
|
105
|
+
}
|
package/src/typings/comment.ts
CHANGED
|
@@ -40,6 +40,11 @@ export interface WalineCommentData {
|
|
|
40
40
|
*/
|
|
41
41
|
at?: string;
|
|
42
42
|
|
|
43
|
+
/**
|
|
44
|
+
* edit comment id
|
|
45
|
+
*/
|
|
46
|
+
eid?: string;
|
|
47
|
+
|
|
43
48
|
/**
|
|
44
49
|
* Comment link
|
|
45
50
|
*/
|
|
@@ -80,4 +85,5 @@ export interface WalineComment extends Exclude<WalineCommentData, 'ua'> {
|
|
|
80
85
|
user_id?: string | number;
|
|
81
86
|
status?: WalineCommentStatus;
|
|
82
87
|
like?: number;
|
|
88
|
+
orig?: string;
|
|
83
89
|
}
|
package/src/typings/locale.ts
CHANGED
package/src/utils/fetch.ts
CHANGED
|
@@ -85,6 +85,7 @@ export interface FetchListOptions {
|
|
|
85
85
|
path: string;
|
|
86
86
|
page: number;
|
|
87
87
|
pageSize: number;
|
|
88
|
+
sortBy: string;
|
|
88
89
|
signal: AbortSignal;
|
|
89
90
|
token?: string;
|
|
90
91
|
lang: string;
|
|
@@ -102,6 +103,7 @@ export const fetchCommentList = ({
|
|
|
102
103
|
path,
|
|
103
104
|
page,
|
|
104
105
|
pageSize,
|
|
106
|
+
sortBy,
|
|
105
107
|
signal,
|
|
106
108
|
token,
|
|
107
109
|
}: FetchListOptions): Promise<FetchListResult> => {
|
|
@@ -112,7 +114,7 @@ export const fetchCommentList = ({
|
|
|
112
114
|
return fetch(
|
|
113
115
|
`${serverURL}/comment?path=${encodeURIComponent(
|
|
114
116
|
path
|
|
115
|
-
)}&pageSize=${pageSize}&page=${page}&lang=${lang}`,
|
|
117
|
+
)}&pageSize=${pageSize}&page=${page}&lang=${lang}&sortBy=${sortBy}`,
|
|
116
118
|
{ signal, headers }
|
|
117
119
|
)
|
|
118
120
|
.then((resp) => resp.json() as Promise<FetchListResult>)
|
|
@@ -144,6 +146,14 @@ export const postComment = ({
|
|
|
144
146
|
|
|
145
147
|
if (token) headers.Authorization = `Bearer ${token}`;
|
|
146
148
|
|
|
149
|
+
if (comment.eid) {
|
|
150
|
+
return fetch(`${serverURL}/comment/${comment.eid}?lang=${lang}`, {
|
|
151
|
+
method: 'PUT',
|
|
152
|
+
headers,
|
|
153
|
+
body: JSON.stringify(comment),
|
|
154
|
+
}).then((resp) => resp.json() as Promise<PostCommentResponse>);
|
|
155
|
+
}
|
|
156
|
+
|
|
147
157
|
return fetch(`${serverURL}/comment?lang=${lang}`, {
|
|
148
158
|
method: 'POST',
|
|
149
159
|
headers,
|