Skip to content

Commit b572855

Browse files
committed
添加设置选项:1. 增加隐藏变量选择和隐藏虚拟键盘的开关;2. 修改相关接口和默认值;3. 更新中英文语言包以支持新选项。
1 parent 68896bc commit b572855

File tree

4 files changed

+65
-11
lines changed

4 files changed

+65
-11
lines changed

src/components/EditorSettings.vue

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
<el-form-item :label="t('settings.horizontalLayout')">
1212
<el-switch v-model="localSettings.horizontalLayout" />
1313
</el-form-item>
14+
<el-form-item :label="t('settings.hideVariables')">
15+
<el-switch v-model="localSettings.hideVariables" />
16+
</el-form-item>
17+
<el-form-item :label="t('settings.hideKeyboard')">
18+
<el-switch v-model="localSettings.hideKeyboard" />
19+
</el-form-item>
1420
<el-form-item :label="t('settings.language')">
1521
<el-select v-model="localSettings.language" class="w-full">
1622
<el-option label="中文" value="zh" />
@@ -36,6 +42,8 @@ interface Settings {
3642
bracketColorEnabled: boolean;
3743
horizontalLayout: boolean;
3844
language: string;
45+
hideVariables: boolean; // 修改:showVariables -> hideVariables
46+
hideKeyboard: boolean; // 修改:showKeyboard -> hideKeyboard
3947
}
4048
4149
const props = withDefaults(defineProps<{
@@ -48,7 +56,9 @@ const props = withDefaults(defineProps<{
4856
autoCompleteBrackets: false,
4957
bracketColorEnabled: false,
5058
horizontalLayout: false,
51-
language: 'zh'
59+
language: 'zh',
60+
hideVariables: false, // 修改默认值
61+
hideKeyboard: false // 修改默认值
5262
})
5363
});
5464

src/components/ExpressionEditor.vue

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,11 @@
8989
</div>
9090
<div class="editor-content" :class="[
9191
{ 'circle-style': isCircleStyle },
92-
{ 'horizontal-layout': horizontalLayout }
92+
{ 'horizontal-layout': horizontalLayout },
93+
{ 'hide-variables': !showVariablesEnabled },
94+
{ 'hide-keyboard': !showKeyboardEnabled }
9395
]">
94-
<div class="variables-section">
96+
<div class="variables-section" v-if="showVariablesEnabled">
9597
<div class="variables-search">
9698
<el-input v-model="variableSearchText" placeholder="搜索变量" clearable :prefix-icon="Search" />
9799
</div>
@@ -104,8 +106,8 @@
104106
</el-scrollbar>
105107
</div>
106108
</div>
107-
<Calculator :can-undo="canUndo" :can-redo="canRedo" :is-circle-style="isCircleStyle" :t="t" @number="addNumber"
108-
@operator="addOperator" @delete="deleteLast" @undo="undo" @redo="redo" />
109+
<Calculator v-if="showKeyboardEnabled" :can-undo="canUndo" :can-redo="canRedo" :is-circle-style="isCircleStyle" :t="t"
110+
@number="addNumber" @operator="addOperator" @delete="deleteLast" @undo="undo" @redo="redo" />
109111
</div>
110112
<div v-if="previewMode" class="preview-panel">
111113
<div class="variables-input">
@@ -188,13 +190,17 @@ interface Props {
188190
showPreview?: boolean;
189191
showCopy?: boolean;
190192
showStyleToggle?: boolean;
193+
hideVariables?: boolean; // 修改:showVariables -> hideVariables
194+
hideKeyboard?: boolean; // 修改:showKeyboard -> hideKeyboard
191195
192196
// 初始设置
193197
initialSettings?: {
194198
autoCompleteBrackets?: boolean;
195199
bracketColorEnabled?: boolean;
196200
isDarkMode?: boolean;
197-
horizontalLayout?: boolean; // 添加horizontalLayout默认值
201+
horizontalLayout?: boolean;
202+
hideVariables?: boolean; // 修改:showVariables -> hideVariables
203+
hideKeyboard?: boolean; // 修改:showKeyboard -> hideKeyboard
198204
};
199205
200206
// 变量列表
@@ -232,11 +238,15 @@ const props = withDefaults(defineProps<Props>(), {
232238
showPreview: true,
233239
showCopy: true,
234240
showStyleToggle: true,
241+
hideVariables: false, // 修改默认值
242+
hideKeyboard: false, // 修改默认值
235243
initialSettings: () => ({
236244
autoCompleteBrackets: false,
237245
bracketColorEnabled: false,
238246
isDarkMode: false,
239-
horizontalLayout: false // 添加horizontalLayout默认值
247+
horizontalLayout: false,
248+
hideVariables: false, // 修改默认值
249+
hideKeyboard: false, // 修改默认值
240250
}),
241251
variables: () => [],
242252
modelValue: '',
@@ -302,6 +312,10 @@ const isCircleStyle = ref(false);
302312
const showExpression = ref(false);
303313
const horizontalLayout = ref(true); // 添加horizontalLayout变量
304314
315+
// 添加显示控制的计算属性
316+
const showVariablesEnabled = computed(() => !props.hideVariables && !props.initialSettings?.hideVariables);
317+
const showKeyboardEnabled = computed(() => !props.hideKeyboard && !props.initialSettings?.hideKeyboard);
318+
305319
// 计算属性
306320
const canUndo = computed(() => historyIndex.value > 0);
307321
const canRedo = computed(() => historyIndex.value < history.value.length - 1);
@@ -1410,18 +1424,20 @@ const handleSettingsSave = (settings: {
14101424
bracketColorEnabled: boolean;
14111425
horizontalLayout: boolean;
14121426
language: string;
1427+
hideVariables: boolean; // 修改
1428+
hideKeyboard: boolean; // 修改
14131429
}) => {
14141430
autoCompleteBrackets.value = settings.autoCompleteBrackets;
14151431
bracketColorEnabled.value = settings.bracketColorEnabled;
14161432
horizontalLayout.value = settings.horizontalLayout;
1417-
// 添加语言设置的保存,保持布局设置不变
14181433
if (settings.language !== props.language) {
14191434
emit('update:language', settings.language);
14201435
}
1421-
// 保存所有设置,包括当前的布局设置
14221436
localStorage.setItem('editor-settings', JSON.stringify({
14231437
...settings,
1424-
horizontalLayout: horizontalLayout.value
1438+
horizontalLayout: horizontalLayout.value,
1439+
hideVariables: settings.hideVariables,
1440+
hideKeyboard: settings.hideKeyboard
14251441
}));
14261442
settingsDialogVisible.value = false;
14271443
};
@@ -1439,7 +1455,9 @@ const loadSettings = () => {
14391455
autoCompleteBrackets: localSettings.autoCompleteBrackets ?? false,
14401456
bracketColorEnabled: localSettings.bracketColorEnabled ?? false,
14411457
isDarkMode: localSettings.isDarkMode ?? false,
1442-
horizontalLayout: localSettings.horizontalLayout ?? true
1458+
horizontalLayout: localSettings.horizontalLayout ?? true,
1459+
hideVariables: localSettings.hideVariables ?? false,
1460+
hideKeyboard: localSettings.hideKeyboard ?? false
14431461
};
14441462
14451463
autoCompleteBrackets.value = settings.autoCompleteBrackets;
@@ -1670,4 +1688,26 @@ onMounted(() => {
16701688

16711689
<style lang="scss">
16721690
@import '../styles/index.scss';
1691+
1692+
.editor-content {
1693+
display: flex;
1694+
gap: 16px;
1695+
transition: all 0.3s ease;
1696+
1697+
&.hide-variables {
1698+
.variables-section {
1699+
display: none;
1700+
}
1701+
}
1702+
1703+
&.hide-keyboard {
1704+
.calculator {
1705+
display: none;
1706+
}
1707+
}
1708+
1709+
&.horizontal-layout {
1710+
flex-direction: row;
1711+
}
1712+
}
16731713
</style>

src/locales/en.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ export default {
5353
autoCompleteBrackets: 'Auto Complete Brackets',
5454
bracketColorEnabled: 'Enable Bracket Colors',
5555
horizontalLayout: 'Horizontal Layout',
56+
hideVariables: 'Hide Variable Selection', // 修改:Show -> Hide
57+
hideKeyboard: 'Hide Virtual Keyboard', // 修改:Show -> Hide
5658
buttons: {
5759
cancel: 'Cancel',
5860
confirm: 'OK'

src/locales/zh.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ export default {
5353
autoCompleteBrackets: '自动补全括号',
5454
bracketColorEnabled: '括号颜色区分',
5555
horizontalLayout: '水平布局',
56+
hideVariables: '隐藏变量选择', // 修改:显示 -> 隐藏
57+
hideKeyboard: '隐藏虚拟键盘', // 修改:显示 -> 隐藏
5658
buttons: {
5759
cancel: '取消',
5860
confirm: '确定'

0 commit comments

Comments
 (0)