Skip to content

Commit

Permalink
fix: non-style window
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghomist committed Feb 22, 2025
1 parent c744bdb commit 3f8ba60
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 14 deletions.
6 changes: 3 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<!doctype html>
<html lang="en" style="background: transparent">
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tauri + Vue + Typescript App</title>
<title>Rockoon</title>
</head>

<body style="margin: 8px; filter: drop-shadow(0 0 2px black)">
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "rockoon",
"version": "1.5.0",
"version": "1.5.1",
"identifier": "com.ghomist.rockoon",
"build": {
"beforeDevCommand": "pnpm dev",
Expand Down
8 changes: 7 additions & 1 deletion src/assets/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
-webkit-text-size-adjust: 100%;
}

:root {
/* make transparent window */
background: transparent;
}

body {
user-select: none;
-ms-user-select: none;
Expand All @@ -24,7 +29,8 @@ body {

scrollbar-width: none;

margin: 0;
margin: 8px;
filter: drop-shadow(0 0 2px black);
}

::-webkit-scrollbar {
Expand Down
52 changes: 45 additions & 7 deletions src/utils/updater.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,53 @@
import { check } from "@tauri-apps/plugin-updater";
import { openDialog } from "./message";
// import { relaunch } from "@tauri-apps/plugin-process";
import { openDialog, sendMessage } from "./message";
import { h, ref } from "vue";
import { toPercentage } from "./format";

export const checkUpdate = async () => {
const update = await check();
if (update) {
openDialog(
`found update ${update.version} from ${update.date} with notes ${update.body}`,
{
title: "更新提示"
let date = "未知";
if (update.date) {
date = update.date
.replace(/\s+([+-]\d{2}:\d{2}):\d{2}$/, "$1")
.replace(/(?<!\d)(\d)(?!\d)/, "0$1")
.replace(" ", "T");
date = new Date(date).toLocaleString("zh-CN", {
dateStyle: "long",
timeStyle: "short"
});
}
openDialog(`更新至 <b>${update.version}</b> (${date})`, {
lock: true,
title: "发现新版本!",
sureText: "更新并重启 Rockoon",
onSure: async () => {
const message = ref("");
const { close } = openDialog(() => h("p", message.value), {
title: "更新中...",
lock: true,
footer: false
});
let downloaded = 0;
let contentLength = 0;
await update.downloadAndInstall(event => {
switch (event.event) {
case "Started":
contentLength = event.data.contentLength ?? 0;
message.value = "开始下载...";
break;
case "Progress":
downloaded += event.data.chunkLength;
message.value = `下载中... ${toPercentage(downloaded / contentLength)}`;
break;
case "Finished":
message.value = `下载完成!`;
break;
}
});
close();
sendMessage("更新完成!请重启 Rockoon");
}
);
});
}
};
15 changes: 13 additions & 2 deletions src/views/settings/SettingsPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { open } from "@tauri-apps/plugin-shell";
import { open as browseFile } from "@tauri-apps/plugin-dialog";
import { onMounted, ref } from "vue";
import { convertFileSrc } from "@tauri-apps/api/core";
import { checkUpdate } from "@/utils/updater";
const pref = usePrefStore();
Expand Down Expand Up @@ -82,6 +83,10 @@ const onRestorePref = () => {
const appVersion = ref("");
const tauriVersion = ref("");
const onCheckUpdate = async () => {
sendMessage("正在检查更新");
await checkUpdate();
};
// debug
const debugContent = ref("欢迎使用 Rockoon!");
Expand Down Expand Up @@ -195,8 +200,14 @@ onMounted(() => {
</BasicCollapse>

<BasicCollapse title="关于 Rockoon">
<BasicConfig title="当前版本"> {{ appVersion }} </BasicConfig>
<BasicConfig title="Tauri 版本"> {{ tauriVersion }} </BasicConfig>
<BasicConfig title="当前版本">
<BasicButton @click="onCheckUpdate">
当前版本 {{ appVersion }},点击检查更新
</BasicButton>
</BasicConfig>
<BasicConfig title="框架版本">
<BasicButton> Tauri - {{ tauriVersion }} </BasicButton>
</BasicConfig>
<BasicConfig title="作者 Github">
<a @click="open('https://github.com/Ghomist')"> @Ghomist </a>
</BasicConfig>
Expand Down

0 comments on commit 3f8ba60

Please sign in to comment.