diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 4fdfa52..026613b 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -12,8 +12,5 @@ A clear and concise description of what the problem is. Ex. I'm always frustrate **Describe the solution you'd like** A clear and concise description of what you want to happen. -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - **Additional context** Add any other context or screenshots about the feature request here. diff --git a/package.json b/package.json index d43384c..125027b 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "@tauri-apps/plugin-process": "~2", "@tauri-apps/plugin-shell": "~2", "@tauri-apps/plugin-store": "~2", + "marked": "^15.0.7", "naive-ui": "^2.41.0", "pinia": "^3.0.1", "vue": "^3.5.13", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8608888..4e0921e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -32,6 +32,9 @@ importers: '@tauri-apps/plugin-store': specifier: ~2 version: 2.2.0 + marked: + specifier: ^15.0.7 + version: 15.0.7 naive-ui: specifier: ^2.41.0 version: 2.41.0(vue@3.5.13(typescript@5.8.2)) @@ -1094,6 +1097,11 @@ packages: magic-string@0.30.17: resolution: {integrity: sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA==} + marked@15.0.7: + resolution: {integrity: sha512-dgLIeKGLx5FwziAnsk4ONoGwHwGPJzselimvlVskE9XLN4Orv9u2VA3GWw/lYUqjfA0rUT/6fqKwfZJapP9BEg==} + engines: {node: '>= 18'} + hasBin: true + memorystream@0.3.1: resolution: {integrity: sha512-S3UwM3yj5mtUSEfP41UZmt/0SCoVYUcU1rkXv+BQ5Ig8ndL4sPoJNBUJERafdPb5jjHJGuMgytgKvKIf58XNBw==} engines: {node: '>= 0.10.0'} @@ -2388,6 +2396,8 @@ snapshots: dependencies: '@jridgewell/sourcemap-codec': 1.5.0 + marked@15.0.7: {} + memorystream@0.3.1: {} micromatch@4.0.8: diff --git a/src/tools/hooks.ts b/src/tools/hooks.ts index 75d1496..7cf1c64 100644 --- a/src/tools/hooks.ts +++ b/src/tools/hooks.ts @@ -1,6 +1,5 @@ import { getVersion } from "@tauri-apps/api/app"; import { useDialog, useMessage } from "naive-ui"; -import { h } from "vue"; import { useI18n } from "vue-i18n"; import { fetch } from "@tauri-apps/plugin-http"; import { compareVersion } from "./tools"; @@ -8,13 +7,16 @@ import { checkAdbAvailable } from "./invoke"; import { NonReactiveStore } from "../store/noneReactiveStore"; import { getCurrentWindow, LogicalSize } from "@tauri-apps/api/window"; import { useGlobalStore } from "../store/global"; +import { h } from "vue"; +import { marked } from "marked"; -// TODO use markdown to render update info - -function renderUpdateInfo(content: string) { - const pList = content.split("\r\n").map((line: string) => h("p", line)); - return h("div", { style: "margin: 20px 0" }, pList); -} +const render = new marked.Renderer(); +marked.setOptions({ + renderer: render, + gfm: true, + pedantic: false, + async: false, +}); export function useCheckUpdate() { const message = useMessage(); @@ -43,7 +45,11 @@ export function useCheckUpdate() { const body = data.body as string; dialog.info({ title: t("pages.Mask.checkUpdate.notLatest.title", [latestVersion]), - content: () => renderUpdateInfo(body), + content: () => + h("div", { + style: "margin: 20px 0", + innerHTML: marked.parse(body), + }), positiveText: t("pages.Mask.checkUpdate.notLatest.positiveText"), negativeText: t("pages.Mask.checkUpdate.notLatest.negativeText"), onPositiveClick: () => {