@waline/client 2.13.1 → 2.14.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.
Files changed (66) hide show
  1. package/dist/api.cjs +1 -1
  2. package/dist/api.cjs.map +1 -1
  3. package/dist/api.d.cts +60 -34
  4. package/dist/api.d.mts +60 -34
  5. package/dist/api.d.ts +60 -34
  6. package/dist/api.mjs +1 -1
  7. package/dist/api.mjs.map +1 -1
  8. package/dist/comment.cjs +1 -1
  9. package/dist/comment.cjs.map +1 -1
  10. package/dist/comment.d.cts +1 -1
  11. package/dist/comment.d.mts +1 -1
  12. package/dist/comment.d.ts +1 -1
  13. package/dist/comment.js +40 -45
  14. package/dist/comment.js.map +1 -1
  15. package/dist/comment.mjs +1 -1
  16. package/dist/comment.mjs.map +1 -1
  17. package/dist/component.mjs +1 -1
  18. package/dist/component.mjs.map +1 -1
  19. package/dist/legacy.umd.d.ts +13 -3
  20. package/dist/legacy.umd.js +1 -1
  21. package/dist/legacy.umd.js.map +1 -1
  22. package/dist/pageview.cjs +1 -1
  23. package/dist/pageview.cjs.map +1 -1
  24. package/dist/pageview.js +44 -49
  25. package/dist/pageview.js.map +1 -1
  26. package/dist/pageview.mjs +1 -1
  27. package/dist/pageview.mjs.map +1 -1
  28. package/dist/shim.cjs +1 -1
  29. package/dist/shim.cjs.map +1 -1
  30. package/dist/shim.d.cts +15 -9
  31. package/dist/shim.d.mts +15 -9
  32. package/dist/shim.mjs +1 -1
  33. package/dist/shim.mjs.map +1 -1
  34. package/dist/waline.cjs +1 -1
  35. package/dist/waline.cjs.map +1 -1
  36. package/dist/waline.css +1 -1
  37. package/dist/waline.css.map +1 -1
  38. package/dist/waline.d.cts +15 -9
  39. package/dist/waline.d.mts +15 -9
  40. package/dist/waline.d.ts +15 -9
  41. package/dist/waline.js +441 -449
  42. package/dist/waline.js.map +1 -1
  43. package/dist/waline.mjs +1 -1
  44. package/dist/waline.mjs.map +1 -1
  45. package/package.json +1 -1
  46. package/src/api/articleCounter.ts +3 -7
  47. package/src/api/comment.ts +60 -49
  48. package/src/api/commentCount.ts +0 -2
  49. package/src/api/pageview.ts +2 -2
  50. package/src/api/recentComment.ts +2 -5
  51. package/src/api/user.ts +2 -4
  52. package/src/api/utils.ts +17 -10
  53. package/src/comment.ts +1 -1
  54. package/src/compact/convert.ts +1 -1
  55. package/src/components/CommentBox.vue +14 -11
  56. package/src/components/Waline.vue +35 -34
  57. package/src/pageview.ts +3 -3
  58. package/src/styles/index.scss +2 -2
  59. package/src/styles/{nomalize.scss → normalize.scss} +0 -0
  60. package/src/styles/panel.scss +1 -1
  61. package/src/styles/{userlist.scss → user-list.scss} +0 -0
  62. package/src/typings/base.ts +5 -1
  63. package/src/typings/comment.ts +1 -5
  64. package/src/typings/waline.ts +13 -2
  65. package/src/utils/config.ts +2 -0
  66. package/src/utils/date.ts +3 -3
@@ -1,3 +1,5 @@
1
+ export type WalineCommentSorting = 'latest' | 'oldest' | 'hottest';
2
+
1
3
  export interface WalineEmojiInfo {
2
4
  /**
3
5
  * 选项卡上的 Emoji 名称
@@ -39,6 +41,8 @@ export interface WalineEmojiInfo {
39
41
 
40
42
  export type WalineEmojiMaps = Record<string, string>;
41
43
 
44
+ export type WalineLoginStatus = 'enable' | 'disable' | 'force';
45
+
42
46
  export interface WalineSearchImageData extends Record<string, unknown> {
43
47
  /**
44
48
  * 图片链接
@@ -102,7 +106,7 @@ export interface WalineSearchOptions {
102
106
  *
103
107
  * @default (word) => search(word)
104
108
  */
105
- more?: (word: string, currectCount: number) => Promise<WalineSearchResult>;
109
+ more?: (word: string, currentCount: number) => Promise<WalineSearchResult>;
106
110
  }
107
111
 
108
112
  export type WalineMeta = 'nick' | 'mail' | 'link';
@@ -40,15 +40,11 @@ export interface WalineCommentData {
40
40
  */
41
41
  at?: string;
42
42
 
43
- /**
44
- * edit comment id
45
- */
46
- eid?: string;
47
-
48
43
  /**
49
44
  * Comment link
50
45
  */
51
46
  url: string;
47
+
52
48
  /**
53
49
  * Recaptcha Token
54
50
  */
@@ -1,7 +1,9 @@
1
1
  import type {
2
+ WalineCommentSorting,
2
3
  WalineHighlighter,
3
4
  WalineEmojiInfo,
4
5
  WalineImageUploader,
6
+ WalineLoginStatus,
5
7
  WalineMeta,
6
8
  WalineTexRenderer,
7
9
  WalineSearchOptions,
@@ -129,6 +131,15 @@ export interface WalineProps {
129
131
  */
130
132
  locale?: Partial<WalineLocale>;
131
133
 
134
+ /**
135
+ * 评论列表排序方式
136
+ *
137
+ * Sorting method for comment list
138
+ *
139
+ * @default 'latest'
140
+ */
141
+ commentSorting?: WalineCommentSorting;
142
+
132
143
  /**
133
144
  * 是否启用暗黑模式适配
134
145
  *
@@ -194,12 +205,12 @@ export interface WalineProps {
194
205
  * Login mode status, optional values:
195
206
  *
196
207
  * - `'enable'`: enable login (default)
197
- * - `'disable'`: Login is disabled, users should fill in infomation to comment
208
+ * - `'disable'`: Login is disabled, users should fill in information to comment
198
209
  * - `'force'`: Forced login, users must login to comment
199
210
  *
200
211
  * @default 'enable'
201
212
  */
202
- login?: 'enable' | 'disable' | 'force';
213
+ login?: WalineLoginStatus;
203
214
 
204
215
  /**
205
216
  * 是否在页脚展示版权信息
@@ -67,6 +67,7 @@ export const getConfig = ({
67
67
  search,
68
68
  reaction,
69
69
  recaptchaV3Key = '',
70
+ commentSorting = 'latest',
70
71
  ...more
71
72
  }: WalineProps): WalineConfig => ({
72
73
  serverURL: getServerURL(serverURL),
@@ -94,5 +95,6 @@ export const getConfig = ({
94
95
  : reaction === true
95
96
  ? defaultReaction
96
97
  : [],
98
+ commentSorting,
97
99
  ...more,
98
100
  });
package/src/utils/date.ts CHANGED
@@ -30,15 +30,15 @@ export const getTimeAgo = (
30
30
  ? new Date(date.indexOf(' ') !== -1 ? date.replace(/-/g, '/') : date)
31
31
  : date;
32
32
 
33
- const timepassed = now.getTime() - time.getTime();
33
+ const timePassed = now.getTime() - time.getTime();
34
34
 
35
- const days = Math.floor(timepassed / (24 * 3600 * 1000));
35
+ const days = Math.floor(timePassed / (24 * 3600 * 1000));
36
36
 
37
37
  if (days === 0) {
38
38
  // 计算相差小时数
39
39
 
40
40
  // 计算天数后剩余的毫秒数
41
- const leave1 = timepassed % (24 * 3600 * 1000);
41
+ const leave1 = timePassed % (24 * 3600 * 1000);
42
42
  const hours = Math.floor(leave1 / (3600 * 1000));
43
43
 
44
44
  if (hours === 0) {