feat: crypto.randomUUID 替换为 uuid

This commit is contained in:
hzm
2026-03-04 10:21:33 +08:00
parent c9038757dd
commit c65f2b8ab1
4 changed files with 25 additions and 6 deletions

View File

@@ -1,7 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.cursor" />
<excludeFolder url="file://$MODULE_DIR$/.trae" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>

View File

@@ -11,6 +11,7 @@ import utc from 'dayjs/plugin/utc';
import timezone from 'dayjs/plugin/timezone';
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
import { isNumber, isString, isPlainObject } from 'lodash';
import { v4 as uuidv4 } from 'uuid';
import Announcement from "./components/Announcement";
import { Stat } from "./components/Common";
import FundTrendChart from "./components/FundTrendChart";
@@ -987,7 +988,7 @@ export default function HomePage() {
setTransactions(prev => {
const current = prev[fundCode] || [];
const record = {
id: crypto.randomUUID(),
id: uuidv4(),
type: data.type,
share: data.share,
amount: data.amount,
@@ -1012,7 +1013,7 @@ export default function HomePage() {
// 如果没有价格API失败加入待处理队列
if (!data.price || data.price === 0) {
const pending = {
id: crypto.randomUUID(),
id: uuidv4(),
fundCode: fund.code,
fundName: fund.name,
type: tradeModal.type,
@@ -1063,7 +1064,7 @@ export default function HomePage() {
setTransactions(prev => {
const current = prev[fund.code] || [];
const record = {
id: crypto.randomUUID(),
id: uuidv4(),
type: tradeModal.type,
share: data.share,
amount: isBuy ? data.totalCost : (data.share * data.price),

16
package-lock.json generated
View File

@@ -24,7 +24,8 @@
"react": "18.3.1",
"react-chartjs-2": "^5.3.1",
"react-dom": "18.3.1",
"tesseract.js": "^5.1.1"
"tesseract.js": "^5.1.1",
"uuid": "^13.0.0"
},
"devDependencies": {
"babel-plugin-react-compiler": "^1.0.0",
@@ -6959,6 +6960,19 @@
"punycode": "^2.1.0"
}
},
"node_modules/uuid": {
"version": "13.0.0",
"resolved": "https://registry.npmmirror.com/uuid/-/uuid-13.0.0.tgz",
"integrity": "sha512-XQegIaBTVUjSHliKqcnFqYypAd4S+WCYt5NIeRs6w/UAry7z8Y9j5ZwRRL4kzq9U3sD6v+85er9FvkEaBpji2w==",
"funding": [
"https://github.com/sponsors/broofa",
"https://github.com/sponsors/ctavan"
],
"license": "MIT",
"bin": {
"uuid": "dist-node/bin/uuid"
}
},
"node_modules/wasm-feature-detect": {
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/wasm-feature-detect/-/wasm-feature-detect-1.8.0.tgz",

View File

@@ -27,7 +27,8 @@
"react": "18.3.1",
"react-chartjs-2": "^5.3.1",
"react-dom": "18.3.1",
"tesseract.js": "^5.1.1"
"tesseract.js": "^5.1.1",
"uuid": "^13.0.0"
},
"engines": {
"node": ">=20.9.0"