Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/main/presenter/floatingButtonPresenter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ipcMain, Menu, app, screen } from 'electron'
import { FLOATING_BUTTON_EVENTS } from '@/events'
import { presenter } from '../index'
import { IConfigPresenter } from '@shared/presenter'
import { FLOATING_BUTTON_AVAILABLE } from '@shared/featureFlags'

export class FloatingButtonPresenter {
private floatingWindow: FloatingButtonWindow | null = null
Expand All @@ -21,6 +22,12 @@ export class FloatingButtonPresenter {
* 初始化悬浮按钮功能
*/
public async initialize(config?: Partial<FloatingButtonConfig>): Promise<void> {
if (!FLOATING_BUTTON_AVAILABLE) {
this.destroy()
console.log('FloatingButton is temporarily unavailable, skipping initialization')
return
}

const floatingButtonEnabled = this.configPresenter.getFloatingButtonEnabled()
try {
this.config = {
Expand Down Expand Up @@ -70,6 +77,12 @@ export class FloatingButtonPresenter {
* 启用悬浮按钮
*/
public async enable(): Promise<void> {
if (!FLOATING_BUTTON_AVAILABLE) {
this.destroy()
console.log('FloatingButton is temporarily unavailable, skipping enable')
return
}

console.log(
'FloatingButtonPresenter.enable called, current enabled:',
this.config.enabled,
Expand All @@ -93,6 +106,11 @@ export class FloatingButtonPresenter {
* 设置悬浮按钮启用状态
*/
public async setEnabled(enabled: boolean): Promise<void> {
if (!FLOATING_BUTTON_AVAILABLE) {
this.destroy()
return
}

if (enabled) {
await this.enable()
} else {
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/settings/components/DisplaySettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@
</div>

<!-- 悬浮按钮开关 -->
<div class="flex flex-col gap-2 px-2 py-2">
<div v-if="FLOATING_BUTTON_AVAILABLE" class="flex flex-col gap-2 px-2 py-2">
<div class="flex items-center gap-3">
<span
class="flex items-center gap-2 text-sm font-medium shrink-0 min-w-[220px]"
Expand Down Expand Up @@ -307,6 +307,7 @@ import {
import { ref, onMounted, watch, computed } from 'vue'
import { storeToRefs } from 'pinia'

import { FLOATING_BUTTON_AVAILABLE } from '@shared/featureFlags'
import { useUiSettingsStore } from '@/stores/uiSettingsStore'
import { useLanguageStore } from '@/stores/language'
import { useFloatingButtonStore } from '@/stores/floatingButton'
Expand Down
1 change: 1 addition & 0 deletions src/shared/featureFlags.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const FLOATING_BUTTON_AVAILABLE = false
Loading