Skip to content

Commit c8344fe

Browse files
committed
feat(ui): 移除系统模式环境变量限制,调整子模式按钮顺序
- useProSubMode: 移除 isDevelopment 依赖,系统模式(多对话)默认可用 - OptimizationModeSelector: 基础模式(系统|用户),上下文模式(变量|多对话) - App.vue: 移除 hide-system-option 限制,多消息按钮在任何环境下可见
1 parent 1f1f6bc commit c8344fe

File tree

4 files changed

+40
-32
lines changed

4 files changed

+40
-32
lines changed

packages/extension/src/App.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
v-if="functionMode === 'pro'"
4141
:modelValue="proSubMode"
4242
functionMode="pro"
43-
:hide-system-option="!isDev"
4443
@change="handleProSubModeChange"
4544
/>
4645

@@ -819,7 +818,6 @@
819818
:services="servicesForContextEditor"
820819
:variable-manager="variableManager"
821820
:optimization-mode="selectedOptimizationMode"
822-
:context-mode="contextMode"
823821
:scan-variables="
824822
(content) =>
825823
variableManager?.variableManager.value?.scanVariablesInContent(

packages/ui/src/components/OptimizationModeSelector.vue

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,38 @@
66
size="small"
77
class="optimization-mode-selector"
88
>
9-
<NRadioButton
10-
v-if="!hideSystemOption"
11-
value="system"
12-
:title="systemHelp"
13-
>
14-
{{ systemLabel }}
15-
</NRadioButton>
16-
<NRadioButton
17-
value="user"
18-
:title="userHelp"
19-
>
20-
{{ userLabel }}
21-
</NRadioButton>
9+
<!-- 基础模式:系统 | 用户 -->
10+
<template v-if="functionMode !== 'pro'">
11+
<NRadioButton
12+
v-if="!hideSystemOption"
13+
value="system"
14+
:title="systemHelp"
15+
>
16+
{{ systemLabel }}
17+
</NRadioButton>
18+
<NRadioButton
19+
value="user"
20+
:title="userHelp"
21+
>
22+
{{ userLabel }}
23+
</NRadioButton>
24+
</template>
25+
<!-- 上下文模式:变量 | 多对话 -->
26+
<template v-else>
27+
<NRadioButton
28+
value="user"
29+
:title="userHelp"
30+
>
31+
{{ userLabel }}
32+
</NRadioButton>
33+
<NRadioButton
34+
v-if="!hideSystemOption"
35+
value="system"
36+
:title="systemHelp"
37+
>
38+
{{ systemLabel }}
39+
</NRadioButton>
40+
</template>
2241
</NRadioGroup>
2342
</template>
2443

packages/ui/src/composables/mode/useProSubMode.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ref, readonly, type Ref } from 'vue'
22

33
import type { AppServices } from '../../types/services'
44
import { usePreferences } from '../storage/usePreferenceManager'
5-
import { UI_SETTINGS_KEYS, type ProSubMode, isDevelopment } from '@prompt-optimizer/core'
5+
import { UI_SETTINGS_KEYS, type ProSubMode } from '@prompt-optimizer/core'
66

77
interface UseProSubModeApi {
88
proSubMode: Ref<ProSubMode>
@@ -12,9 +12,8 @@ interface UseProSubModeApi {
1212
ensureInitialized: () => Promise<void>
1313
}
1414

15-
// 根据 VITE_LOCAL_DEV 环境变量确定默认模式:开发模式启用 system,生产模式使用 user
16-
// 使用 Core 层的 isDevelopment() 统一判断
17-
const DEFAULT_PRO_SUB_MODE: ProSubMode = isDevelopment() ? 'system' : 'user'
15+
// 默认模式为 user,系统模式(多对话)在任何环境下都可用
16+
const DEFAULT_PRO_SUB_MODE: ProSubMode = 'user'
1817

1918
let singleton: {
2019
mode: Ref<ProSubMode>
@@ -24,8 +23,8 @@ let singleton: {
2423

2524
/**
2625
* 上下文模式(Pro模式)的子模式单例。读取/写入 PreferenceService。
27-
* - 默认值根据 VITE_LOCAL_DEV 环境变量判断:开发模式为 'system',生产模式为 'user'
28-
* - 系统提示词优化仅在开发模式(VITE_LOCAL_DEV=true)下可用
26+
* - 默认值为 'user'
27+
* - 系统模式(多对话优化)在任何环境下都可用
2928
* - 第一次调用时异步初始化
3029
* - 状态独立于基础模式,实现不同功能模式下的子模式状态隔离
3130
*/
@@ -48,18 +47,11 @@ export function useProSubMode(services: Ref<AppServices | null>): UseProSubModeA
4847
}
4948
singleton!.initializing = (async () => {
5049
try {
51-
// 读取 pro-sub-mode;若不存在,返回默认值(VITE_LOCAL_DEV=true:system,其他:user
50+
// 读取 pro-sub-mode;若不存在,返回默认值 'user'
5251
const saved = await getPreference<ProSubMode>(UI_SETTINGS_KEYS.PRO_SUB_MODE, DEFAULT_PRO_SUB_MODE)
5352

54-
// 非开发模式(VITE_LOCAL_DEV≠true)下强制使用 'user' 模式(禁用 'system' 模式)
55-
// 开发模式(VITE_LOCAL_DEV=true)下允许使用 'system' 模式
56-
if (!isDevelopment() && saved === 'system') {
57-
singleton!.mode.value = 'user'
58-
await setPreference(UI_SETTINGS_KEYS.PRO_SUB_MODE, 'user')
59-
console.log('[useProSubMode] 生产模式检测到 system 模式,已强制切换为 user')
60-
} else {
61-
singleton!.mode.value = (saved === 'system' || saved === 'user') ? saved : DEFAULT_PRO_SUB_MODE
62-
}
53+
// 系统模式(多对话)在任何环境下都可用
54+
singleton!.mode.value = (saved === 'system' || saved === 'user') ? saved : DEFAULT_PRO_SUB_MODE
6355

6456
console.log(`[useProSubMode] 初始化完成,当前值: ${singleton!.mode.value}`)
6557

packages/web/src/App.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
v-if="functionMode === 'pro'"
4141
:modelValue="proSubMode"
4242
functionMode="pro"
43-
:hide-system-option="!isDev"
4443
@change="handleProSubModeChange"
4544
/>
4645

0 commit comments

Comments
 (0)