@waline/client 2.3.1 → 2.4.1
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 -8
- 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 +45 -10
- package/dist/shim.esm.d.ts +45 -10
- 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 +45 -10
- 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 +45 -10
- package/dist/waline.esm.d.ts +45 -10
- 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 +20 -5
- package/src/components/CommentBox.vue +1 -3
- package/src/components/CommentCard.vue +80 -14
- package/src/components/Icons.ts +28 -2
- package/src/components/Waline.vue +220 -98
- 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/utils/config.ts +1 -1
- package/src/utils/fetch.ts +77 -4
|
@@ -10,11 +10,19 @@ export interface UserInfo {
|
|
|
10
10
|
token: string;
|
|
11
11
|
avatar: string;
|
|
12
12
|
mailMd5: string;
|
|
13
|
+
objectId: string | number;
|
|
14
|
+
type: 'administrator' | 'guest';
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
export const USER_KEY = 'WALINE_USER';
|
|
16
18
|
|
|
17
19
|
export type UserInfoRef = Ref<UserInfo | Record<string, never>>;
|
|
18
20
|
|
|
21
|
+
let userInfoStorage: UserInfoRef | null = null;
|
|
22
|
+
|
|
19
23
|
export const useUserInfo = (): UserInfoRef =>
|
|
20
|
-
|
|
24
|
+
userInfoStorage ||
|
|
25
|
+
(userInfoStorage = useStorage<UserInfo | Record<string, never>>(
|
|
26
|
+
'USER_KEY',
|
|
27
|
+
{}
|
|
28
|
+
));
|
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
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
.wl-user {
|
|
19
19
|
--avatar-size: var(--waline-avatar-size);
|
|
20
20
|
|
|
21
|
+
position: relative;
|
|
22
|
+
margin-right: 0.75em;
|
|
23
|
+
|
|
21
24
|
@media (max-width: 720px) {
|
|
22
25
|
--avatar-size: var(--waline-m-avatar-size);
|
|
23
26
|
}
|
|
24
27
|
|
|
25
|
-
position: relative;
|
|
26
|
-
margin-right: 0.75em;
|
|
27
|
-
|
|
28
28
|
img {
|
|
29
29
|
width: var(--avatar-size);
|
|
30
30
|
height: var(--avatar-size);
|
|
@@ -101,30 +101,6 @@
|
|
|
101
101
|
font-size: 0.75em;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
.wl-reply {
|
|
105
|
-
float: right;
|
|
106
|
-
|
|
107
|
-
padding: 4px;
|
|
108
|
-
border: none;
|
|
109
|
-
|
|
110
|
-
background: transparent;
|
|
111
|
-
color: var(--waline-color);
|
|
112
|
-
|
|
113
|
-
line-height: 1;
|
|
114
|
-
|
|
115
|
-
cursor: pointer;
|
|
116
|
-
|
|
117
|
-
transition: color 0.2s ease;
|
|
118
|
-
|
|
119
|
-
&:hover {
|
|
120
|
-
color: var(--waline-theme-color);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
&.active {
|
|
124
|
-
color: var(--waline-active-color);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
104
|
.wl-meta {
|
|
129
105
|
position: relative;
|
|
130
106
|
line-height: 1;
|
|
@@ -152,6 +128,36 @@
|
|
|
152
128
|
}
|
|
153
129
|
}
|
|
154
130
|
|
|
131
|
+
.wl-comment-actions {
|
|
132
|
+
float: right;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.wl-delete,
|
|
136
|
+
.wl-like,
|
|
137
|
+
.wl-reply {
|
|
138
|
+
display: inline-flex;
|
|
139
|
+
align-items: center;
|
|
140
|
+
padding: 4px;
|
|
141
|
+
border: none;
|
|
142
|
+
|
|
143
|
+
background: transparent;
|
|
144
|
+
color: var(--waline-color);
|
|
145
|
+
|
|
146
|
+
line-height: 1;
|
|
147
|
+
|
|
148
|
+
cursor: pointer;
|
|
149
|
+
|
|
150
|
+
transition: color 0.2s ease;
|
|
151
|
+
|
|
152
|
+
&:hover {
|
|
153
|
+
color: var(--waline-theme-color);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
&.active {
|
|
157
|
+
color: var(--waline-active-color);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
155
161
|
.wl-content {
|
|
156
162
|
position: relative;
|
|
157
163
|
|
|
@@ -213,6 +219,28 @@
|
|
|
213
219
|
}
|
|
214
220
|
}
|
|
215
221
|
|
|
222
|
+
.wl-admin-actions {
|
|
223
|
+
margin: 8px 0;
|
|
224
|
+
font-size: 12px;
|
|
225
|
+
text-align: right;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.wl-comment-status {
|
|
229
|
+
margin: 0 8px;
|
|
230
|
+
|
|
231
|
+
.wl-btn {
|
|
232
|
+
border-radius: 0;
|
|
233
|
+
|
|
234
|
+
&:first-child {
|
|
235
|
+
border-radius: 0.5em 0 0 0.5em;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
&:last-child {
|
|
239
|
+
border-radius: 0 0.5em 0.5em 0;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
216
244
|
.wl-quote {
|
|
217
245
|
border-left: 1px dashed rgb(237 237 237 / 50%);
|
|
218
246
|
|
package/src/styles/nomalize.scss
CHANGED
package/src/styles/panel.scss
CHANGED
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/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>)
|