@liujitcn/kratos-uni-app-system 0.0.54 → 0.0.56

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/index.mjs CHANGED
@@ -4,6 +4,7 @@ import { registerUserStoreExtension } from "@liujitcn/kratos-uni-app-core/stores
4
4
  // src/notification.ts
5
5
  import { ref } from "vue";
6
6
  import { setAppMenuBadge } from "@liujitcn/kratos-uni-app-core/navigation";
7
+ import { hasValidToken } from "@liujitcn/kratos-uni-app-core/utils/auth";
7
8
  import { getRequestAccessToken, requestBaseURL } from "@liujitcn/kratos-uni-app-core/utils/http";
8
9
 
9
10
  // src/api/base/v1/notification.ts
@@ -51,7 +52,7 @@ var NotificationServiceImpl = class {
51
52
  const response = await http({
52
53
  url: `${NOTIFICATION_URL}/summary`,
53
54
  method: "GET",
54
- authMode: "required",
55
+ authMode: "optional",
55
56
  data: request
56
57
  });
57
58
  return {
@@ -132,6 +133,8 @@ async function refreshNotificationSummary() {
132
133
  }
133
134
  function startNotificationPolling() {
134
135
  stopNotificationPolling();
136
+ if (!hasValidToken())
137
+ return;
135
138
  notificationPaused = false;
136
139
  void refreshNotificationSummary();
137
140
  notificationTimer = setInterval(() => void refreshNotificationSummary(), 3e4);
@@ -149,9 +152,8 @@ function pauseNotificationPolling() {
149
152
  clearNotificationResources();
150
153
  }
151
154
  function resumeNotificationPolling() {
152
- if (!notificationPaused)
155
+ if (!notificationPaused || !hasValidToken())
153
156
  return;
154
- notificationPaused = false;
155
157
  startNotificationPolling();
156
158
  }
157
159
  function clearNotificationResources() {
@@ -167,7 +169,7 @@ function startNotificationSse() {
167
169
  let retryDelay = 1e3;
168
170
  while (!controller.signal.aborted) {
169
171
  try {
170
- const token = await getRequestAccessToken();
172
+ const token = await getRequestAccessToken("optional");
171
173
  if (!token || controller.signal.aborted)
172
174
  return;
173
175
  const sseBaseURL = requestBaseURL.replace(/\/api\/?$/, "") || window.location.origin;
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "type": "git",
8
8
  "url": "git@github.com:liujitcn/kratos-admin.git"
9
9
  },
10
- "version": "0.0.54",
10
+ "version": "0.0.56",
11
11
  "type": "module",
12
12
  "files": [
13
13
  "dist",
@@ -35,7 +35,7 @@
35
35
  "@dcloudio/uni-app": "3.0.0-5010520260709002",
36
36
  "@dcloudio/uni-ui": "^1.4.28",
37
37
  "vue": "^3.4.21",
38
- "@liujitcn/kratos-uni-app-core": "^0.0.54"
38
+ "@liujitcn/kratos-uni-app-core": "^0.0.56"
39
39
  },
40
40
  "devDependencies": {
41
41
  "esbuild": "^0.20.2",
@@ -67,7 +67,7 @@ export class NotificationServiceImpl implements NotificationService {
67
67
  const response = await http<Partial<NotificationSummary>>({
68
68
  url: `${NOTIFICATION_URL}/summary`,
69
69
  method: 'GET',
70
- authMode: 'required',
70
+ authMode: 'optional',
71
71
  data: request,
72
72
  })
73
73
  return {
@@ -9,6 +9,6 @@
9
9
  | `en-US.json` | System 模块英文语言包。 | uni-app 切换为英文时使用。 |
10
10
  | `ja-JP.json` | System 模块日文语言包。 | uni-app 切换为日文时使用。 |
11
11
 
12
- 语言键必须使用 `system.` 命名空间;语言包保持标准 JSON,不在文件内写注释。新增语言后执行仓库根目录的 `make i18n-sync`。
12
+ 语言键必须使用 `system.` 命名空间;语言包保持标准 JSON,不在文件内写注释。新增语言后执行仓库根目录的 `make i18n`。
13
13
 
14
14
  新增语言的完整文件清单和迁移流程见[国际化语言扩展指南](../../../../../../../docs/国际化语言扩展指南.md)。
@@ -1,5 +1,6 @@
1
1
  import { ref } from 'vue'
2
2
  import { setAppMenuBadge } from '@liujitcn/kratos-uni-app-core/navigation'
3
+ import { hasValidToken } from '@liujitcn/kratos-uni-app-core/utils/auth'
3
4
  import { getRequestAccessToken, requestBaseURL } from '@liujitcn/kratos-uni-app-core/utils/http'
4
5
  import { defNotificationService } from './api/base/v1/notification'
5
6
 
@@ -24,6 +25,7 @@ export async function refreshNotificationSummary(): Promise<void> {
24
25
  /** 启动应用端站内信定时回源。 */
25
26
  export function startNotificationPolling(): void {
26
27
  stopNotificationPolling()
28
+ if (!hasValidToken()) return
27
29
  notificationPaused = false
28
30
  void refreshNotificationSummary()
29
31
  notificationTimer = setInterval(() => void refreshNotificationSummary(), 30_000)
@@ -47,8 +49,7 @@ export function pauseNotificationPolling(): void {
47
49
 
48
50
  /** 恢复前台通知资源并立即对账。 */
49
51
  export function resumeNotificationPolling(): void {
50
- if (!notificationPaused) return
51
- notificationPaused = false
52
+ if (!notificationPaused || !hasValidToken()) return
52
53
  startNotificationPolling()
53
54
  }
54
55
 
@@ -67,7 +68,7 @@ function startNotificationSse(): () => void {
67
68
  let retryDelay = 1_000
68
69
  while (!controller.signal.aborted) {
69
70
  try {
70
- const token = await getRequestAccessToken()
71
+ const token = await getRequestAccessToken('optional')
71
72
  if (!token || controller.signal.aborted) return
72
73
  const sseBaseURL = requestBaseURL.replace(/\/api\/?$/, '') || window.location.origin
73
74
  const response = await fetch(`${sseBaseURL}/events/base.notification`, {