@waline/client 2.3.2 → 2.4.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/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 +4 -9
- package/dist/legacy.js +1 -1
- package/dist/legacy.js.map +1 -1
- package/dist/pageview.cjs.d.ts +47 -0
- package/dist/pageview.cjs.js +1 -1
- package/dist/pageview.cjs.js.map +1 -1
- package/dist/pageview.esm.d.ts +47 -0
- 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 +46 -11
- package/dist/shim.esm.d.ts +46 -11
- 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 +46 -11
- 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 +46 -11
- package/dist/waline.esm.d.ts +46 -11
- 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 +19 -5
- package/src/components/CommentCard.vue +80 -14
- package/src/components/Icons.ts +28 -2
- package/src/components/Waline.vue +115 -2
- package/src/composables/index.ts +1 -0
- package/src/composables/like.ts +14 -0
- package/src/composables/userInfo.ts +9 -1
- package/src/config/i18n/en.ts +2 -0
- package/src/config/i18n/generate.ts +2 -0
- package/src/config/i18n/jp.ts +2 -0
- package/src/config/i18n/pt-BR.ts +2 -0
- package/src/config/i18n/ru.ts +2 -0
- package/src/config/i18n/vi-VN.ts +2 -0
- package/src/config/i18n/zh-CN.ts +2 -0
- package/src/config/i18n/zh-TW.ts +2 -0
- package/src/styles/card.scss +55 -27
- package/src/styles/nomalize.scss +0 -1
- package/src/styles/panel.scss +0 -1
- package/src/typings/comment.ts +56 -1
- package/src/typings/locale.ts +3 -8
- package/src/typings/waline.ts +1 -1
- package/src/utils/config.ts +1 -1
- package/src/utils/fetch.ts +77 -4
package/src/typings/comment.ts
CHANGED
|
@@ -1,21 +1,71 @@
|
|
|
1
1
|
export interface WalineCommentData {
|
|
2
|
+
/**
|
|
3
|
+
* User Nickname
|
|
4
|
+
*/
|
|
2
5
|
nick: string;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* User email
|
|
9
|
+
*/
|
|
3
10
|
mail: string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* User link
|
|
14
|
+
*/
|
|
4
15
|
link?: string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Content of comment
|
|
19
|
+
*/
|
|
5
20
|
comment: string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* User Agent
|
|
24
|
+
*/
|
|
6
25
|
ua: string;
|
|
7
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Parent comment id
|
|
29
|
+
*/
|
|
30
|
+
|
|
8
31
|
pid?: string;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Root comment id
|
|
35
|
+
*/
|
|
9
36
|
rid?: string;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* User id being at
|
|
40
|
+
*/
|
|
10
41
|
at?: string;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Comment link
|
|
45
|
+
*/
|
|
11
46
|
url: string;
|
|
12
47
|
}
|
|
13
48
|
|
|
49
|
+
export type WalineCommentStatus = 'approved' | 'waiting' | 'spam';
|
|
50
|
+
|
|
14
51
|
export interface WalineComment extends Exclude<WalineCommentData, 'ua'> {
|
|
52
|
+
/**
|
|
53
|
+
* User avatar
|
|
54
|
+
*/
|
|
15
55
|
avatar: string;
|
|
16
|
-
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* User type
|
|
59
|
+
*/
|
|
60
|
+
type?: 'administrator' | 'guest' | `verify:${string}`;
|
|
61
|
+
|
|
17
62
|
objectId: string;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Time ISOString when the comment is created
|
|
66
|
+
*/
|
|
18
67
|
createdAt: string;
|
|
68
|
+
|
|
19
69
|
insertedAt: string;
|
|
20
70
|
updatedAt: string;
|
|
21
71
|
children: WalineComment[];
|
|
@@ -25,4 +75,9 @@ export interface WalineComment extends Exclude<WalineCommentData, 'ua'> {
|
|
|
25
75
|
level?: number;
|
|
26
76
|
addr?: string;
|
|
27
77
|
label?: string;
|
|
78
|
+
// TODO: Rename it to `userId` in next major version
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
80
|
+
user_id?: string | number;
|
|
81
|
+
status?: WalineCommentStatus;
|
|
82
|
+
like?: number;
|
|
28
83
|
}
|
package/src/typings/locale.ts
CHANGED
|
@@ -6,14 +6,7 @@ export interface WalineDateLocale {
|
|
|
6
6
|
now: string;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export
|
|
10
|
-
level0: string;
|
|
11
|
-
level1: string;
|
|
12
|
-
level2: string;
|
|
13
|
-
level3: string;
|
|
14
|
-
level4: string;
|
|
15
|
-
level5: string;
|
|
16
|
-
}
|
|
9
|
+
export type WalineLevelLocale = Record<`level${number}`, string>;
|
|
17
10
|
|
|
18
11
|
export interface WalineLocale extends WalineDateLocale, WalineLevelLocale {
|
|
19
12
|
nick: string;
|
|
@@ -25,6 +18,8 @@ export interface WalineLocale extends WalineDateLocale, WalineLevelLocale {
|
|
|
25
18
|
placeholder: string;
|
|
26
19
|
sofa: string;
|
|
27
20
|
submit: string;
|
|
21
|
+
like: string;
|
|
22
|
+
cancelLike: string;
|
|
28
23
|
reply: string;
|
|
29
24
|
cancelReply: string;
|
|
30
25
|
comment: string;
|
package/src/typings/waline.ts
CHANGED
package/src/utils/config.ts
CHANGED
|
@@ -68,7 +68,7 @@ export const getConfig = ({
|
|
|
68
68
|
locale: {
|
|
69
69
|
...(defaultLocales[lang] || defaultLocales[defaultLang]),
|
|
70
70
|
...(typeof locale === 'object' ? locale : {}),
|
|
71
|
-
},
|
|
71
|
+
} as WalineLocale,
|
|
72
72
|
wordLimit: getWordLimit(wordLimit),
|
|
73
73
|
meta: getMeta(meta),
|
|
74
74
|
requiredMeta: getMeta(requiredMeta),
|
package/src/utils/fetch.ts
CHANGED
|
@@ -5,6 +5,11 @@ export interface FetchErrorData {
|
|
|
5
5
|
errmsg: string;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
const JSON_HEADERS: Record<string, string> = {
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
10
|
+
'Content-Type': 'application/json',
|
|
11
|
+
};
|
|
12
|
+
|
|
8
13
|
const errorCheck = <T = unknown>(data: T | FetchErrorData, name = ''): T => {
|
|
9
14
|
if (typeof data === 'object' && (data as FetchErrorData).errno)
|
|
10
15
|
throw new TypeError(
|
|
@@ -143,6 +148,77 @@ export const postComment = ({
|
|
|
143
148
|
}).then((resp) => resp.json() as Promise<PostCommentResponse>);
|
|
144
149
|
};
|
|
145
150
|
|
|
151
|
+
export interface DeleteCommentOptions {
|
|
152
|
+
serverURL: string;
|
|
153
|
+
lang: string;
|
|
154
|
+
token: string;
|
|
155
|
+
objectId: string | number;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export const deleteComment = ({
|
|
159
|
+
serverURL,
|
|
160
|
+
lang,
|
|
161
|
+
token,
|
|
162
|
+
objectId,
|
|
163
|
+
}: DeleteCommentOptions): Promise<void> => {
|
|
164
|
+
const headers: Record<string, string> = {
|
|
165
|
+
Authorization: `Bearer ${token}`,
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
return fetch(`${serverURL}/comment/${objectId}?lang=${lang}`, {
|
|
169
|
+
method: 'DELETE',
|
|
170
|
+
headers,
|
|
171
|
+
}).then((resp) => resp.json() as Promise<void>);
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
export interface LikeCommentOptions {
|
|
175
|
+
serverURL: string;
|
|
176
|
+
lang: string;
|
|
177
|
+
objectId: number | string;
|
|
178
|
+
like: boolean;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export const likeComment = ({
|
|
182
|
+
serverURL,
|
|
183
|
+
lang,
|
|
184
|
+
objectId,
|
|
185
|
+
like,
|
|
186
|
+
}: LikeCommentOptions): Promise<void> =>
|
|
187
|
+
fetch(`${serverURL}/comment/${objectId}?lang=${lang}`, {
|
|
188
|
+
method: 'PUT',
|
|
189
|
+
headers: JSON_HEADERS,
|
|
190
|
+
body: JSON.stringify({ like }),
|
|
191
|
+
}).then((resp) => resp.json() as Promise<void>);
|
|
192
|
+
|
|
193
|
+
export interface UpdateCommentOptions {
|
|
194
|
+
serverURL: string;
|
|
195
|
+
lang: string;
|
|
196
|
+
token: string;
|
|
197
|
+
objectId: number | string;
|
|
198
|
+
status?: 'approved' | 'waiting' | 'spam';
|
|
199
|
+
sticky?: number;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export const updateComment = ({
|
|
203
|
+
serverURL,
|
|
204
|
+
lang,
|
|
205
|
+
token,
|
|
206
|
+
objectId,
|
|
207
|
+
...data
|
|
208
|
+
}: UpdateCommentOptions): Promise<void> => {
|
|
209
|
+
const headers: Record<string, string> = {
|
|
210
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
211
|
+
'Content-Type': 'application/json',
|
|
212
|
+
Authorization: `Bearer ${token}`,
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
return fetch(`${serverURL}/comment/${objectId}?lang=${lang}`, {
|
|
216
|
+
method: 'PUT',
|
|
217
|
+
headers,
|
|
218
|
+
body: JSON.stringify(data),
|
|
219
|
+
}).then((resp) => resp.json() as Promise<void>);
|
|
220
|
+
};
|
|
221
|
+
|
|
146
222
|
export interface FetchPageviewsOptions {
|
|
147
223
|
serverURL: string;
|
|
148
224
|
lang: string;
|
|
@@ -180,10 +256,7 @@ export const updatePageviews = ({
|
|
|
180
256
|
}: UpdatePageviewsOptions): Promise<number> =>
|
|
181
257
|
fetch(`${serverURL}/article?lang=${lang}`, {
|
|
182
258
|
method: 'POST',
|
|
183
|
-
headers:
|
|
184
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
185
|
-
'Content-Type': 'application/json',
|
|
186
|
-
},
|
|
259
|
+
headers: JSON_HEADERS,
|
|
187
260
|
body: JSON.stringify({ path }),
|
|
188
261
|
})
|
|
189
262
|
.then((resp) => resp.json() as Promise<number>)
|