🎨 增加对v2ex支持

This commit is contained in:
Tw93
2022-11-06 12:52:08 +08:00
parent 1e0a7a7d74
commit fc58f2bc8a
4 changed files with 82 additions and 63 deletions

View File

@@ -2,7 +2,7 @@
<p align="center"> <p align="center">
<img src=https://gw.alipayobjects.com/zos/k/fa/logo-modified.png width=138/> <img src=https://gw.alipayobjects.com/zos/k/fa/logo-modified.png width=138/>
<h1 align="center">Pake</h1> <h1 align="center">Pake</h1>
<div align="left">很简单的用 Rust 打包网页生成很小的 Mac App底层使用 Tauri支持微信读书、Twitter、语雀、RunCode、Witeboard、Flomo、Vercel 等,详细小白开发教程可见底部。</div> <div align="left">很简单的用 Rust 打包网页生成很小的 Mac App底层使用 Tauri支持微信读书、Twitter、语雀、RunCode、Witeboard、Flomo、Vercel、V2EX 等,详细小白开发教程可见底部。</div>
</p> </p>
## 特征 ## 特征

View File

@@ -2,7 +2,7 @@
<p align="center"> <p align="center">
<img src=https://gw.alipayobjects.com/zos/k/fa/logo-modified.png width=138/> <img src=https://gw.alipayobjects.com/zos/k/fa/logo-modified.png width=138/>
<h1 align="center">Pake</h1> <h1 align="center">Pake</h1>
<div align="left">A simple way to package a web page with Rust to create Mac App, using Tauri as underlying layer, supporting WeRead、Twitter、YuQue、RunCode、Flomo、Witeboard、Vercel, detailed development tutorial can be seen at the bottom.</div> <div align="left">A simple way to package a web page with Rust to create Mac App, using Tauri as underlying layer, supporting WeRead、Twitter、YuQue、RunCode、Flomo、Witeboard、Vercel、V2EX, detailed development tutorial can be seen at the bottom.</div>
</p> </p>
## Features ## Features

BIN
src-tauri/icons/v2ex.icns Normal file

Binary file not shown.

View File

@@ -1,7 +1,8 @@
window.addEventListener('DOMContentLoaded', (_event) => { window.addEventListener('DOMContentLoaded', (_event) => {
const style = document.createElement('style'); const style = document.createElement('style');
style.innerHTML = ` style.innerHTML = `
// mini twitter 代码存到 dist 下面,为了防止干扰,需要的时候 copy 过来即可 // mini twitter 代码存到 dist 下面,为了防止干扰,需要的时候 copy 过来即可
.panel.give_me .nav_view { .panel.give_me .nav_view {
top: 154px !important; top: 154px !important;
} }
@@ -18,10 +19,26 @@ window.addEventListener('DOMContentLoaded', (_event) => {
.drawing-board .toolbar .toolbar-action, .drawing-board .toolbar .toolbar-action,
.c-swiper-container, .c-swiper-container,
.download_entry, .download_entry,
.lang, .copyright { .lang, .copyright,
.wwads-cn, .adsbygoogle,
#Bottom > div.content > div.inner,
#Rightbar .sep20:nth-of-type(5),
#Rightbar > div.box:nth-child(4),
#Main > div.box:nth-child(8) > div
#Wrapper > div.sep20,
#Main > div.box:nth-child(8) {
display: none !important; display: none !important;
} }
#Wrapper{
background-color: #F8F8F8 !important;
background-image:none !important;
}
#Top {
border-bottom: none;
}
.container-with-note #home, .container-with-note #switcher{ .container-with-note #home, .container-with-note #switcher{
top: 30px; top: 30px;
} }
@@ -49,62 +66,61 @@ window.addEventListener('DOMContentLoaded', (_event) => {
cursor: -webkit-grab; cursor: -webkit-grab;
} }
`; `;
document.head.append(style); document.head.append(style);
const topDom = document.createElement("div"); const topDom = document.createElement('div');
topDom.id = "pack-top-dom" topDom.id = 'pack-top-dom';
document.body.appendChild(topDom); document.body.appendChild(topDom);
const domEl = document.getElementById('pack-top-dom'); const domEl = document.getElementById('pack-top-dom');
domEl.addEventListener('mousedown', (e) => { domEl.addEventListener('mousedown', (e) => {
if (e.buttons === 1 && e.detail !== 2) { if (e.buttons === 1 && e.detail !== 2) {
window.ipc.postMessage('drag_window'); window.ipc.postMessage('drag_window');
} }
}) });
domEl.addEventListener('touchstart', (e) => { domEl.addEventListener('touchstart', (e) => {
window.ipc.postMessage('drag_window'); window.ipc.postMessage('drag_window');
}) });
domEl.addEventListener('dblclick', (e) => { domEl.addEventListener('dblclick', (e) => {
window.ipc.postMessage('fullscreen'); window.ipc.postMessage('fullscreen');
}) });
document.addEventListener('keyup', function (event) { document.addEventListener('keyup', function (event) {
if (event.key === "ArrowUp" && event.metaKey){ if (event.key === 'ArrowUp' && event.metaKey) {
scrollTo(0,0); scrollTo(0, 0);
} }
if (event.key === "ArrowDown" && event.metaKey){ if (event.key === 'ArrowDown' && event.metaKey) {
window.scrollTo(0, document.body.scrollHeight); window.scrollTo(0, document.body.scrollHeight);
} }
if (event.key === "[" && event.metaKey){ if (event.key === '[' && event.metaKey) {
window.history.go(-1); window.history.go(-1);
} }
if (event.key === "]" && event.metaKey){ if (event.key === ']' && event.metaKey) {
window.history.go(1); window.history.go(1);
} }
if (event.key === "r" && event.metaKey){ if (event.key === 'r' && event.metaKey) {
window.location.reload(); window.location.reload();
} }
if (event.key === "-" && event.metaKey){ if (event.key === '-' && event.metaKey) {
zoomOut(); zoomOut();
} }
if (event.key === "=" && event.metaKey){ if (event.key === '=' && event.metaKey) {
zoomIn(); zoomIn();
} }
if (event.key === "0" && event.metaKey){ if (event.key === '0' && event.metaKey) {
zoomCommon(() => '100%'); zoomCommon(() => '100%');
} }
}) });
document.addEventListener('click', e => {
const origin = e.target.closest('a');
const href = origin.href;
if (href) {
origin.target = "_self"
}
});
document.addEventListener('click', (e) => {
const origin = e.target.closest('a');
const href = origin.href;
if (href) {
origin.target = '_self';
}
});
}); });
setDefaultZoom(); setDefaultZoom();
@@ -117,18 +133,21 @@ function setDefaultZoom() {
} }
function zoomCommon(callback) { function zoomCommon(callback) {
const htmlZoom = window.localStorage.getItem('htmlZoom') || '100%'; const htmlZoom = window.localStorage.getItem('htmlZoom') || '100%';
const html = document.getElementsByTagName('html')[0]; const html = document.getElementsByTagName('html')[0];
const zoom = callback(htmlZoom); const zoom = callback(htmlZoom);
html.style.zoom = zoom; html.style.zoom = zoom;
window.localStorage.setItem('htmlZoom', zoom); window.localStorage.setItem('htmlZoom', zoom);
} }
function zoomIn() { function zoomIn() {
zoomCommon(htmlZoom => parseInt(htmlZoom) < 200 ? (parseInt(htmlZoom) + 10 +'%') : '200%'); zoomCommon((htmlZoom) =>
parseInt(htmlZoom) < 200 ? parseInt(htmlZoom) + 10 + '%' : '200%',
);
} }
function zoomOut() { function zoomOut() {
zoomCommon(htmlZoom => parseInt(htmlZoom) > 30 ? (parseInt(htmlZoom) - 10 +'%') : '30%'); zoomCommon((htmlZoom) =>
parseInt(htmlZoom) > 30 ? parseInt(htmlZoom) - 10 + '%' : '30%',
);
} }