From c30f96d3ac67d8df11fa246cd19b33a5d8275795 Mon Sep 17 00:00:00 2001 From: Ou Date: Tue, 14 May 2024 12:55:01 +0800 Subject: [PATCH] chore: preview ohmymn v4.4.0 --- packages/docs/guide/modules/ai.md | 7 ++- packages/docs/guide/modules/shortcut.md | 6 +-- packages/docs/update.md | 8 ++- packages/ohmymn/package.json | 2 +- packages/ohmymn/src/dataSource/index.ts | 17 ++++--- packages/ohmymn/src/self.d.ts | 2 +- .../settingViewController/handleUserAction.ts | 50 +++++++++---------- .../src/settingViewController/settingView.ts | 13 +++-- 8 files changed, 56 insertions(+), 49 deletions(-) diff --git a/packages/docs/guide/modules/ai.md b/packages/docs/guide/modules/ai.md index 4ceac94c..93db93af 100644 --- a/packages/docs/guide/modules/ai.md +++ b/packages/docs/guide/modules/ai.md @@ -29,12 +29,11 @@ api.openai.com ## OpenAI 模型 ::: tip 更新 -[v4.3.3](/update.md) 支持 `gpt-3.5-turbo-1106`,默认支持 16k 上下文,不需要单独选择 16k。 +[v4.4.0](/update.md) 只支持 gpt-3.5-turbo 和 gpt-4-turbo。 ::: -- `gpt-3.5-turbo`: 速度较快,Max Tokens 为 16k, -- `gpt-4`: 回答质量较高,速度较慢,Max Tokens 为 8k,目前还处于内测阶段,需要自行申请。 -- `gpt-4-32k`: Max Tokens 为 32k,目前还没有开放使用。 +- `gpt-3.5`: 即 gpt-3.5-turbo 速度较快。 +- `gpt-4`: 即 gpt-4-turbo 速度较慢,但更聪明。 ::: tip token OpenAI API 有输入+输出长度限制,也就是 Max Tokens,而且不光包括输入,还包括输出。比如 Max Tokens 为 4k,输入 2k,输出只能 2k。 diff --git a/packages/docs/guide/modules/shortcut.md b/packages/docs/guide/modules/shortcut.md index 06c628c1..ac7b5dab 100644 --- a/packages/docs/guide/modules/shortcut.md +++ b/packages/docs/guide/modules/shortcut.md @@ -8,7 +8,7 @@ import Shortcut from '/.vitepress/components/Shortcut.vue'; ::: ::: warning 注意 -该功能完全由 OhMyMN 提供,与 MarginNote 无关。 +该功能完全由 OhMyMN 提供,与 MarginNote 无关。如果你使用的是 MN4,注意把所有 URL Scheme 中的 `marginnote3app` 替换为 `marginnote4app` ::: 通过 URL Scheme 来触发 MagicAction 中的动作,在 Mac 上可以设置快捷键打开 URL。 @@ -18,10 +18,6 @@ import Shortcut from '/.vitepress/components/Shortcut.vue'; ## 自定义捷径 -::: tip 更新 -[v4.0.14](/update.md) 改进。捷径 Pro 更名为自定义捷径,并改进了语法。 -::: - 可以为每个动作以及任意输入值设置 URL,并将其设置成快捷键。甚至可以同时执行多个动作,通过选择的顺序来改变执行的顺序。 ::: warning 捷径生成器 diff --git a/packages/docs/update.md b/packages/docs/update.md index 71163c18..6addf4c9 100644 --- a/packages/docs/update.md +++ b/packages/docs/update.md @@ -9,7 +9,13 @@ outline: 2 https://bbs.marginnote.cn/t/topic/20501#heading-6 ::: -## v4.3.2 (2023-11-26) + +## v4.4.0 (2024-05-13) +- 修复在开关模块时,控制面板没有及时刷新的问题。 +- 修复手动调整控制面板位置和长度偶尔出现异常的问题。 +- 简单适配 MN4,主要是 URL Scheme 的变化。其他不常用的我也不知道有没有问题。 + +## v4.3.3 (2023-11-26) - `AutoComplete`: 数据库支持单独导入,不需要下载特定版本,并支持导入以前在线 API 使用的数据库。 - `AI`: 支持最新的 `gpt-3.5-turbo-1106` 模型,价格更低,同时默认支持 16k 的上下文。 diff --git a/packages/ohmymn/package.json b/packages/ohmymn/package.json index 9e44b89a..09595e43 100644 --- a/packages/ohmymn/package.json +++ b/packages/ohmymn/package.json @@ -2,7 +2,7 @@ "name": "ohmymn", "private": true, "author": "ourongxing", - "version": "4.3.3", + "version": "4.4.0", "license": "MIT", "description": "MarginNote toolbox that can process excerpts automatically", "scripts": { diff --git a/packages/ohmymn/src/dataSource/index.ts b/packages/ohmymn/src/dataSource/index.ts index 4dd5527e..53791f84 100644 --- a/packages/ohmymn/src/dataSource/index.ts +++ b/packages/ohmymn/src/dataSource/index.ts @@ -14,12 +14,6 @@ function genSection(config: IConfig): ISection { } ] - if (config.key !== "addon") - rows.push({ - type: CellViewType.PlainText, - label: lang.expand - }) - for (const setting of config.settings) { //@ts-ignore magic hack rows.push(setting) @@ -42,6 +36,17 @@ function genSection(config: IConfig): ISection { } } } + if (config.key === "addon") { + rows.splice(4, 0, { + type: CellViewType.PlainText, + label: lang.expand + }) + } else { + rows.splice(1, 0, { + type: CellViewType.PlainText, + label: lang.expand + }) + } return { header: config.name, key: config.key as AllModuleKeyUnion, diff --git a/packages/ohmymn/src/self.d.ts b/packages/ohmymn/src/self.d.ts index d328a77a..1439ddbe 100644 --- a/packages/ohmymn/src/self.d.ts +++ b/packages/ohmymn/src/self.d.ts @@ -99,7 +99,7 @@ declare global { */ settingViewCache: { offModules: MyMap - expandSections: Set> + expandSections: Set } /** * Only mainView diff --git a/packages/ohmymn/src/settingViewController/handleUserAction.ts b/packages/ohmymn/src/settingViewController/handleUserAction.ts index 89743624..462de670 100644 --- a/packages/ohmymn/src/settingViewController/handleUserAction.ts +++ b/packages/ohmymn/src/settingViewController/handleUserAction.ts @@ -7,7 +7,7 @@ import { } from "marginnote" import { Addon } from "~/addon" import { actionKey4Card, actionKey4Text } from "~/dataSource" -import { checkInputCorrect, type OptionalModuleKeyUnion } from "~/coreModule" +import { AllModuleKeyUnion, checkInputCorrect } from "~/coreModule" import { CellViewType, type IRowSelect, @@ -39,36 +39,32 @@ async function tableViewDidSelectRowAtIndexPath( switch (row.type) { case CellViewType.PlainText: { - if (indexPath.row !== 1 || sec.key === "more" || sec.key === "addon") { - if (row.link) { - if (self.globalProfile.addon.doubleLink) { - if ( - Date.now() - doubleClickTemp.lastTime < 500 && - indexPath === doubleClickTemp.location - ) { - openURL(row.link, true) - doubleClickTemp.lastTime = 0 - doubleClickTemp.location = undefined - } else { - doubleClickTemp.lastTime = Date.now() - doubleClickTemp.location = indexPath - } - } else { - openURL(row.link, true) - } - } - } else if (self.settingViewCache.expandSections.has(sec.key)) { + if (row.label === lang.expand) { + row.label = lang.collapse + self.settingViewCache.expandSections.add(sec.key as AllModuleKeyUnion) + self.tableView.reloadData() + } else if (row.label === lang.collapse) { row.label = lang.expand self.settingViewCache.expandSections.delete( - sec.key as OptionalModuleKeyUnion - ) - self.tableView.reloadData() - } else { - row.label = lang.collapse - self.settingViewCache.expandSections.add( - sec.key as OptionalModuleKeyUnion + sec.key as AllModuleKeyUnion ) self.tableView.reloadData() + } else if (row.link) { + if (self.globalProfile.addon.doubleLink) { + if ( + Date.now() - doubleClickTemp.lastTime < 500 && + indexPath === doubleClickTemp.location + ) { + openURL(row.link, true) + doubleClickTemp.lastTime = 0 + doubleClickTemp.location = undefined + } else { + doubleClickTemp.lastTime = Date.now() + doubleClickTemp.location = indexPath + } + } else { + openURL(row.link, true) + } } } break diff --git a/packages/ohmymn/src/settingViewController/settingView.ts b/packages/ohmymn/src/settingViewController/settingView.ts index 6b4d5003..7ec5794e 100644 --- a/packages/ohmymn/src/settingViewController/settingView.ts +++ b/packages/ohmymn/src/settingViewController/settingView.ts @@ -65,10 +65,10 @@ function tableViewNumberOfRowsInSection( section: number ) { const { key } = self.dataSource[section] - if (key === "addon" || key === "more") - return self.dataSource[section].rows.length + if (key === "more") return self.dataSource[section].rows.length else if (_isModuleOFF(key)) return 0 - else if (!self.settingViewCache.expandSections.has(key)) return 2 + else if (!self.settingViewCache.expandSections.has(key)) + return key === "addon" ? 5 : 2 else return self.dataSource[section].rows.length } @@ -214,7 +214,12 @@ function tableViewCellForRowAtIndexPath( cell.textLabel.textColor = UIColor.grayColor() cell.textLabel.font = UIFont.systemFontOfSize(fontSize.plain) if (row.link) cell.textLabel.text = `⎋ ${row.label}` - else if (key === "more" || indexPath.row === 0 || indexPath.row === 1) + else if ( + key === "more" || + indexPath.row === 0 || + indexPath.row === 1 || + (key === "addon" && indexPath.row === 4) + ) cell.textLabel.text = row.label else cell.textLabel.text = `↑ ${row.label}` return cell