Skip to content

Commit 356780e

Browse files
committed
refactor(frontend): 移除禁用右键点击功能及相关代码
1 parent fc574e6 commit 356780e

File tree

2 files changed

+5
-54
lines changed

2 files changed

+5
-54
lines changed

frontend/src/App.svelte

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { onMount, onDestroy } from 'svelte';
44
import { i18n as i18nData } from './lib/i18n.js';
55
import { EventsOn, EventsOff, WindowMinimise, WindowMaximise, WindowUnmaximise, WindowIsMaximised, Quit, Environment } from '../wailsjs/runtime/runtime.js';
6-
import { ListCases, ListTemplates, GetConfig, GetVersion, GetMCPStatus, StartMCPServer, StopMCPServer, GetResourceSummary, GetBalances, GetTerraformMirrorConfig, GetNotificationEnabled, GetCurrentProject, ListProjects, SwitchProject, CreateProject, GetDisableRightClick, SetDisableRightClick, CheckForUpdates, GetLanguage, SetLanguage, GetShowWelcomeDialog, GetSpotMonitorEnabled, GetSpotAutoRecoverEnabled } from '../wailsjs/go/main/App.js';
6+
import { ListCases, ListTemplates, GetConfig, GetVersion, GetMCPStatus, StartMCPServer, StopMCPServer, GetResourceSummary, GetBalances, GetTerraformMirrorConfig, GetNotificationEnabled, GetCurrentProject, ListProjects, SwitchProject, CreateProject, CheckForUpdates, GetLanguage, SetLanguage, GetShowWelcomeDialog, GetSpotMonitorEnabled, GetSpotAutoRecoverEnabled } from '../wailsjs/go/main/App.js';
77
import Console from './components/Console/Console.svelte';
88
import CloudResources from './components/Resources/CloudResources.svelte';
99
import Compose from './components/Compose/Compose.svelte';
@@ -36,18 +36,11 @@
3636
let notificationEnabled = $state(false);
3737
let spotMonitorEnabled = $state(false);
3838
let spotAutoRecoverEnabled = $state(false);
39-
let rightClickDisabled = $state(true);
40-
let rightClickDisabledSync = true; // 同步变量用于右键处理
4139
let appVersion = $state('');
4240
4341
// 控制欢迎弹框是否可见(用于避免闪烁)
4442
let welcomeDialogReady = $state(false);
4543
let hasCheckedWelcomeDialog = $state(false);
46-
47-
// 当 rightClickDisabled 变化时更新同步变量
48-
$effect(() => {
49-
rightClickDisabledSync = rightClickDisabled;
50-
});
5144
5245
// 监听页面切换到仪表盘时检查欢迎弹框(只检查一次)
5346
$effect(() => {
@@ -167,14 +160,6 @@
167160
const env = await Environment();
168161
isWindows = env.platform === 'windows';
169162
170-
// 注册右键菜单处理 - 使用同步变量
171-
window.addEventListener('contextmenu', (e) => {
172-
if (rightClickDisabledSync) {
173-
e.preventDefault();
174-
e.stopPropagation();
175-
}
176-
}, true);
177-
178163
EventsOn('log', (message) => {
179164
logs = [...logs, { time: new Date().toLocaleTimeString(), message }];
180165
if (dashboardComponent && dashboardComponent.updateCreateStatusFromLog) {
@@ -209,19 +194,17 @@
209194
isLoading = true;
210195
error = '';
211196
try {
212-
[cases, templates, config, terraformMirror, notificationEnabled, rightClickDisabled, lang, appVersion, spotMonitorEnabled, spotAutoRecoverEnabled] = await Promise.all([
197+
[cases, templates, config, terraformMirror, notificationEnabled, lang, appVersion, spotMonitorEnabled, spotAutoRecoverEnabled] = await Promise.all([
213198
ListCases(),
214199
ListTemplates(),
215200
GetConfig(),
216201
GetTerraformMirrorConfig(),
217202
GetNotificationEnabled(),
218-
GetDisableRightClick(),
219203
GetLanguage(),
220204
GetVersion(),
221205
GetSpotMonitorEnabled(),
222206
GetSpotAutoRecoverEnabled()
223207
]);
224-
rightClickDisabledSync = rightClickDisabled;
225208
debugEnabled = !!config.debugEnabled;
226209
} catch (e) {
227210
error = e.message || String(e);
@@ -418,7 +401,7 @@
418401
<Compose {t} onTabChange={(tab) => activeTab = tab} />
419402

420403
{:else if activeTab === 'settings'}
421-
<Settings {t} bind:config bind:terraformMirror bind:debugEnabled bind:notificationEnabled bind:spotMonitorEnabled bind:spotAutoRecoverEnabled bind:rightClickDisabled />
404+
<Settings {t} bind:config bind:terraformMirror bind:debugEnabled bind:notificationEnabled bind:spotMonitorEnabled bind:spotAutoRecoverEnabled />
422405

423406
{:else if activeTab === 'registry'}
424407
<Registry {t} />

frontend/src/components/Settings/Settings.svelte

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script>
2-
import { SaveProxyConfig, SetDebugLogging, GetTerraformMirrorConfig, SaveTerraformMirrorConfig, TestTerraformEndpoints, SetNotificationEnabled, SetDisableRightClick, SetSpotMonitorEnabled, SetSpotAutoRecoverEnabled, GetWebhookConfig, SetWebhookConfig, TestWebhook, GetHTTPServerConfig, SetHTTPServerConfig, StartHTTPServer, StopHTTPServer, GetHTTPServerStatus } from '../../../wailsjs/go/main/App.js';
2+
import { SaveProxyConfig, SetDebugLogging, GetTerraformMirrorConfig, SaveTerraformMirrorConfig, TestTerraformEndpoints, SetNotificationEnabled, SetSpotMonitorEnabled, SetSpotAutoRecoverEnabled, GetWebhookConfig, SetWebhookConfig, TestWebhook, GetHTTPServerConfig, SetHTTPServerConfig, StartHTTPServer, StopHTTPServer, GetHTTPServerStatus } from '../../../wailsjs/go/main/App.js';
33
4-
let { t, config = $bindable({ redcPath: '', projectPath: '', logPath: '' }), terraformMirror = $bindable({ enabled: false, configPath: '', managed: false, fromEnv: false, providers: [] }), debugEnabled = $bindable(false), notificationEnabled = $bindable(false), spotMonitorEnabled = $bindable(false), spotAutoRecoverEnabled = $bindable(false), rightClickDisabled = $bindable(false) } = $props();
4+
let { t, config = $bindable({ redcPath: '', projectPath: '', logPath: '' }), terraformMirror = $bindable({ enabled: false, configPath: '', managed: false, fromEnv: false, providers: [] }), debugEnabled = $bindable(false), notificationEnabled = $bindable(false), spotMonitorEnabled = $bindable(false), spotAutoRecoverEnabled = $bindable(false) } = $props();
55
let proxyForm = $state({ httpProxy: '', httpsProxy: '', socks5Proxy: '', noProxy: '' });
66
let proxySaving = $state(false);
77
let proxySaved = $state(false);
@@ -16,7 +16,6 @@ let { t, config = $bindable({ redcPath: '', projectPath: '', logPath: '' }), ter
1616
let notificationSaving = $state(false);
1717
let spotMonitorSaving = $state(false);
1818
let spotAutoRecoverSaving = $state(false);
19-
let rightClickSaving = $state(false);
2019
let webhookForm = $state({ enabled: false, slack: '', dingtalk: '', dingtalkSecret: '', feishu: '', feishuSecret: '', discord: '', wecom: '' });
2120
let webhookSaving = $state(false);
2221
let webhookMessage = $state('');
@@ -271,19 +270,6 @@ let { t, config = $bindable({ redcPath: '', projectPath: '', logPath: '' }), ter
271270
spotAutoRecoverSaving = false;
272271
}
273272
}
274-
275-
async function handleToggleRightClick() {
276-
const nextValue = !rightClickDisabled;
277-
rightClickSaving = true;
278-
try {
279-
await SetDisableRightClick(nextValue);
280-
rightClickDisabled = nextValue;
281-
} catch (e) {
282-
console.error('Failed to toggle right click:', e);
283-
} finally {
284-
rightClickSaving = false;
285-
}
286-
}
287273
288274
async function handleToggleTerraformMirror() {
289275
const nextValue = !terraformMirrorForm.enabled;
@@ -795,24 +781,6 @@ let { t, config = $bindable({ redcPath: '', projectPath: '', logPath: '' }), ter
795781
</button>
796782
</div>
797783
{/if}
798-
<!-- 右键菜单 -->
799-
<div class="flex items-center justify-between px-4 sm:px-5 py-3.5">
800-
<div>
801-
<div class="text-[13px] sm:text-[14px] font-medium text-gray-900">{t.disableRightClick}</div>
802-
<div class="text-[11px] sm:text-[12px] text-gray-500 mt-0.5">{t.disableRightClickDesc}</div>
803-
</div>
804-
<button
805-
class="relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer"
806-
class:bg-emerald-500={rightClickDisabled}
807-
class:bg-gray-300={!rightClickDisabled}
808-
onclick={handleToggleRightClick}
809-
disabled={rightClickSaving}
810-
aria-label={rightClickDisabled ? t.enable : t.disable}
811-
>
812-
<span class="inline-block h-4 w-4 transform rounded-full bg-white transition-transform"
813-
class:translate-x-6={rightClickDisabled} class:translate-x-1={!rightClickDisabled}></span>
814-
</button>
815-
</div>
816784
</div>
817785
818786
<!-- HTTP Server Section -->

0 commit comments

Comments
 (0)