Skip to content

Commit

Permalink
chore: preview ohmymn v4.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ourongxing committed May 14, 2024
1 parent e87ffe3 commit c30f96d
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 49 deletions.
7 changes: 3 additions & 4 deletions packages/docs/guide/modules/ai.md
Original file line number Diff line number Diff line change
Expand Up @@ -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。
Expand Down
6 changes: 1 addition & 5 deletions packages/docs/guide/modules/shortcut.md
Original file line number Diff line number Diff line change
Expand Up @@ -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。
Expand All @@ -18,10 +18,6 @@ import Shortcut from '/.vitepress/components/Shortcut.vue';

## 自定义捷径

::: tip 更新
[v4.0.14](/update.md) 改进。捷径 Pro 更名为自定义捷径,并改进了语法。
:::

可以为每个动作以及任意输入值设置 URL,并将其设置成快捷键。甚至可以同时执行多个动作,通过选择的顺序来改变执行的顺序。

::: warning 捷径生成器
Expand Down
8 changes: 7 additions & 1 deletion packages/docs/update.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 的上下文。
Expand Down
2 changes: 1 addition & 1 deletion packages/ohmymn/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
17 changes: 11 additions & 6 deletions packages/ohmymn/src/dataSource/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ function genSection(config: IConfig<AllModuleKeyUnion>): 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)
Expand All @@ -42,6 +36,17 @@ function genSection(config: IConfig<AllModuleKeyUnion>): 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,
Expand Down
2 changes: 1 addition & 1 deletion packages/ohmymn/src/self.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ declare global {
*/
settingViewCache: {
offModules: MyMap<DataSourceSectionKeyUnion, boolean | undefined>
expandSections: Set<Exclude<AllModuleKeyUnion, "addon">>
expandSections: Set<AllModuleKeyUnion>
}
/**
* Only mainView
Expand Down
50 changes: 23 additions & 27 deletions packages/ohmymn/src/settingViewController/handleUserAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
13 changes: 9 additions & 4 deletions packages/ohmymn/src/settingViewController/settingView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c30f96d

Please sign in to comment.