diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f175b1..6cd38f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ ## Changelog +## v1.2.3 + +- ⚡ perf: 适配优化移动端 [#13](https://github.com/frostime/sy-bookmark-plus/issues/13) + - 允许移动端点击跳转 + - 去掉异常显示的 empty element + - 优化 setting 对话框显示 + ## v1.2.2 - ✨ feat: 优化反查询功能,允许添加后处理 diff --git a/README.md b/README.md index 837f847..15c2a14 100644 --- a/README.md +++ b/README.md @@ -184,3 +184,10 @@ However, if the user enables the "First child of container" post-processing sche * For dynamic groups, it re-executes the query and displays the most recent query results. * For static groups, it checks the current status of each item (block) and updates them based on the latest results. + + +### Can plugins be used on mobile devices? + +![](asset/mobile.png) + +However, since plugin development is done on the desktop, some operations on mobile devices may be less convenient. diff --git a/README_zh_CN.md b/README_zh_CN.md index 0338f11..fbee178 100644 --- a/README_zh_CN.md +++ b/README_zh_CN.md @@ -188,3 +188,9 @@ * 对于动态组,会重新执行查询,并显示最新的查询结果 * 对于静态组,会查询当中每个项目(块)的最新情况,并根据最新结果更新项目 + +### 移动端能使用插件吗? + +![](asset/mobile.png) + +不过由于插件开发在桌面端上,所以移动端中有些操作可能会有些不方便。 diff --git a/asset/mobile.png b/asset/mobile.png new file mode 100644 index 0000000..8146cbd Binary files /dev/null and b/asset/mobile.png differ diff --git a/package.json b/package.json index cbb622d..31ad87d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sy-bookmark-plus", - "version": "1.2.2", + "version": "1.2.3", "type": "module", "description": "A more powerful bookmark", "repository": "", diff --git a/plugin.json b/plugin.json index 08441a5..6034ee2 100644 --- a/plugin.json +++ b/plugin.json @@ -2,7 +2,7 @@ "name": "sy-bookmark-plus", "author": "frostime", "url": "https://github.com/frostime/sy-bookmark-plus", - "version": "1.2.2", + "version": "1.2.3", "minAppVersion": "3.0.12", "backends": [ "all" diff --git a/src/components/item.tsx b/src/components/item.tsx index 06b3e87..696b95a 100644 --- a/src/components/item.tsx +++ b/src/components/item.tsx @@ -1,6 +1,6 @@ import { Component, createEffect, createMemo, createSignal, useContext } from "solid-js"; import { render } from "solid-js/web"; -import { Menu, openTab, showMessage } from "siyuan"; +import { Menu, openTab, showMessage, openMobileFileById } from "siyuan"; import { buildItemDetail } from "../libs/dom"; import { itemInfo, setGroups, groupMap, configs } from "../model"; @@ -10,7 +10,7 @@ import { BookmarkContext, itemMoving, setItemMoving } from "./context"; import { i18n, renderI18n } from "@/utils/i18n"; import { simpleDialog } from "@/libs/dialog"; import Typography from "@/libs/components/typography"; -import { getNotebook } from "@/utils"; +import { getNotebook, isMobile } from "@/utils"; interface IProps { group: TBookmarkGroupId; @@ -263,13 +263,17 @@ const Item: Component = (props) => { }; const openBlock = () => { - openTab({ - app: plugin.app, - doc: { - id: item().id, - zoomIn: item().type === 'd' ? false : true, - }, - }); + if (isMobile()) { + openMobileFileById(plugin.app, item().id); + } else { + openTab({ + app: plugin.app, + doc: { + id: item().id, + zoomIn: item().type === 'd' ? false : true, + }, + }); + } }; const onDragStart = (event: DragEvent) => { diff --git a/src/components/setting/index.tsx b/src/components/setting/index.tsx index dbb37d6..0b77a99 100644 --- a/src/components/setting/index.tsx +++ b/src/components/setting/index.tsx @@ -10,7 +10,7 @@ const App = () => { return (
{ await model.updateAll(); ele.classList.add('fn__flex-column'); + + if (isMobile()) { + //Refer to https://github.com/frostime/sy-bookmark-plus/issues/13#issuecomment-2283031563 + let empty = ele.querySelector('.b3-list--empty') as HTMLElement; + if (empty) empty.style.display = 'none'; + } render(() => Bookmark({ plugin: plugin, model: model @@ -48,6 +55,7 @@ const destroyBookmark = () => { const bookmarkKeymap = window.siyuan.config.keymap.general.bookmark; + export default class PluginBookmarkPlus extends Plugin { declare data: { @@ -121,14 +129,23 @@ export default class PluginBookmarkPlus extends Plugin { let container = document.createElement("div") as HTMLDivElement; container.classList.add("fn__flex-1", "fn__flex"); render(() => Setting(), container); + let size = { + width: '700px', + height: '700px' + } + if (isMobile()) { + size = { + width: '100%', + height: '90%' + } + } simpleDialog({ title: window.siyuan.languages.config, ele: container, - width: '700px', - height: '700px', callback: () => { model.save(); - } + }, + ...size }) } diff --git a/src/utils/index.ts b/src/utils/index.ts index 54bcb4c..40005c4 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -6,9 +6,15 @@ * @LastEditTime : 2024-07-20 18:17:00 * @Description : */ +import { getFrontend } from 'siyuan'; import * as api from '../api'; +export const isMobile = () => { + return getFrontend().endsWith('mobile'); +} + + export function debounce void>(func: T, wait: number): T { let timeout: NodeJS.Timeout; return function(...args: Parameters) {