This commit is contained in:
Baobhan Sith
2025-05-07 23:21:18 +08:00
parent 6f4996fcd8
commit 5e1146481a
6 changed files with 121 additions and 27 deletions
@@ -286,12 +286,24 @@ export const useConnectionsStore = defineStore('connections', {
},
// +++ 新增:获取 VNC 会话令牌 +++
async getVncSessionToken(connectionId: number): Promise<string | null> {
async getVncSessionToken(connectionId: number, width?: number, height?: number): Promise<string | null> {
// this.isLoading = true; // 考虑是否需要独立的加载状态,或者由调用方处理
// this.error = null;
try {
// 调用后端 API GET /connections/:id/vnc-session
const response = await apiClient.post<{ token: string }>(`/connections/${connectionId}/vnc-session`);
let apiUrl = `/connections/${connectionId}/vnc-session`;
const params = new URLSearchParams();
if (width !== undefined) {
params.append('width', String(width));
}
if (height !== undefined) {
params.append('height', String(height));
}
const queryString = params.toString();
if (queryString) {
apiUrl += `?${queryString}`;
}
// 调用后端 API POST /connections/:id/vnc-session (现在带有可选的 width/height 查询参数)
const response = await apiClient.post<{ token: string }>(apiUrl);
return response.data.token;
} catch (err: any) {
console.error(`获取 VNC 会话令牌失败 (连接 ID: ${connectionId}):`, err);
+14 -1
View File
@@ -50,6 +50,8 @@ interface SettingsState {
timezone?: string; // NEW: 时区设置 (e.g., 'Asia/Shanghai', 'UTC')
rdpModalWidth?: string; // NEW: RDP 模态框宽度
rdpModalHeight?: string; // NEW: RDP 模态框高度
vncModalWidth?: string; // NEW: VNC 模态框宽度
vncModalHeight?: string; // NEW: VNC 模态框高度
ipBlacklistEnabled?: string;
dashboardSortBy?: SortField;
dashboardSortOrder?: SortOrder;
@@ -250,7 +252,14 @@ export const useSettingsStore = defineStore('settings', () => {
if (settings.value.rdpModalHeight === undefined) {
settings.value.rdpModalHeight = '858';
}
// NEW: VNC Modal Size defaults
if (settings.value.vncModalWidth === undefined) {
settings.value.vncModalWidth = '1024'; // 默认宽度
}
if (settings.value.vncModalHeight === undefined) {
settings.value.vncModalHeight = '768'; // 默认高度
}
if (settings.value.dashboardSortBy === undefined) {
settings.value.dashboardSortBy = 'last_connected_at';
}
@@ -364,6 +373,8 @@ export const useSettingsStore = defineStore('settings', () => {
'timezone', // NEW: 添加时区键
'rdpModalWidth', // NEW: 添加 RDP 模态框宽度键
'rdpModalHeight', // NEW: 添加 RDP 模态框高度键
'vncModalWidth', // NEW: 添加 VNC 模态框宽度键
'vncModalHeight', // NEW: 添加 VNC 模态框高度键
'ipBlacklistEnabled',
'dashboardSortBy',
'dashboardSortOrder',
@@ -451,6 +462,8 @@ export const useSettingsStore = defineStore('settings', () => {
'timezone', // NEW: 添加时区键
'rdpModalWidth', // NEW: 添加 RDP 模态框宽度键
'rdpModalHeight', // NEW: 添加 RDP 模态框高度键
'vncModalWidth', // NEW: 添加 VNC 模态框宽度键
'vncModalHeight', // NEW: 添加 VNC 模态框高度键
'ipBlacklistEnabled',
'dashboardSortBy',
'dashboardSortOrder',