fix: Open the link with browser

This commit is contained in:
MystiPanda 2024-04-28 18:46:49 +08:00
parent a54e9cb244
commit 9646fab22c
3 changed files with 1329 additions and 418 deletions

View File

@ -19,48 +19,48 @@
"@dnd-kit/core": "^6.1.0", "@dnd-kit/core": "^6.1.0",
"@dnd-kit/sortable": "^8.0.0", "@dnd-kit/sortable": "^8.0.0",
"@dnd-kit/utilities": "^3.2.2", "@dnd-kit/utilities": "^3.2.2",
"@emotion/react": "^11.11.3", "@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.0", "@emotion/styled": "^11.11.5",
"@juggle/resize-observer": "^3.4.0", "@juggle/resize-observer": "^3.4.0",
"@mui/icons-material": "^5.15.5", "@mui/icons-material": "^5.15.15",
"@mui/lab": "5.0.0-alpha.149", "@mui/lab": "5.0.0-alpha.149",
"@mui/material": "^5.15.5", "@mui/material": "^5.15.15",
"@mui/x-data-grid": "^6.18.7", "@mui/x-data-grid": "^6.19.11",
"@tauri-apps/api": "^1.5.3", "@tauri-apps/api": "^1.5.4",
"@types/json-schema": "^7.0.15", "@types/json-schema": "^7.0.15",
"ahooks": "^3.7.8", "ahooks": "^3.7.11",
"axios": "^1.6.5", "axios": "^1.6.8",
"dayjs": "1.11.5", "dayjs": "1.11.5",
"i18next": "^23.7.16", "i18next": "^23.11.2",
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"meta-json-schema": "^1.18.3-beta", "meta-json-schema": "1.18.3-beta",
"monaco-editor": "^0.47.0", "monaco-editor": "^0.47.0",
"monaco-yaml": "^5.1.1", "monaco-yaml": "^5.1.1",
"nanoid": "^5.0.4", "nanoid": "^5.0.7",
"react": "^18.2.0", "react": "^18.3.1",
"react-dom": "^18.2.0", "react-dom": "^18.3.1",
"react-error-boundary": "^3.1.4", "react-error-boundary": "^3.1.4",
"react-hook-form": "^7.49.3", "react-hook-form": "^7.51.3",
"react-i18next": "^13.5.0", "react-i18next": "^13.5.0",
"react-router-dom": "^6.21.2", "react-markdown": "^9.0.1",
"react-router-dom": "^6.23.0",
"react-transition-group": "^4.4.5", "react-transition-group": "^4.4.5",
"react-virtuoso": "^4.6.2", "react-virtuoso": "^4.7.10",
"recoil": "^0.7.7", "recoil": "^0.7.7",
"snarkdown": "^2.0.0",
"swr": "^1.3.0", "swr": "^1.3.0",
"tar": "^6.2.0" "tar": "^6.2.1"
}, },
"devDependencies": { "devDependencies": {
"@actions/github": "^5.1.1", "@actions/github": "^5.1.1",
"@tauri-apps/cli": "^1.5.9", "@tauri-apps/cli": "^1.5.12",
"@types/fs-extra": "^9.0.13", "@types/fs-extra": "^9.0.13",
"@types/js-cookie": "^3.0.6", "@types/js-cookie": "^3.0.6",
"@types/lodash-es": "^4.17.12", "@types/lodash-es": "^4.17.12",
"@types/react": "^18.2.48", "@types/react": "^18.3.1",
"@types/react-dom": "^18.2.18", "@types/react-dom": "^18.3.0",
"@types/react-transition-group": "^4.4.10", "@types/react-transition-group": "^4.4.10",
"@vitejs/plugin-react": "^4.2.1", "@vitejs/plugin-react": "^4.2.1",
"adm-zip": "^0.5.10", "adm-zip": "^0.5.12",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"fs-extra": "^11.2.0", "fs-extra": "^11.2.0",
"https-proxy-agent": "^5.0.1", "https-proxy-agent": "^5.0.1",
@ -68,9 +68,9 @@
"node-fetch": "^3.3.2", "node-fetch": "^3.3.2",
"prettier": "^2.8.8", "prettier": "^2.8.8",
"pretty-quick": "^3.3.1", "pretty-quick": "^3.3.1",
"sass": "^1.70.0", "sass": "^1.75.0",
"typescript": "^5.3.3", "typescript": "^5.4.5",
"vite": "^5.0.11", "vite": "^5.2.10",
"vite-plugin-monaco-editor": "^1.1.0", "vite-plugin-monaco-editor": "^1.1.0",
"vite-plugin-svgr": "^4.2.0" "vite-plugin-svgr": "^4.2.0"
}, },

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,7 @@
import useSWR from "swr"; import useSWR from "swr";
import snarkdown from "snarkdown";
import { forwardRef, useImperativeHandle, useState, useMemo } from "react"; import { forwardRef, useImperativeHandle, useState, useMemo } from "react";
import { useLockFn } from "ahooks"; import { useLockFn } from "ahooks";
import { Box, LinearProgress, styled } from "@mui/material"; import { Box, LinearProgress } from "@mui/material";
import { useRecoilState } from "recoil"; import { useRecoilState } from "recoil";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { relaunch } from "@tauri-apps/api/process"; import { relaunch } from "@tauri-apps/api/process";
@ -11,10 +10,8 @@ import { BaseDialog, DialogRef, Notice } from "@/components/base";
import { atomUpdateState } from "@/services/states"; import { atomUpdateState } from "@/services/states";
import { listen, Event, UnlistenFn } from "@tauri-apps/api/event"; import { listen, Event, UnlistenFn } from "@tauri-apps/api/event";
import { portableFlag } from "@/pages/_layout"; import { portableFlag } from "@/pages/_layout";
import ReactMarkdown from "react-markdown";
const UpdateLog = styled(Box)(() => ({
"h1,h2,h3,ul,ol,p": { margin: "0.5em 0", color: "inherit" },
}));
let eventListener: UnlistenFn | null = null; let eventListener: UnlistenFn | null = null;
export const UpdateViewer = forwardRef<DialogRef>((props, ref) => { export const UpdateViewer = forwardRef<DialogRef>((props, ref) => {
@ -38,12 +35,11 @@ export const UpdateViewer = forwardRef<DialogRef>((props, ref) => {
close: () => setOpen(false), close: () => setOpen(false),
})); }));
// markdown parser const markdownContent = useMemo(() => {
const parseContent = useMemo(() => {
if (!updateInfo?.manifest?.body) { if (!updateInfo?.manifest?.body) {
return "New Version is available"; return "New Version is available";
} }
return snarkdown(updateInfo?.manifest?.body); return updateInfo?.manifest?.body;
}, [updateInfo]); }, [updateInfo]);
const onUpdate = useLockFn(async () => { const onUpdate = useLockFn(async () => {
@ -87,10 +83,22 @@ export const UpdateViewer = forwardRef<DialogRef>((props, ref) => {
onCancel={() => setOpen(false)} onCancel={() => setOpen(false)}
onOk={onUpdate} onOk={onUpdate}
> >
<UpdateLog <Box sx={{ height: "calc(100% - 10px)", overflow: "auto" }}>
dangerouslySetInnerHTML={{ __html: parseContent }} <ReactMarkdown
sx={{ height: "calc(100% - 10px)", overflow: "auto" }} components={{
/> a: ({ node, ...props }) => {
const { children } = props;
return (
<a {...props} target="_blank">
{children}
</a>
);
},
}}
>
{markdownContent}
</ReactMarkdown>
</Box>
{updateState && ( {updateState && (
<LinearProgress <LinearProgress
variant="buffer" variant="buffer"