feat: update deps and insight

This commit is contained in:
Haoyu Xu
2025-01-28 22:10:02 +08:00
parent 07e7cd2bd1
commit 075087e733
6 changed files with 1264 additions and 1312 deletions

View File

@@ -5,11 +5,7 @@
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>aklive2d directory</title> <title>aklive2d directory</title>
<script <link rel="canonical" href="https://arknights.halyul.dev/">
id="counterscale-script"
src="https://insight.halyul.dev/on-demand.js"
defer
></script>
<style> <style>
.loader { .loader {
position: fixed; position: fixed;

View File

@@ -1,13 +1,19 @@
import * as Counterscale from "@counterscale/tracker";
import React from 'react'; import React from 'react';
export default (path = null, skipPageView = false) => { Counterscale.init({
siteId: "aklive2d",
reporterUrl: "https://insight.halyul.dev/collect",
autoTrackPageviews: false,
});
export default (path = "", skipPageView = false) => {
React.useEffect(() => { React.useEffect(() => {
if (!skipPageView && import.meta.env.MODE !== 'development') { if (!skipPageView && import.meta.env.MODE !== 'development') {
try { try {
window.counterscale = { Counterscale.trackPageview({
q: [["set", "siteId", import.meta.env.VITE_INSIGHT_ID], ["trackPageview", {path}]], url: `/${path}`
}; });
window.counterscaleOnDemandTrack()
} catch (err) { } catch (err) {
console.warn && console.warn(err.message) console.warn && console.warn(err.message)
} }

View File

@@ -18,36 +18,38 @@
"cf:download": "node aklive2d cf:download" "cf:download": "node aklive2d cf:download"
}, },
"devDependencies": { "devDependencies": {
"@types/react": "^18.3.18", "@types/react": "^19.0.8",
"@types/react-dom": "^18.3.5", "@types/react-dom": "^19.0.3",
"@vitejs/plugin-react-swc": "^3.7.2", "@vitejs/plugin-react-swc": "^3.7.2",
"autoprefixer": "^10.4.20", "autoprefixer": "^10.4.20",
"eslint": "^8.57.1", "eslint": "^9.19.0",
"eslint-plugin-react": "^7.37.3", "eslint-plugin-react": "^7.37.4",
"eslint-plugin-react-hooks": "^4.6.2", "eslint-plugin-react-hooks": "^5.1.0",
"postcss": "^8.4.49", "postcss": "^8.5.1",
"prop-types": "^15.8.1", "prop-types": "^15.8.1",
"rollup": "^3.29.5", "rollup": "^4.32.1",
"sass": "^1.83.1", "sass": "^1.83.4",
"stylelint": "^16.12.0", "stylelint": "^16.14.1",
"stylelint-config-standard": "^36.0.1", "stylelint-config-standard": "^37.0.0",
"stylelint-config-standard-scss": "^13.1.0", "stylelint-config-standard-scss": "^14.0.0",
"vite": "^5.4.11", "vite": "^6.0.11",
"wrangler": "^3.99.0" "wrangler": "^3.106.0"
}, },
"dependencies": { "dependencies": {
"@counterscale/tracker": "^2.5.1",
"dotenv": "^16.4.7", "dotenv": "^16.4.7",
"jotai": "^2.11.0", "jotai": "^2.11.1",
"jsdom": "^22.1.0", "jsdom": "^26.0.0",
"node-fetch": "^3.3.2", "node-fetch": "^3.3.2",
"p-throttle": "^6.2.0", "p-throttle": "^7.0.0",
"react": "^18.3.1", "react": "^19.0.0",
"react-dom": "^18.3.1", "react-dom": "^19.0.0",
"react-refresh": "^0.14.2", "react-refresh": "^0.16.0",
"react-router-dom": "^6.28.1", "react-router-dom": "^7.1.3",
"react-simple-typewriter": "^5.0.1", "react-simple-typewriter": "^5.0.1",
"reset-css": "^5.0.2", "reset-css": "^5.0.2",
"sharp": "^0.32.6", "sharp": "^0.33.5",
"yaml": "^2.7.0" "yaml": "^2.7.0"
} },
} "packageManager": "pnpm@9.5.0+sha512.140036830124618d624a2187b50d04289d5a087f326c9edfc0ccd733d76c4f52c3a313d4fc148794a2a9d81553016004e6742e8cf850670268a7387fc220c903"
}

2478
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -6,11 +6,7 @@
<meta name="apple-mobile-web-app-status-bar-style" content="black"> <meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="renderer" content="webkit"> <meta name="renderer" content="webkit">
<title>aklive2d</title> <title>aklive2d</title>
<script <link rel="canonical" href="https://arknights.halyul.dev/">
id="counterscale-script"
src="https://insight.halyul.dev/on-demand.js"
defer
></script>
</head> </head>
<body> <body>
<div id="app"></div> <div id="app"></div>

View File

@@ -1,4 +1,5 @@
import {createCustomEvent} from "@/components/helper" import * as Counterscale from "@counterscale/tracker";
import { createCustomEvent } from "@/components/helper"
export default class Insight { export default class Insight {
#isInsightInited = false #isInsightInited = false
@@ -12,14 +13,19 @@ export default class Insight {
this.#isInsightInited = true this.#isInsightInited = true
if (doNotTrack) return if (doNotTrack) return
try { try {
const config = { const canonical = document.querySelector('link[rel="canonical"][href]')
path: `/${import.meta.env.VITE_LINK}` if (!canonical) {
return;
} }
if (isFromWallpaperEngine) config.hostname = "file://wallpaperengine.local"; if (isFromWallpaperEngine) canonical.href = "file://wallpaperengine.local/";
window.counterscale = { Counterscale.init({
q: [["set", "siteId", import.meta.env.VITE_INSIGHT_ID], ["trackPageview", config]], siteId: "aklive2d",
}; reporterUrl: "https://insight.halyul.dev/collect",
window.counterscaleOnDemandTrack(); autoTrackPageviews: false,
});
Counterscale.trackPageview({
url: `/${import.meta.env.VITE_LINK}`
});
} catch (e) { } catch (e) {
console.warn && console.warn(e.message) console.warn && console.warn(e.message)
} }