Skip to content
This repository was archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
Feat Tauri [Desktop App] [AlwaysOnTop] (#104)
Browse files Browse the repository at this point in the history
* Update Package [Tauri]

[+] chore(package.json): add "@tauri-apps/api" dependency
[+] chore(Cargo.toml): update "tauri" dependency features
[+] chore(yarn.lock): update "@tauri-apps/cli" and "@tauri-apps/api" versions

* Feat Tauri [Desktop App] [Locales]

[+] feat(locales): add support for pinning and unpinning desktop app in multiple languages

* Feat Tauri [Desktop App] [AlwaysOnTop]

[+] feat(chat.tsx): add support for pinning the app window
[+] fix(tauri.conf.json): enable setting the app window always on top
  • Loading branch information
H0llyW00dzZ authored Nov 14, 2023
1 parent 243538d commit a50935d
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 65 deletions.
30 changes: 30 additions & 0 deletions app/components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ import { prettyObject } from "../utils/format";
import { ExportMessageModal } from "./exporter";
import { getClientConfig } from "../config/client";
import { useAllModels } from "../utils/hooks";
import { appWindow } from '@tauri-apps/api/window';

const Markdown = dynamic(async () => (await import("./markdown")).Markdown, {
loading: () => <LoadingIcon />,
Expand Down Expand Up @@ -684,6 +685,26 @@ export function EditMessageModal(props: { onClose: () => void }) {
);
}

function usePinApp() {
const [pinApp, setPinApp] = useState(false);

const togglePinApp = async () => {
if (pinApp) {
await appWindow.setAlwaysOnTop(true);
showToast(Locale.Chat.Actions.PinAppContent.Pinned);
} else {
await appWindow.setAlwaysOnTop(false);
showToast(Locale.Chat.Actions.PinAppContent.UnPinned);
}
setPinApp(!pinApp);
};

return {
pinApp,
togglePinApp,
};
}

function _Chat() {
type RenderMessage = ChatMessage & { preview?: boolean };

Expand All @@ -702,6 +723,7 @@ function _Chat() {
const [hitBottom, setHitBottom] = useState(true);
const isMobileScreen = useMobileScreen();
const navigate = useNavigate();
const { pinApp, togglePinApp } = usePinApp();

// prompt hints
const promptStore = usePromptStore();
Expand Down Expand Up @@ -1235,6 +1257,14 @@ function _Chat() {
setShowExport(true);
}}
/>
</div>
<div className="window-action-button">
<IconButton
icon={<PinIcon />}
bordered
title={Locale.Chat.Actions.Pin}
onClick={togglePinApp} // Call the enablePinApp function
/>
</div>
{showMaxIcon && (
<div className="window-action-button">
Expand Down
4 changes: 4 additions & 0 deletions app/locales/cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ const cn = {
Pin: "固定",
PinToastContent: "已将 1 条对话固定至预设提示词",
PinToastAction: "查看",
PinAppContent: {
Pinned : "桌面应用已固定",
UnPinned: "桌面应用已取消固定",
},
Delete: "删除",
Edit: "编辑",
},
Expand Down
4 changes: 4 additions & 0 deletions app/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ const en: LocaleType = {
Pin: "Pin",
PinToastContent: "Pinned 1 messages to contextual prompts",
PinToastAction: "View",
PinAppContent: {
Pinned : "Desktop App is now pinned",
UnPinned: "Desktop App is no longer pinned",
},
Delete: "Delete",
Edit: "Edit",
},
Expand Down
4 changes: 4 additions & 0 deletions app/locales/id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ const id: PartialLocaleType = {
Pin: "Pin",
PinToastContent: "2 pesan telah ditandai",
PinToastAction: "Lihat",
PinAppContent: {
Pinned : "Aplikasi Desktop sekarang dipasangkan",
UnPinned: "Aplikasi Desktop tidak lagi dipasangkan",
},
Delete: "Hapus",
Edit: "Edit",
},
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@fortaine/fetch-event-source": "^3.0.6",
"@hello-pangea/dnd": "^16.3.0",
"@svgr/webpack": "^6.5.1",
"@tauri-apps/api": "^1.5.1",
"@types/lodash": "^4.14.199",
"@vercel/analytics": "^0.1.11",
"emoji-picker-react": "^4.5.15",
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ tauri-build = { version = "1.3.0", features = [] }
[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.3.0", features = [ "process-relaunch", "fs-all", "notification-all", "clipboard-all", "dialog-all", "shell-open", "updater", "window-close", "window-hide", "window-maximize", "window-minimize", "window-set-icon", "window-set-ignore-cursor-events", "window-set-resizable", "window-show", "window-start-dragging", "window-unmaximize", "window-unminimize"] }
tauri = { version = "1.3.0", features = [ "window-set-always-on-top", "process-relaunch", "fs-all", "notification-all", "clipboard-all", "dialog-all", "shell-open", "updater", "window-close", "window-hide", "window-maximize", "window-minimize", "window-set-icon", "window-set-ignore-cursor-events", "window-set-resizable", "window-show", "window-start-dragging", "window-unmaximize", "window-unminimize"] }
tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }

[features]
Expand Down
6 changes: 4 additions & 2 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"show": true,
"startDragging": true,
"unmaximize": true,
"unminimize": true
"unminimize": true,
"setAlwaysOnTop": true
},
"fs": {
"all": true
Expand Down Expand Up @@ -110,7 +111,8 @@
"title": "ChatGPT Next Web",
"width": 960,
"hiddenTitle": true,
"titleBarStyle": "Overlay"
"titleBarStyle": "Overlay",
"alwaysOnTop": false
}
]
}
Expand Down
129 changes: 67 additions & 62 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1344,71 +1344,76 @@
dependencies:
tslib "^2.4.0"

"@tauri-apps/[email protected]":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-arm64/-/cli-darwin-arm64-1.4.0.tgz#e76bb8515ae31f03f2cbd440c1a09b237a79b3ac"
integrity sha512-nA/ml0SfUt6/CYLVbHmT500Y+ijqsuv5+s9EBnVXYSLVg9kbPUZJJHluEYK+xKuOj6xzyuT/+rZFMRapmJD3jQ==

"@tauri-apps/[email protected]":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-x64/-/cli-darwin-x64-1.4.0.tgz#dd1472460550d0aa0ec6e699b073be2d77e5b962"
integrity sha512-ov/F6Zr+dg9B0PtRu65stFo2G0ow2TUlneqYYrkj+vA3n+moWDHfVty0raDjMLQbQt3rv3uayFMXGPMgble9OA==

"@tauri-apps/[email protected]":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm-gnueabihf/-/cli-linux-arm-gnueabihf-1.4.0.tgz#325e90e47d260ba71a499850ce769b5a6bdfd48d"
integrity sha512-zwjbiMncycXDV7doovymyKD7sCg53ouAmfgpUqEBOTY3vgBi9TwijyPhJOqoG5vUVWhouNBC08akGmE4dja15g==

"@tauri-apps/[email protected]":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm64-gnu/-/cli-linux-arm64-gnu-1.4.0.tgz#b5d8f5cba3f8f7c7d44d071681f0ab0a37f2c46e"
integrity sha512-5MCBcziqXC72mMXnkZU68mutXIR6zavDxopArE2gQtK841IlE06bIgtLi0kUUhlFJk2nhPRgiDgdLbrPlyt7fw==

"@tauri-apps/[email protected]":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.4.0.tgz#f805ab2ee415875900f4b456f17dc4900d2a7911"
integrity sha512-7J3pRB6n6uNYgIfCeKt2Oz8J7oSaz2s8GGFRRH2HPxuTHrBNCinzVYm68UhVpJrL3bnGkU0ziVZLsW/iaOGfUg==

"@tauri-apps/[email protected]":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-x64-gnu/-/cli-linux-x64-gnu-1.4.0.tgz#d3f5e69c22420c7ac9e4021b7a94bce2e48cb45d"
integrity sha512-Zh5gfAJxOv5AVWxcwuueaQ2vIAhlg0d6nZui6nMyfIJ8dbf3aZQ5ZzP38sYow5h/fbvgL+3GSQxZRBIa3c2E1w==

"@tauri-apps/[email protected]":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-x64-musl/-/cli-linux-x64-musl-1.4.0.tgz#2e7f718272ffdd9ace80f57a35023ba0c74767ad"
integrity sha512-OLAYoICU3FaYiTdBsI+lQTKnDHeMmFMXIApN0M+xGiOkoIOQcV9CConMPjgmJQ867+NHRNgUGlvBEAh9CiJodQ==

"@tauri-apps/[email protected]":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-arm64-msvc/-/cli-win32-arm64-msvc-1.4.0.tgz#85cdb52a06feb92da785def4d02512099464525e"
integrity sha512-gZ05GENFbI6CB5MlOUsLlU0kZ9UtHn9riYtSXKT6MYs8HSPRffPHaHSL0WxsJweWh9nR5Hgh/TUU8uW3sYCzCg==

"@tauri-apps/[email protected]":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-ia32-msvc/-/cli-win32-ia32-msvc-1.4.0.tgz#0b7c921204058215aec9a5a00f735e73909bd330"
integrity sha512-JsetT/lTx/Zq98eo8T5CiRyF1nKeX04RO8JlJrI3ZOYsZpp/A5RJvMd/szQ17iOzwiHdge+tx7k2jHysR6oBlQ==

"@tauri-apps/[email protected]":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-x64-msvc/-/cli-win32-x64-msvc-1.4.0.tgz#23abe3f08c0df89111c29602f91c21a23577b908"
integrity sha512-z8Olcnwp5aYhzqUAarFjqF+oELCjuYWnB2HAJHlfsYNfDCAORY5kct3Fklz8PSsubC3U2EugWn8n42DwnThurg==
"@tauri-apps/api@^1.5.1":
version "1.5.1"
resolved "https://registry.yarnpkg.com/@tauri-apps/api/-/api-1.5.1.tgz#9074476c4323f71351db624e9711c99277cdfb99"
integrity sha512-6unsZDOdlXTmauU3NhWhn+Cx0rODV+rvNvTdvolE5Kls5ybA6cqndQENDt1+FS0tF7ozCP66jwWoH6a5h90BrA==

"@tauri-apps/[email protected]":
version "1.5.6"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-arm64/-/cli-darwin-arm64-1.5.6.tgz#0d68eaf6fa1b35197a9d4991ac5377e6085a569a"
integrity sha512-NNvG3XLtciCMsBahbDNUEvq184VZmOveTGOuy0So2R33b/6FDkuWaSgWZsR1mISpOuP034htQYW0VITCLelfqg==

"@tauri-apps/[email protected]":
version "1.5.6"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-x64/-/cli-darwin-x64-1.5.6.tgz#a48e1f66b12c33cf6c9c216865f2e9a3ff18a923"
integrity sha512-nkiqmtUQw3N1j4WoVjv81q6zWuZFhBLya/RNGUL94oafORloOZoSY0uTZJAoeieb3Y1YK0rCHSDl02MyV2Fi4A==

"@tauri-apps/[email protected]":
version "1.5.6"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm-gnueabihf/-/cli-linux-arm-gnueabihf-1.5.6.tgz#385cd8054be7722cc07acc2d6d86f8e20c6265ef"
integrity sha512-z6SPx+axZexmWXTIVPNs4Tg7FtvdJl9EKxYN6JPjOmDZcqA13iyqWBQal2DA/GMZ1Xqo3vyJf6EoEaKaliymPQ==

"@tauri-apps/[email protected]":
version "1.5.6"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm64-gnu/-/cli-linux-arm64-gnu-1.5.6.tgz#bd3f8f61637a1073909cb2d663aa0c6e8e036337"
integrity sha512-QuQjMQmpsCbzBrmtQiG4uhnfAbdFx3nzm+9LtqjuZlurc12+Mj5MTgqQ3AOwQedH3f7C+KlvbqD2AdXpwTg7VA==

"@tauri-apps/[email protected]":
version "1.5.6"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.5.6.tgz#77fb4a804b77447bffba725a4b8b62df45f9ff97"
integrity sha512-8j5dH3odweFeom7bRGlfzDApWVOT4jIq8/214Wl+JeiNVehouIBo9lZGeghZBH3XKFRwEvU23i7sRVjuh2s8mg==

"@tauri-apps/[email protected]":
version "1.5.6"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-x64-gnu/-/cli-linux-x64-gnu-1.5.6.tgz#e70a6c9dd243c2a3fa1fec69de9ebc9abf4dc795"
integrity sha512-gbFHYHfdEGW0ffk8SigDsoXks6USpilF6wR0nqB/JbWzbzFR/sBuLVNQlJl1RKNakyJHu+lsFxGy0fcTdoX8xA==

"@tauri-apps/[email protected]":
version "1.5.6"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-x64-musl/-/cli-linux-x64-musl-1.5.6.tgz#f25dad778b2da6ab7b2b81f81c0805026d742c33"
integrity sha512-9v688ogoLkeFYQNgqiSErfhTreLUd8B3prIBSYUt+x4+5Kcw91zWvIh+VSxL1n3KCGGsM7cuXhkGPaxwlEh1ug==

"@tauri-apps/[email protected]":
version "1.5.6"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-arm64-msvc/-/cli-win32-arm64-msvc-1.5.6.tgz#47d0f359e04d93c1fd0b527e18a56606f3df9bed"
integrity sha512-DRNDXFNZb6y5IZrw+lhTTA9l4wbzO4TNRBAlHAiXUrH+pRFZ/ZJtv5WEuAj9ocVSahVw2NaK5Yaold4NPAxHog==

"@tauri-apps/[email protected]":
version "1.5.6"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-ia32-msvc/-/cli-win32-ia32-msvc-1.5.6.tgz#54c7ec152065e8167068411b82748a25a483d948"
integrity sha512-oUYKNR/IZjF4fsOzRpw0xesl2lOjhsQEyWlgbpT25T83EU113Xgck9UjtI7xemNI/OPCv1tPiaM1e7/ABdg5iA==

"@tauri-apps/[email protected]":
version "1.5.6"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-x64-msvc/-/cli-win32-x64-msvc-1.5.6.tgz#963280a4f7001c27d4e4745f302728297c007deb"
integrity sha512-RmEf1os9C8//uq2hbjXi7Vgz9ne7798ZxqemAZdUwo1pv3oLVZSz1/IvZmUHPdy2e6zSeySqWu1D0Y3QRNN+dg==

"@tauri-apps/cli@^1.4.0":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli/-/cli-1.4.0.tgz#72732ae61e6b7d097e44a8a2ef5f211b2d01d98b"
integrity sha512-VXYr2i2iVFl98etQSQsqLzXgX96bnWiNZd1YADgatqwy/qecbd6Kl5ZAPB5R4ynsgE8A1gU7Fbzh7dCEQYFfmA==
version "1.5.6"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli/-/cli-1.5.6.tgz#5011c9dd3a36dc89073fed7d4cb429d38b37862b"
integrity sha512-k4Y19oVCnt7WZb2TnDzLqfs7o98Jq0tUoVMv+JQSzuRDJqaVu2xMBZ8dYplEn+EccdR5SOMyzaLBJWu38TVK1A==
optionalDependencies:
"@tauri-apps/cli-darwin-arm64" "1.4.0"
"@tauri-apps/cli-darwin-x64" "1.4.0"
"@tauri-apps/cli-linux-arm-gnueabihf" "1.4.0"
"@tauri-apps/cli-linux-arm64-gnu" "1.4.0"
"@tauri-apps/cli-linux-arm64-musl" "1.4.0"
"@tauri-apps/cli-linux-x64-gnu" "1.4.0"
"@tauri-apps/cli-linux-x64-musl" "1.4.0"
"@tauri-apps/cli-win32-arm64-msvc" "1.4.0"
"@tauri-apps/cli-win32-ia32-msvc" "1.4.0"
"@tauri-apps/cli-win32-x64-msvc" "1.4.0"
"@tauri-apps/cli-darwin-arm64" "1.5.6"
"@tauri-apps/cli-darwin-x64" "1.5.6"
"@tauri-apps/cli-linux-arm-gnueabihf" "1.5.6"
"@tauri-apps/cli-linux-arm64-gnu" "1.5.6"
"@tauri-apps/cli-linux-arm64-musl" "1.5.6"
"@tauri-apps/cli-linux-x64-gnu" "1.5.6"
"@tauri-apps/cli-linux-x64-musl" "1.5.6"
"@tauri-apps/cli-win32-arm64-msvc" "1.5.6"
"@tauri-apps/cli-win32-ia32-msvc" "1.5.6"
"@tauri-apps/cli-win32-x64-msvc" "1.5.6"

"@trysound/[email protected]":
version "0.2.0"
Expand Down

0 comments on commit a50935d

Please sign in to comment.