Skip to content
Open
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
10 changes: 6 additions & 4 deletions src/components/ChatDrawer/ChatDrawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@ async function onAddChat() {
}

async function hideChat() {
const confirm = await confirmModal.value.showModal(
i18n.global.t("modal.confirmHideChat"),
);
const confirm = store.state.general.isSkipDeleteChatConfirm ||
await confirmModal.value.showModal(
i18n.global.t("modal.confirmHideChat"),
);
Comment on lines +68 to +71

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

这段代码的缩进有些不一致,影响了可读性。建议统一缩进。另外,虽然使用 || 短路操作符和 await 的组合是有效的,但对于一些开发者来说可能不够直观。可以考虑使用 if 语句来更清晰地表达逻辑,例如:

let confirm = store.state.general.isSkipDeleteChatConfirm;
if (!confirm) {
  confirm = await confirmModal.value.showModal(
    i18n.global.t("modal.confirmHideChat"),
  );
}

这里提供一个仅修正格式的建议。

  const confirm = store.state.general.isSkipDeleteChatConfirm ||
    await confirmModal.value.showModal(
      i18n.global.t("modal.confirmHideChat"),
    );


if (confirm) {
await Chats.update(store.state.currentChatIndex, { hide: true });
selectLatestVisibleChat();
await selectLatestVisibleChat();
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/components/ChatDrawer/ChatDrawerItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
size="x-small"
icon="mdi-delete-outline"
@click="confirmHideChat"
@shortkey="confirmHideChat"
v-shortkey="SHORTCUT_DELETE_CHAT.key"
:id="SHORTCUT_DELETE_CHAT.elementId"
style="margin: 0; background-color: transparent"
></v-btn
> </template
Expand Down Expand Up @@ -58,6 +61,7 @@

<script setup>
import { ref } from "vue";
import { SHORTCUT_DELETE_CHAT } from "@/components/ShortcutGuide/shortcut.const";

const emit = defineEmits([
"hideChat",
Expand Down
5 changes: 5 additions & 0 deletions src/components/SettingsModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ const settings = [
name: "isShowMenuBar",
label: $t("settings.showMenuBar"),
},
{
type: Type.Checkbox,
name: "isSkipDeleteChatConfirm",
label: $t("settings.skipDeleteChatConfirm"),
},
];

watch(
Expand Down
10 changes: 10 additions & 0 deletions src/components/ShortcutGuide/shortcut.const.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ export const SHORTCUT_PROMPT_MANAGEMENT = {
flexDirection: "column",
};

export const SHORTCUT_DELETE_CHAT = {
elementId: "delete-chat-btn",
key: [modifier, "backspace"],
offset: {
top: 40,
},
flexDirection: "column",
};

export const SHORTCUT_APP_BAR = {
elementId: "app-bar",
key: [modifier, "f11"],
Expand All @@ -112,6 +121,7 @@ export const SHORTCUT_LIST = [
SHORTCUT_PROMPT_TEXTAREA,
SHORTCUT_CHAT_DRAWER,
SHORTCUT_NEW_CHAT,
SHORTCUT_DELETE_CHAT,
SHORTCUT_PROMPT_MANAGEMENT,
SHORTCUT_PROMPT_PRE_NEXT,
SHORTCUT_APP_BAR,
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"light": "Light",
"dark": "Dark",
"bots": "AI Bots",
"showMenuBar": "Show Menu Bar"
"showMenuBar": "Show Menu Bar",
"skipDeleteChatConfirm": "Delete chat without confirm"
},
"common": {
"apiKey": "API Key"
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"dark": "深色",
"bots": "AI 模型",
"api": "API",
"showMenuBar": "显示菜单栏"
"showMenuBar": "显示菜单栏",
"skipDeleteChatConfirm": "删除聊天时无需确认"
},
"common": {
"apiKey": "API 密钥"
Expand Down
1 change: 1 addition & 0 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export default createStore({
general: {
isShowMenuBar: true,
isShowAppBar: true,
isSkipDeleteChatConfirm: false,
},
},
mutations: {
Expand Down