Merge remote-tracking branch 'origin/master' into dev

This commit is contained in:
jeasonnow
2023-06-25 10:23:51 +08:00
54 changed files with 2346 additions and 5630 deletions

527
src-tauri/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -12,12 +12,12 @@ rust-version = "1.63.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[build-dependencies]
tauri-build = { version = "1.3.0", features = [] }
tauri-build = { version = "1.4.0", features = [] }
[dependencies]
serde_json = "1.0.96"
serde = { version = "1.0.163", features = ["derive"] }
tauri = { version = "1.3.0", features = ["api-all", "system-tray"] }
tauri = { version = "1.4.1", features = ["api-all", "system-tray"] }
download_rs = { version = "0.2.0", features = ["sync_download"] }
tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "dev" }

9
src-tauri/info.plist Normal file
View File

@@ -0,0 +1,9 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSCameraUsageDescription</key>
<string>Request camera access</string>
<key>NSMicrophoneUsageDescription</key>
<string>Request microphone access</string>
</dict>
</plist>

View File

@@ -136,8 +136,7 @@ document.addEventListener('DOMContentLoaded', () => {
document.body.appendChild(m);
setTimeout(function () {
const d = 0.5;
m.style.transition =
'transform ' + d + 's ease-in, opacity ' + d + 's ease-in';
m.style.transition = 'transform ' + d + 's ease-in, opacity ' + d + 's ease-in';
m.style.opacity = '0';
setTimeout(function () {
document.body.removeChild(m);
@@ -146,4 +145,36 @@ document.addEventListener('DOMContentLoaded', () => {
}
window.pakeToast = pakeToast;
// chatgpt supports unlimited times of GPT4-Mobile
if (window.location.hostname === 'chat.openai.com') {
const originFetch = fetch;
window.fetch = (url, options) => {
return originFetch(url, options).then(async response => {
if (url.indexOf('/backend-api/models') === -1) {
return response;
}
const responseClone = response.clone();
let res = await responseClone.json();
res.models = res.models.map(m => {
m.tags = m.tags.filter(t => {
return t !== 'mobile';
});
if (m.slug === 'gpt-4-mobile') {
res.categories.push({
browsing_model: null,
category: 'gpt_4',
code_interpreter_model: null,
default_model: 'gpt-4-mobile',
human_category_name: 'GPT-4-Mobile',
plugins_model: null,
subscription_level: 'plus',
});
}
return m;
});
return new Response(JSON.stringify(res), response);
});
};
}
});

View File

@@ -82,14 +82,14 @@ async function invoke(cmd, args) {
// Judgment of file download.
function isDownloadLink(url) {
const fileExtensions = [
'3gp', '7z', 'ai', 'apk', 'avi', 'bmp', 'csv', 'dmg', 'doc', 'docx', 'fla', 'flv', 'gif', 'gz', 'gzip',
'ico', 'iso', 'indd', 'jar', 'jpeg', 'jpg', 'm3u8', 'mov', 'mp3', 'mp4', 'mpa', 'mpg',
'mpeg', 'msi', 'odt', 'ogg', 'ogv', 'pdf', 'png', 'ppt', 'pptx', 'psd', 'rar', 'raw', 'rss', 'svg',
'swf', 'tar', 'tif', 'tiff', 'ts', 'txt', 'wav', 'webm', 'webp', 'wma', 'wmv', 'xls', 'xlsx', 'xml', 'zip'
];
const downloadLinkPattern = new RegExp(`\\.(${fileExtensions.join('|')})$`, 'i');
return downloadLinkPattern.test(url);
const fileExtensions = [
'3gp', '7z', 'ai', 'apk', 'avi', 'bmp', 'csv', 'dmg', 'doc', 'docx', 'fla', 'flv', 'gif', 'gz', 'gzip',
'ico', 'iso', 'indd', 'jar', 'jpeg', 'jpg', 'm3u8', 'mov', 'mp3', 'mp4', 'mpa', 'mpg',
'mpeg', 'msi', 'odt', 'ogg', 'ogv', 'pdf', 'png', 'ppt', 'pptx', 'psd', 'rar', 'raw', 'rss', 'svg',
'swf', 'tar', 'tif', 'tiff', 'ts', 'txt', 'wav', 'webm', 'webp', 'wma', 'wmv', 'xls', 'xlsx', 'xml', 'zip',
];
const downloadLinkPattern = new RegExp(`\\.(${fileExtensions.join('|')})$`, 'i');
return downloadLinkPattern.test(url);
}
// No need to go to the download link.
@@ -114,17 +114,17 @@ document.addEventListener('DOMContentLoaded', () => {
domEl.addEventListener('mousedown', (e) => {
e.preventDefault();
if (e.buttons === 1 && e.detail !== 2) {
appWindow.startDragging();
appWindow.startDragging().then();
}
});
domEl.addEventListener('touchstart', () => {
appWindow.startDragging();
appWindow.startDragging().then();
});
domEl.addEventListener('dblclick', () => {
appWindow.isFullscreen().then((fullscreen) => {
appWindow.setFullscreen(!fullscreen);
appWindow.setFullscreen(!fullscreen).then();
});
});
@@ -156,6 +156,7 @@ document.addEventListener('DOMContentLoaded', () => {
}
let filename = anchorElement.download || getFilenameFromUrl(absoluteUrl);
// Process download links for Rust to handle.
// If the download attribute is set, the download attribute is used as the file name.
if (
@@ -184,7 +185,7 @@ document.addEventListener('DOMContentLoaded', () => {
// Rewrite the window.open function.
const originalWindowOpen = window.open;
window.open = function (url, name, specs) {
window.open = function(url, name, specs) {
// Apple login and google login
if (name === 'AppleAuthentication') {
//do nothing
@@ -261,31 +262,34 @@ function convertBlobUrlToBinary(blobUrl) {
});
}
function downloadFromBlobUrl(blobUrl, filename) {
const tauri = window.__TAURI__;
convertBlobUrlToBinary(blobUrl).then((binary) => {
console.log('binary', binary);
tauri.fs.writeBinaryFile(filename, binary, {
dir: tauri.fs.BaseDirectory.Download,
}).then(() => {
window.pakeToast('Download successful, saved to download directory~');
});
});
}
// detect blob download by createElement("a")
function detectDownloadByCreateAnchor() {
const createEle = document.createElement;
const tauri = window.__TAURI__;
document.createElement = (el) => {
if (el !== "a") return createEle.call(document, el);
if (el !== 'a') return createEle.call(document, el);
const anchorEle = createEle.call(document, el);
const anchorClick = anchorEle.click;
Object.defineProperties(anchorEle, {
click: {
get: () => {
if (anchorEle.href && anchorEle.href.includes('blob:')) {
const url = anchorEle.href;
convertBlobUrlToBinary(url).then((binary) => {
tauri.fs.writeBinaryFile(anchorEle.download || getFilenameFromUrl(url), binary, {
dir: tauri.fs.BaseDirectory.Download,
});
});
}
return anchorClick.bind(anchorEle);
}
// use addEventListener to avoid overriding the original click event.
anchorEle.addEventListener('click', () => {
const url = anchorEle.href;
if (window.blobToUrlCaches.has(url)) {
downloadFromBlobUrl(url, anchorEle.download || getFilenameFromUrl(url));
}
})
});
return anchorEle;
}
};
}

View File

@@ -1,4 +1,4 @@
window.addEventListener('DOMContentLoaded', (_event) => {
window.addEventListener('DOMContentLoaded', _event => {
const css = `
#page #footer-wrapper,
.drawing-board .toolbar .toolbar-action,
@@ -56,6 +56,10 @@ window.addEventListener('DOMContentLoaded', (_event) => {
padding-top: 20px;
}
#__next > div.overflow-hidden.w-full.h-full .min-h-\\[20px\\].items-start.gap-4.whitespace-pre-wrap.break-words {
word-break: break-all;
}
#__next .PageWithSidebarLayout_mainSection__i1yOg {
width: 100%;
max-width: 1000px;
@@ -312,7 +316,8 @@ window.addEventListener('DOMContentLoaded', (_event) => {
}
@media (min-width:1024px){
#__next .text-base.lg\\:max-w-xl, #__next form.stretch.lg\\:max-w-2xl {
#__next .text-base.lg\\:max-w-xl, #__next form.stretch.lg\\:max-w-2xl,
#__next > .w-full.h-full .lg\\:max-w-\\[38rem\\] {
max-width: 44rem;
}
}
@@ -327,6 +332,20 @@ window.addEventListener('DOMContentLoaded', (_event) => {
#__next .overflow-hidden.w-full .max-w-full>.sticky.top-0 {
padding-top: 20px;
}
#__next .overflow-hidden.w-full main.relative.h-full.w-full.flex-1{
padding-bottom: 82px;
}
#__next > div.overflow-hidden.w-full.h-full main.relative.h-full.w-full.flex-1 > .flex-1.overflow-hidden .h-32.md\\:h-48.flex-shrink-0{
height: 0px;
}
}
@media (max-width:565px){
#__next .overflow-hidden.w-full main.relative.h-full.w-full.flex-1{
padding-bottom: 98px;
}
}
#__next .prose ol li p {

View File

@@ -1,34 +1,34 @@
{
"package": {
"productName": "WeRead",
"version": "1.0.0"
"package": {
"productName": "WeRead",
"version": "1.0.0"
},
"tauri": {
"security": {
"csp": null
},
"tauri": {
"security": {
"csp": null
},
"updater": {
"active": false
},
"systemTray": {
"iconPath": "png/weread_512.png",
"iconAsTemplate": true
},
"allowlist": {
"all": true,
"fs": {
"all": true,
"scope": [
"$DOWNLOAD/*"
]
}
}
"updater": {
"active": false
},
"build": {
"withGlobalTauri": true,
"devPath": "../dist",
"distDir": "../dist",
"beforeBuildCommand": "",
"beforeDevCommand": ""
"systemTray": {
"iconPath": "png/weread_512.png",
"iconAsTemplate": true
},
"allowlist": {
"all": true,
"fs": {
"all": true,
"scope": [
"$DOWNLOAD/*"
]
}
}
}
},
"build": {
"withGlobalTauri": true,
"devPath": "../dist",
"distDir": "../dist",
"beforeBuildCommand": "",
"beforeDevCommand": ""
}
}

View File

@@ -8,7 +8,9 @@
"copyright": "",
"deb": {
"depends": ["curl", "wget"],
"files": {"/usr/share/applications/com-tw93-weread.desktop": "assets/com-tw93-weread.desktop"}
"files": {
"/usr/share/applications/com-tw93-weread.desktop": "assets/com-tw93-weread.desktop"
}
},
"externalBin": [],
"longDescription": "",