This is an automated email from the ASF dual-hosted git repository.

lizhimins pushed a commit to branch rocketmq-studio
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git

commit 5adad5fee60ac16723463205fa21246bc6c79bf0
Author: lizhimins <[email protected]>
AuthorDate: Wed Jul 22 20:26:15 2026 +0800

    fix: include remaining consolidated frontend changes (#490)
    
    topicService topic API contract, authStore persisted session, vite env 
config.
---
 web/src/services/topicService.ts | 20 +++++++++-----------
 web/src/stores/authStore.ts      | 11 +++++++----
 web/vite.config.ts               | 34 +++++++++++++++++++---------------
 3 files changed, 35 insertions(+), 30 deletions(-)

diff --git a/web/src/services/topicService.ts b/web/src/services/topicService.ts
index f4e03705..39d25cc1 100644
--- a/web/src/services/topicService.ts
+++ b/web/src/services/topicService.ts
@@ -2,6 +2,7 @@ import { USE_MOCK } from '../config';
 import * as metadataApi from '../api/metadata';
 import type {
   Topic,
+  TopicQuery,
   BrokerRoute,
   ConsumerGroupInfo,
   SendTopicMessageRequest,
@@ -9,19 +10,15 @@ import type {
 } from '../api/metadata';
 import { topics as mockTopics, topicRoutes, topicConsumers } from 
'../mock/topics';
 
-export async function listTopics(params?: {
-  keyword?: string;
-  type?: string;
-  namespace?: string;
-}): Promise<Topic[]> {
+export async function listTopics(params?: TopicQuery): Promise<Topic[]> {
   if (USE_MOCK) {
     let result = [...mockTopics];
-    if (params?.keyword) {
-      const kw = params.keyword.toLowerCase();
+    if (params?.search) {
+      const kw = params.search.toLowerCase();
       result = result.filter((t) => t.name.toLowerCase().includes(kw));
     }
     if (params?.type) result = result.filter((t) => t.type === params.type);
-    if (params?.namespace) result = result.filter((t) => t.namespace === 
params.namespace);
+    if (params?.clusterId) result = result.filter((t) => t.clusterId === 
params.clusterId);
     return result as unknown as Topic[];
   }
   return metadataApi.listTopics(params);
@@ -43,11 +40,12 @@ export async function createTopic(data: Partial<Topic>): 
Promise<Topic> {
   return metadataApi.createTopic(data);
 }
 
-export async function updateTopic(data: Partial<Topic>): Promise<void> {
+export async function updateTopic(data: Partial<Topic>): Promise<Topic> {
   if (USE_MOCK) {
     const idx = mockTopics.findIndex((t) => t.name === data.name);
-    if (idx >= 0) Object.assign(mockTopics[idx], data, { updatedAt: new 
Date().toISOString() });
-    return;
+    if (idx < 0) throw new Error(`Topic not found: ${data.name}`);
+    Object.assign(mockTopics[idx], data, { updatedAt: new Date().toISOString() 
});
+    return mockTopics[idx] as unknown as Topic;
   }
   return metadataApi.updateTopic(data);
 }
diff --git a/web/src/stores/authStore.ts b/web/src/stores/authStore.ts
index 7a58962c..9804208f 100644
--- a/web/src/stores/authStore.ts
+++ b/web/src/stores/authStore.ts
@@ -16,6 +16,7 @@
  */
 
 import { create } from 'zustand';
+import { clearAuthSession, persistAuthSession, readAuthSession } from 
'./authStorage';
 
 interface AuthState {
   user: string | null;
@@ -24,15 +25,17 @@ interface AuthState {
   logout: () => void;
 }
 
+const initialSession = readAuthSession();
+
 const useAuthStore = create<AuthState>((set) => ({
-  user: null,
-  token: null,
+  user: initialSession.user,
+  token: initialSession.token,
   login: (token: string, user: string) => {
-    localStorage.setItem('token', token);
+    persistAuthSession(token, user);
     set({ token, user });
   },
   logout: () => {
-    localStorage.removeItem('token');
+    clearAuthSession();
     set({ token: null, user: null });
   },
 }));
diff --git a/web/vite.config.ts b/web/vite.config.ts
index f8d5b64a..d5c0bebf 100644
--- a/web/vite.config.ts
+++ b/web/vite.config.ts
@@ -1,21 +1,25 @@
 import { defineConfig } from 'vitest/config';
+import { loadEnv } from 'vite';
 import react from '@vitejs/plugin-react';
 
-export default defineConfig({
-  plugins: [react()],
-  server: {
-    port: 5173,
-    proxy: {
-      '/api': {
-        target: 'http://localhost:8888',
-        changeOrigin: true,
+export default defineConfig(({ mode }) => {
+  const env = loadEnv(mode, '.', '');
+  return {
+    plugins: [react()],
+    server: {
+      port: 5173,
+      proxy: {
+        '/api': {
+          target: env.VITE_API_PROXY_TARGET || 'http://localhost:8888',
+          changeOrigin: true,
+        },
       },
     },
-  },
-  test: {
-    globals: true,
-    environment: 'jsdom',
-    setupFiles: './src/test/setup.ts',
-    css: true,
-  },
+    test: {
+      globals: true,
+      environment: 'jsdom',
+      setupFiles: './src/test/setup.ts',
+      css: true,
+    },
+  };
 });

Reply via email to