diff --git a/.env b/.env index 8ea5a7c5..5faf8537 100644 --- a/.env +++ b/.env @@ -1,6 +1,6 @@ APP_NAME=media-downloader APP_ID=mediago.ziying.site APP_COPYRIGHT=caorushizi -APP_VERSION=2.0.3-beta.1 +APP_VERSION=2.0.3-beta.2 APP_SERVER_PORT=8433 diff --git a/.env.development b/.env.development index e96546cf..b608a433 100644 --- a/.env.development +++ b/.env.development @@ -1,4 +1,5 @@ APP_TD_APPID= +APP_CLARITY_APPID= APP_DOWNLOAD_DEBUG=true GH_TOKEN= diff --git a/.env.production b/.env.production index b758f857..429b2fb8 100644 --- a/.env.production +++ b/.env.production @@ -1,4 +1,5 @@ APP_TD_APPID= +APP_CLARITY_APPID= APP_DOWNLOAD_DEBUG= GH_TOKEN= diff --git a/packages/main/app/package.json b/packages/main/app/package.json index 60676103..1f251e39 100644 --- a/packages/main/app/package.json +++ b/packages/main/app/package.json @@ -1,6 +1,6 @@ { "name": "media-downloader", - "version": "2.0.3-beta.1", + "version": "2.0.3-beta.2", "description": "在线视频下载器", "main": "main/index.js", "author": "", diff --git a/packages/renderer/src/layout/App/index.tsx b/packages/renderer/src/layout/App/index.tsx index 024888f0..74c8115d 100644 --- a/packages/renderer/src/layout/App/index.tsx +++ b/packages/renderer/src/layout/App/index.tsx @@ -19,7 +19,6 @@ import { selectCount, } from "../../store"; import { useAsyncEffect } from "ahooks"; -import { tdApp } from "../../utils"; const { Footer, Sider, Content } = Layout; @@ -126,7 +125,6 @@ const App: FC = () => { ); const openHelpUrl = () => { - tdApp.openHelpPage(); const url = "https://downloader.caorushizi.cn/guides.html?form=client"; openUrl(url); }; diff --git a/packages/renderer/src/main.tsx b/packages/renderer/src/main.tsx index 42a56021..3b097da3 100644 --- a/packages/renderer/src/main.tsx +++ b/packages/renderer/src/main.tsx @@ -5,11 +5,12 @@ import { Provider } from "react-redux"; import store from "./store"; import dayjs from "dayjs"; import "dayjs/locale/zh-cn"; -import { tdApp } from "./utils"; +import { tdApp, initClarity } from "./utils"; import App from "./App"; dayjs.locale("zh-cn"); tdApp.init(); +initClarity(); createRoot(document.getElementById("root") as HTMLElement).render( diff --git a/packages/renderer/src/nodes/HomePage/index.tsx b/packages/renderer/src/nodes/HomePage/index.tsx index e8702b60..e6da1cff 100644 --- a/packages/renderer/src/nodes/HomePage/index.tsx +++ b/packages/renderer/src/nodes/HomePage/index.tsx @@ -27,7 +27,6 @@ import { } from "@ant-design/icons"; import { useSelector } from "react-redux"; import { selectAppStore } from "../../store"; -import { tdApp } from "../../utils"; import DownloadFrom from "../../components/DownloadForm"; import dayjs from "dayjs"; import classNames from "classnames"; @@ -96,12 +95,10 @@ const HomePage: FC = ({ filter = DownloadFilter.list }) => { }; const onDownloadSuccess = () => { - tdApp.downloadSuccess(); refresh(); }; const onDownloadFailed = () => { - tdApp.downloadFailed(); refresh(); }; @@ -156,7 +153,6 @@ const HomePage: FC = ({ filter = DownloadFilter.list }) => { }, []); const onStartDownload = async (id: number) => { - tdApp.startDownload(); await startDownload(id); messageApi.success("添加任务成功"); refresh(); diff --git a/packages/renderer/src/utils/clarity.ts b/packages/renderer/src/utils/clarity.ts new file mode 100644 index 00000000..4da79c56 --- /dev/null +++ b/packages/renderer/src/utils/clarity.ts @@ -0,0 +1,14 @@ +/* eslint-disable */ +// @ts-nocheck +// prettier-ignore +export function initClarity() { + try { + (function(c,l,a,r,i,t,y){ + c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)}; + t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i; + y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y); + })(window, document, "clarity", "script", import.meta.env.APP_CLARITY_APPID); + } catch (e) { + // empty + } +} diff --git a/packages/renderer/src/utils/index.ts b/packages/renderer/src/utils/index.ts index bd110e2a..c94596ac 100644 --- a/packages/renderer/src/utils/index.ts +++ b/packages/renderer/src/utils/index.ts @@ -2,6 +2,7 @@ import { isUrl } from "./url"; export { http } from "./http"; export { tdApp } from "./tdapp"; +export { initClarity } from "./clarity"; export const requestImage = (url: string, timeout = 1000): Promise => { return new Promise((resolve, reject) => { diff --git a/packages/renderer/src/utils/tdapp.ts b/packages/renderer/src/utils/tdapp.ts index d2c1b806..b7c1fe0e 100644 --- a/packages/renderer/src/utils/tdapp.ts +++ b/packages/renderer/src/utils/tdapp.ts @@ -12,22 +12,18 @@ class TDEvent { init() { const script = document.createElement("script"); script.src = `https://jic.talkingdata.com/app/h5/v1?appid=${this.appId}&vn=${this.vn}&vc=${this.vc}`; + script.async = true; const headElement = document.getElementsByTagName("head")[0]; headElement.appendChild(script); } - onEvent(eventId: string, mapKv: Record = {}) { + private onEvent(eventId: string, mapKv: Record = {}) { try { window.TDAPP?.onEvent(eventId, "", mapKv); } catch (e) { // empty } } - - downloadFailed = () => this.onEvent("下载页面-下载视频失败"); - downloadSuccess = () => this.onEvent("下载页面-下载视频成功"); - openHelpPage = () => this.onEvent("下载页面-打开使用帮助"); - startDownload = () => this.onEvent("资源下载-下载按钮"); } const tdApp = new TDEvent(); diff --git a/packages/renderer/src/vite-env.d.ts b/packages/renderer/src/vite-env.d.ts index 4b83ba8c..11b4a64e 100644 --- a/packages/renderer/src/vite-env.d.ts +++ b/packages/renderer/src/vite-env.d.ts @@ -8,9 +8,10 @@ declare global { onEvent: ( eventId: string, label: "", - mapKv: Record + mapKv: Record, ) => void; }; + clarity?: any; } }