Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

是否能在手机端登录时默认进入桌面版? #90

Closed
X-Bruce-Y opened this issue Mar 6, 2024 · 8 comments
Closed

是否能在手机端登录时默认进入桌面版? #90

X-Bruce-Y opened this issue Mar 6, 2024 · 8 comments

Comments

@X-Bruce-Y
Copy link

佬,在用Mobile View这个插件方便手机操作,但是发现手机登录时会默认使用“移动版”(PC登录服务器会默认为“桌面版”,PC软件则没有“移动版/桌面版”选项),然后每次就需要先“切换到桌面版”再用插件“Toggle Mobile View”,很麻烦。插件也许可以通过设置#run=mobileStartup控制,但是怎么样实现手机登录默认为“桌面版”呢?

感谢!

@Nriver
Copy link
Owner

Nriver commented Mar 6, 2024

这个是根据浏览器的User Agent来判断是桌面还是手机,然后写入cookie。
只要cookie里面 trilium-device=mobile 就是移动版界面, trilium-device=desktop就是桌面版界面。

@Nriver
Copy link
Owner

Nriver commented Mar 6, 2024

写了一个简单的js, 移动端打开页面时设置cookie, 这样一直都是桌面版界面

always desktop mode.zip

@X-Bruce-Y
Copy link
Author

大佬666。
我试了一下,手机端登录之后似乎需要刷新一次这个脚本才会生效(已设置#run=mobileStartup,用的edge浏览器已清除旧cookie),这个是浏览器或者我的server的问题吗?
还有一个小白问题,就是我希望能够在手机端登录、用你的脚本自动切换到桌面端后,自动Toggle Mobile View,从而节省一次点击也少占一个launcher,但是这个脚本SetHTMLMetaSetNoteView我设置了#run=mobileStartup后好像也没有生效(刷新网页后没有生效),是我哪里弄错了吗?

@Nriver
Copy link
Owner

Nriver commented Mar 6, 2024

把那些js代码复制到我那个js下面试试

@X-Bruce-Y
Copy link
Author

X-Bruce-Y commented Mar 6, 2024

我把来自Toggle Mobile Vew的相关代码复制到了你的always desktop mod下方:

var viewport = document.createElement('meta');
viewport.name = 'viewport';
viewport.content = 'width=device-width, initial-scale=1.0'
document.head.appendChild(viewport);

$('body').toggleClass("mobile-view");
$('body').attr("current-view", "sidebar");

并且把相关原js笔记都设置为了#disabled:run,但好像没有效果。还有需要刷新才能进入桌面版的问题,要是没有直接的解决方案就先搁置算了,以后我慢慢钻研

@X-Bruce-Y
Copy link
Author

Mobile View问题解决了!原来是应该用#run=frontendStartup而非mobileStartup,因为你的操作生效之后实际上就是桌面版了。然后我在想不管出于什么原因导致我需要刷新一次你的脚本才能生效,有没有api可以直接实现reloadFrontendApp的好加在你的代码最后,相当于直接自动刷新一次?

@Nriver
Copy link
Owner

Nriver commented Mar 7, 2024

直接刷新整个页面?

location.reload();

@X-Bruce-Y
Copy link
Author

直接刷新整个页面?

location.reload();

有效!谢谢佬

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants