sa2kit 3.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/llm/ui/miniapp/index.d.mts +2 -2
- package/dist/ai/llm/ui/miniapp/index.d.ts +2 -2
- package/dist/ai/llm/ui/rn/index.d.mts +2 -2
- package/dist/ai/llm/ui/rn/index.d.ts +2 -2
- package/dist/ai/llm/ui/web/index.d.mts +3 -3
- package/dist/ai/llm/ui/web/index.d.ts +3 -3
- package/dist/analytics/index.d.mts +1 -1
- package/dist/analytics/index.d.ts +1 -1
- package/dist/{chunk-QP5N3ER6.js → chunk-3CSCIRQY.js} +5 -6
- package/dist/chunk-3CSCIRQY.js.map +1 -0
- package/dist/{chunk-RJP2BRJD.mjs → chunk-4OOANEJV.mjs} +2 -2
- package/dist/{chunk-RJP2BRJD.mjs.map → chunk-4OOANEJV.mjs.map} +1 -1
- package/dist/chunk-5FUAQLGC.mjs +14 -0
- package/dist/chunk-5FUAQLGC.mjs.map +1 -0
- package/dist/{chunk-S732H246.js → chunk-6PMXAK7F.js} +2 -2
- package/dist/{chunk-S732H246.js.map → chunk-6PMXAK7F.js.map} +1 -1
- package/dist/chunk-6YLCRWKM.mjs +8 -0
- package/dist/chunk-6YLCRWKM.mjs.map +1 -0
- package/dist/{chunk-IBWDBBX5.mjs → chunk-7B5SI4OF.mjs} +3 -4
- package/dist/chunk-7B5SI4OF.mjs.map +1 -0
- package/dist/chunk-EQXPL7TN.mjs +78 -0
- package/dist/chunk-EQXPL7TN.mjs.map +1 -0
- package/dist/{chunk-GQZHGSRR.js → chunk-GSNGCENJ.js} +39 -2
- package/dist/chunk-GSNGCENJ.js.map +1 -0
- package/dist/chunk-HQLKOXG7.js +16 -0
- package/dist/chunk-HQLKOXG7.js.map +1 -0
- package/dist/{chunk-S3PUP7N4.js → chunk-PA4ELVGI.js} +2 -2
- package/dist/{chunk-S3PUP7N4.js.map → chunk-PA4ELVGI.js.map} +1 -1
- package/dist/{chunk-WZDTNDYR.js → chunk-QSKLQX6H.js} +11 -11
- package/dist/{chunk-WZDTNDYR.js.map → chunk-QSKLQX6H.js.map} +1 -1
- package/dist/{chunk-LHJKLUM7.mjs → chunk-TNJ6LYX7.mjs} +2 -2
- package/dist/{chunk-LHJKLUM7.mjs.map → chunk-TNJ6LYX7.mjs.map} +1 -1
- package/dist/{chunk-J77KR2EV.mjs → chunk-WJ7IMUEJ.mjs} +3 -3
- package/dist/{chunk-J77KR2EV.mjs.map → chunk-WJ7IMUEJ.mjs.map} +1 -1
- package/dist/chunk-YTGUIRRH.js +10 -0
- package/dist/chunk-YTGUIRRH.js.map +1 -0
- package/dist/common/auth/client/index.d.mts +1 -31
- package/dist/common/auth/client/index.d.ts +1 -31
- package/dist/common/auth/client/index.js +2 -15
- package/dist/common/auth/client/index.mjs +1 -2
- package/dist/common/auth/components/index.d.mts +14 -248
- package/dist/common/auth/components/index.d.ts +14 -248
- package/dist/common/auth/components/index.js +878 -49
- package/dist/common/auth/components/index.js.map +1 -1
- package/dist/common/auth/components/index.mjs +871 -5
- package/dist/common/auth/components/index.mjs.map +1 -1
- package/dist/common/auth/hooks/index.d.mts +2 -29
- package/dist/common/auth/hooks/index.d.ts +2 -29
- package/dist/common/auth/hooks/index.js +2 -11
- package/dist/common/auth/hooks/index.mjs +1 -2
- package/dist/common/auth/index.d.mts +5 -9
- package/dist/common/auth/index.d.ts +5 -9
- package/dist/common/auth/index.js +7 -28
- package/dist/common/auth/index.mjs +3 -4
- package/dist/common/auth/react/index.d.mts +3 -3
- package/dist/common/auth/react/index.d.ts +3 -3
- package/dist/common/auth/rn/index.d.mts +3 -19
- package/dist/common/auth/rn/index.d.ts +3 -19
- package/dist/common/auth/rn/index.js +0 -32
- package/dist/common/auth/rn/index.js.map +1 -1
- package/dist/common/auth/rn/index.mjs +1 -30
- package/dist/common/auth/rn/index.mjs.map +1 -1
- package/dist/common/auth/server/index.d.mts +81 -2
- package/dist/common/auth/server/index.d.ts +81 -2
- package/dist/common/auth/server/index.js +128 -37
- package/dist/common/auth/server/index.js.map +1 -1
- package/dist/common/auth/server/index.mjs +124 -1
- package/dist/common/auth/server/index.mjs.map +1 -1
- package/dist/common/auth/services/index.js +12 -9
- package/dist/common/auth/services/index.js.map +1 -1
- package/dist/common/auth/services/index.mjs +10 -1
- package/dist/common/auth/services/index.mjs.map +1 -1
- package/dist/common/file/server/index.js +32 -32
- package/dist/common/file/server/index.mjs +3 -3
- package/dist/common/index.d.mts +5 -8
- package/dist/common/index.d.ts +5 -8
- package/dist/common/index.js +12 -14
- package/dist/common/index.mjs +6 -8
- package/dist/common/request/index.js +4 -5
- package/dist/common/request/index.mjs +2 -3
- package/dist/i18n/index.d.mts +1 -1
- package/dist/i18n/index.d.ts +1 -1
- package/dist/imageCrop/index.d.mts +3 -3
- package/dist/imageCrop/index.d.ts +3 -3
- package/dist/index-Bd7cKF1j.d.mts +50 -0
- package/dist/{index-CLB80GCP.d.ts → index-D0cqaQEH.d.mts} +5 -5
- package/dist/{index-CLB80GCP.d.mts → index-D0cqaQEH.d.ts} +5 -5
- package/dist/index-DRQxtCDw.d.ts +50 -0
- package/dist/{index-BxZauNN_.d.mts → index-DoUo8IrU.d.mts} +8 -8
- package/dist/{index-BxZauNN_.d.ts → index-DoUo8IrU.d.ts} +8 -8
- package/dist/index.d.mts +152 -131
- package/dist/index.d.ts +152 -131
- package/dist/index.js +105 -554
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +106 -555
- package/dist/index.mjs.map +1 -1
- package/dist/ossFile/server/index.js +32 -32
- package/dist/ossFile/server/index.mjs +3 -3
- package/dist/request/index.js +3 -4
- package/dist/request/index.mjs +1 -2
- package/dist/universalExport/index.d.mts +3 -3
- package/dist/universalExport/index.d.ts +3 -3
- package/dist/universalFile/index.d.mts +5 -5
- package/dist/universalFile/index.d.ts +5 -5
- package/dist/universalFile/server/index.js +62 -62
- package/dist/universalFile/server/index.mjs +2 -2
- package/package.json +1 -36
- package/dist/auth/client/index.d.mts +0 -13
- package/dist/auth/client/index.d.ts +0 -13
- package/dist/auth/client/index.js +0 -26
- package/dist/auth/client/index.js.map +0 -1
- package/dist/auth/client/index.mjs +0 -5
- package/dist/auth/client/index.mjs.map +0 -1
- package/dist/auth/components/index.d.mts +0 -10
- package/dist/auth/components/index.d.ts +0 -10
- package/dist/auth/components/index.js +0 -70
- package/dist/auth/components/index.js.map +0 -1
- package/dist/auth/components/index.mjs +0 -9
- package/dist/auth/components/index.mjs.map +0 -1
- package/dist/auth/hooks/index.d.mts +0 -13
- package/dist/auth/hooks/index.d.ts +0 -13
- package/dist/auth/hooks/index.js +0 -28
- package/dist/auth/hooks/index.js.map +0 -1
- package/dist/auth/hooks/index.mjs +0 -7
- package/dist/auth/hooks/index.mjs.map +0 -1
- package/dist/auth/index.d.mts +0 -21
- package/dist/auth/index.d.ts +0 -21
- package/dist/auth/index.js +0 -112
- package/dist/auth/index.js.map +0 -1
- package/dist/auth/index.mjs +0 -11
- package/dist/auth/index.mjs.map +0 -1
- package/dist/auth/rn/index.d.mts +0 -3133
- package/dist/auth/rn/index.d.ts +0 -3133
- package/dist/auth/rn/index.js +0 -684
- package/dist/auth/rn/index.js.map +0 -1
- package/dist/auth/rn/index.mjs +0 -663
- package/dist/auth/rn/index.mjs.map +0 -1
- package/dist/auth/schema/index.d.mts +0 -4
- package/dist/auth/schema/index.d.ts +0 -4
- package/dist/auth/schema/index.js +0 -49
- package/dist/auth/schema/index.js.map +0 -1
- package/dist/auth/schema/index.mjs +0 -4
- package/dist/auth/schema/index.mjs.map +0 -1
- package/dist/auth/services/index.d.mts +0 -1
- package/dist/auth/services/index.d.ts +0 -1
- package/dist/auth/services/index.js +0 -17
- package/dist/auth/services/index.js.map +0 -1
- package/dist/auth/services/index.mjs +0 -4
- package/dist/auth/services/index.mjs.map +0 -1
- package/dist/base-api-client-BpmcQt4Q.d.ts +0 -103
- package/dist/base-api-client-CFIhZK4C.d.mts +0 -277
- package/dist/base-api-client-CFIhZK4C.d.ts +0 -277
- package/dist/base-api-client-DXLsq2yz.d.mts +0 -103
- package/dist/chunk-7E3J7VAD.mjs +0 -3
- package/dist/chunk-7E3J7VAD.mjs.map +0 -1
- package/dist/chunk-B3CZ3HXJ.mjs +0 -126
- package/dist/chunk-B3CZ3HXJ.mjs.map +0 -1
- package/dist/chunk-FOQEQWX5.js +0 -4
- package/dist/chunk-FOQEQWX5.js.map +0 -1
- package/dist/chunk-G4NFB2QA.mjs +0 -212
- package/dist/chunk-G4NFB2QA.mjs.map +0 -1
- package/dist/chunk-G5HJGXGC.mjs +0 -39
- package/dist/chunk-G5HJGXGC.mjs.map +0 -1
- package/dist/chunk-GQZHGSRR.js.map +0 -1
- package/dist/chunk-GS7XLKET.js +0 -41
- package/dist/chunk-GS7XLKET.js.map +0 -1
- package/dist/chunk-IBWDBBX5.mjs.map +0 -1
- package/dist/chunk-MWSAH7ZG.mjs +0 -42
- package/dist/chunk-MWSAH7ZG.mjs.map +0 -1
- package/dist/chunk-MZOGYD4N.mjs +0 -186
- package/dist/chunk-MZOGYD4N.mjs.map +0 -1
- package/dist/chunk-QDUBO567.js +0 -1148
- package/dist/chunk-QDUBO567.js.map +0 -1
- package/dist/chunk-QP5N3ER6.js.map +0 -1
- package/dist/chunk-RWCD2CAD.mjs +0 -1132
- package/dist/chunk-RWCD2CAD.mjs.map +0 -1
- package/dist/chunk-S37OK2QG.js +0 -216
- package/dist/chunk-S37OK2QG.js.map +0 -1
- package/dist/chunk-SFDJNKWC.js +0 -22
- package/dist/chunk-SFDJNKWC.js.map +0 -1
- package/dist/chunk-TXMX6PZR.js +0 -190
- package/dist/chunk-TXMX6PZR.js.map +0 -1
- package/dist/chunk-VHN7PF5I.js +0 -20
- package/dist/chunk-VHN7PF5I.js.map +0 -1
- package/dist/chunk-XBZIS3MV.mjs +0 -13
- package/dist/chunk-XBZIS3MV.mjs.map +0 -1
- package/dist/chunk-XFOZ56FB.mjs +0 -20
- package/dist/chunk-XFOZ56FB.mjs.map +0 -1
- package/dist/chunk-Z23HAXHL.js +0 -136
- package/dist/chunk-Z23HAXHL.js.map +0 -1
- package/dist/index-BcjDRcKp.d.mts +0 -40
- package/dist/index-BlpXrrTy.d.ts +0 -40
- package/dist/session-BCXvGCnm.d.mts +0 -81
- package/dist/session-BCXvGCnm.d.ts +0 -81
- package/dist/types-C_W_CoUD.d.ts +0 -99
- package/dist/types-DCRvasyH.d.mts +0 -99
- package/dist/types.legacy-J-j-_ig_.d.mts +0 -25
- package/dist/types.legacy-J-j-_ig_.d.ts +0 -25
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React45 from 'react';
|
|
2
|
-
import React45__default, { useState, useRef, useCallback, useEffect, useMemo } from 'react';
|
|
2
|
+
import React45__default, { createContext, useState, useRef, useCallback, useEffect, useMemo, useContext } from 'react';
|
|
3
3
|
import { createWorker } from 'tesseract.js';
|
|
4
4
|
import { X, Check, Circle, ChevronRight, ChevronDown, ChevronUp, Upload, Loader2, FileText, Eraser, Download, MessageSquare, Send, Bot, User, RotateCcw, Save, AlertCircle, GripVertical, Settings, Eye, EyeOff, MoveUp, MoveDown, Trash2, Group, Shield, AlertTriangle, FlaskConical, LogOut, Meh, Frown, Smile, Type, Database, FileSpreadsheet } from 'lucide-react';
|
|
5
5
|
import { clsx } from 'clsx';
|
|
@@ -14,15 +14,12 @@ import Link from 'next/link';
|
|
|
14
14
|
import { useSensors, useSensor, PointerSensor, TouchSensor, KeyboardSensor, DndContext, closestCenter } from '@dnd-kit/core';
|
|
15
15
|
import { useSortable, sortableKeyboardCoordinates, SortableContext, rectSortingStrategy, arrayMove } from '@dnd-kit/sortable';
|
|
16
16
|
import { CSS } from '@dnd-kit/utilities';
|
|
17
|
-
import
|
|
18
|
-
import { sql, relations, eq } from 'drizzle-orm';
|
|
19
|
-
import 'better-auth';
|
|
20
|
-
import '@better-auth/drizzle-adapter';
|
|
21
|
-
import 'better-auth/plugins';
|
|
22
|
-
import 'better-auth/next-js';
|
|
17
|
+
import 'better-auth/react';
|
|
23
18
|
import * as THREE2 from 'three';
|
|
24
19
|
import { randomUUID } from 'crypto';
|
|
25
20
|
import * as XLSX from 'xlsx';
|
|
21
|
+
import { pgTable, timestamp, jsonb, text, integer } from 'drizzle-orm/pg-core';
|
|
22
|
+
import { eq } from 'drizzle-orm';
|
|
26
23
|
import { NextResponse } from 'next/server';
|
|
27
24
|
|
|
28
25
|
var __defProp = Object.defineProperty;
|
|
@@ -63,10 +60,10 @@ var ConsoleLoggerAdapter = class {
|
|
|
63
60
|
};
|
|
64
61
|
}
|
|
65
62
|
log(entry) {
|
|
66
|
-
const { level, message, timestamp:
|
|
63
|
+
const { level, message, timestamp: timestamp2, data, context, error } = entry;
|
|
67
64
|
let logMessage = "";
|
|
68
|
-
if (
|
|
69
|
-
logMessage += "[" + this.formatTimestamp(
|
|
65
|
+
if (timestamp2) {
|
|
66
|
+
logMessage += "[" + this.formatTimestamp(timestamp2) + "] ";
|
|
70
67
|
}
|
|
71
68
|
const levelName = this.getLevelName(level);
|
|
72
69
|
logMessage += levelName + ": ";
|
|
@@ -559,7 +556,7 @@ var useSentimentAnalysis = (options = {}) => {
|
|
|
559
556
|
result: null
|
|
560
557
|
});
|
|
561
558
|
const pipelineRef = useRef(null);
|
|
562
|
-
const analyze = useCallback(async (
|
|
559
|
+
const analyze = useCallback(async (text2) => {
|
|
563
560
|
setState((prev) => ({
|
|
564
561
|
...prev,
|
|
565
562
|
isProcessing: true,
|
|
@@ -606,12 +603,12 @@ var useSentimentAnalysis = (options = {}) => {
|
|
|
606
603
|
pipelineRef.current = await pipeline("sentiment-analysis", options.model || defaultModel);
|
|
607
604
|
}
|
|
608
605
|
setState((prev) => ({ ...prev, status: "analyzing" }));
|
|
609
|
-
const output = await pipelineRef.current(
|
|
606
|
+
const output = await pipelineRef.current(text2);
|
|
610
607
|
const resultData = output[0];
|
|
611
608
|
const label = resultData.label.toLowerCase();
|
|
612
609
|
let sentiment = "neutral";
|
|
613
610
|
const negativeKeywords = ["\u7D2F", "\u60E8", "\u7EDD\u671B", "\u96BE\u53D7", "\u4F24\u5FC3", "\u5DEE", "\u574F", "\u7CDF", "\u4E0D\u884C"];
|
|
614
|
-
const hasNegativeKeyword = negativeKeywords.some((k) =>
|
|
611
|
+
const hasNegativeKeyword = negativeKeywords.some((k) => text2.includes(k));
|
|
615
612
|
if (label.includes("positive") && !hasNegativeKeyword) {
|
|
616
613
|
sentiment = "positive";
|
|
617
614
|
} else if (label.includes("negative") || label.includes("0") || hasNegativeKeyword) {
|
|
@@ -643,12 +640,12 @@ var SentimentAnalyzer = ({
|
|
|
643
640
|
className = "",
|
|
644
641
|
placeholder = "\u8F93\u5165\u4E00\u6BB5\u4E2D\u6587\u6216\u82F1\u6587\uFF0C\u5206\u6790\u5176\u60C5\u611F\u503E\u5411..."
|
|
645
642
|
}) => {
|
|
646
|
-
const [
|
|
643
|
+
const [text2, setText] = useState("");
|
|
647
644
|
const { analyze, isProcessing, status, result, error } = useSentimentAnalysis();
|
|
648
645
|
const handleAnalyze = async () => {
|
|
649
|
-
if (!
|
|
646
|
+
if (!text2.trim() || isProcessing) return;
|
|
650
647
|
try {
|
|
651
|
-
const res = await analyze(
|
|
648
|
+
const res = await analyze(text2);
|
|
652
649
|
onResult?.(res);
|
|
653
650
|
} catch (err) {
|
|
654
651
|
console.error("Sentiment Analysis Error:", err);
|
|
@@ -679,7 +676,7 @@ var SentimentAnalyzer = ({
|
|
|
679
676
|
return /* @__PURE__ */ React45__default.createElement("div", { className: clsx("p-6 border rounded-xl bg-white dark:bg-gray-800 shadow-sm", className) }, /* @__PURE__ */ React45__default.createElement("div", { className: "flex items-center gap-2 mb-4 text-gray-700 dark:text-gray-300 font-medium" }, /* @__PURE__ */ React45__default.createElement(MessageSquare, { size: 20 }), /* @__PURE__ */ React45__default.createElement("span", null, "\u6587\u672C\u60C5\u611F\u5206\u6790")), /* @__PURE__ */ React45__default.createElement("div", { className: "relative" }, /* @__PURE__ */ React45__default.createElement(
|
|
680
677
|
"textarea",
|
|
681
678
|
{
|
|
682
|
-
value:
|
|
679
|
+
value: text2,
|
|
683
680
|
onChange: (e) => setText(e.target.value),
|
|
684
681
|
placeholder,
|
|
685
682
|
className: "w-full h-32 p-4 bg-gray-50 dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all outline-none resize-none text-gray-800 dark:text-gray-200",
|
|
@@ -689,7 +686,7 @@ var SentimentAnalyzer = ({
|
|
|
689
686
|
"button",
|
|
690
687
|
{
|
|
691
688
|
onClick: handleAnalyze,
|
|
692
|
-
disabled: !
|
|
689
|
+
disabled: !text2.trim() || isProcessing,
|
|
693
690
|
className: "absolute bottom-3 right-3 p-2 bg-blue-600 hover:bg-blue-700 disabled:bg-gray-400 text-white rounded-md transition-colors shadow-sm"
|
|
694
691
|
},
|
|
695
692
|
isProcessing ? /* @__PURE__ */ React45__default.createElement(Loader2, { className: "animate-spin", size: 18 }) : /* @__PURE__ */ React45__default.createElement(Send, { size: 18 })
|
|
@@ -877,13 +874,13 @@ var requestJson = async (options) => {
|
|
|
877
874
|
body: body ? JSON.stringify(body) : void 0,
|
|
878
875
|
signal: controller?.signal
|
|
879
876
|
});
|
|
880
|
-
const
|
|
877
|
+
const text2 = await response.text();
|
|
881
878
|
let data = null;
|
|
882
|
-
if (
|
|
879
|
+
if (text2) {
|
|
883
880
|
try {
|
|
884
|
-
data = JSON.parse(
|
|
881
|
+
data = JSON.parse(text2);
|
|
885
882
|
} catch {
|
|
886
|
-
data =
|
|
883
|
+
data = text2;
|
|
887
884
|
}
|
|
888
885
|
}
|
|
889
886
|
if (!response.ok) {
|
|
@@ -1344,20 +1341,20 @@ var japaneseUtils = {
|
|
|
1344
1341
|
/**
|
|
1345
1342
|
* 提取文本中的汉字
|
|
1346
1343
|
*/
|
|
1347
|
-
extractKanji(
|
|
1348
|
-
return
|
|
1344
|
+
extractKanji(text2) {
|
|
1345
|
+
return text2.match(/[\u4E00-\u9FAF]/g) || [];
|
|
1349
1346
|
},
|
|
1350
1347
|
/**
|
|
1351
1348
|
* 提取文本中的假名
|
|
1352
1349
|
*/
|
|
1353
|
-
extractKana(
|
|
1354
|
-
return
|
|
1350
|
+
extractKana(text2) {
|
|
1351
|
+
return text2.match(/[\u3040-\u309F\u30A0-\u30FF]/g) || [];
|
|
1355
1352
|
},
|
|
1356
1353
|
/**
|
|
1357
1354
|
* 清理文本,移除特殊字符但保留日语字符
|
|
1358
1355
|
*/
|
|
1359
|
-
cleanText(
|
|
1360
|
-
return
|
|
1356
|
+
cleanText(text2) {
|
|
1357
|
+
return text2.replace(/[^\u3040-\u309F\u30A0-\u30FF\u4E00-\u9FAF\w\s]/g, "");
|
|
1361
1358
|
}
|
|
1362
1359
|
};
|
|
1363
1360
|
|
|
@@ -1446,11 +1443,11 @@ var fileUtils = {
|
|
|
1446
1443
|
* 生成唯一文件名
|
|
1447
1444
|
*/
|
|
1448
1445
|
generateUniqueFileName(originalName) {
|
|
1449
|
-
const
|
|
1446
|
+
const timestamp2 = Date.now();
|
|
1450
1447
|
const random = Math.random().toString(36).substring(2, 15);
|
|
1451
1448
|
const extension = this.getFileExtension(originalName);
|
|
1452
1449
|
const baseName = originalName.replace("." + extension, "");
|
|
1453
|
-
return extension ? baseName + "_" +
|
|
1450
|
+
return extension ? baseName + "_" + timestamp2 + "_" + random + "." + extension : baseName + "_" + timestamp2 + "_" + random;
|
|
1454
1451
|
},
|
|
1455
1452
|
/**
|
|
1456
1453
|
* 验证文件名是否有效
|
|
@@ -1520,28 +1517,28 @@ var stringUtils = {
|
|
|
1520
1517
|
/**
|
|
1521
1518
|
* 截断文本
|
|
1522
1519
|
*/
|
|
1523
|
-
truncate(
|
|
1524
|
-
if (
|
|
1525
|
-
return
|
|
1520
|
+
truncate(text2, length, suffix = "...") {
|
|
1521
|
+
if (text2.length <= length) return text2;
|
|
1522
|
+
return text2.substring(0, length - suffix.length) + suffix;
|
|
1526
1523
|
},
|
|
1527
1524
|
/**
|
|
1528
1525
|
* 首字母大写
|
|
1529
1526
|
*/
|
|
1530
|
-
capitalize(
|
|
1531
|
-
if (!
|
|
1532
|
-
return
|
|
1527
|
+
capitalize(text2) {
|
|
1528
|
+
if (!text2) return "";
|
|
1529
|
+
return text2.charAt(0).toUpperCase() + text2.slice(1).toLowerCase();
|
|
1533
1530
|
},
|
|
1534
1531
|
/**
|
|
1535
1532
|
* 驼峰转下划线
|
|
1536
1533
|
*/
|
|
1537
|
-
camelToSnake(
|
|
1538
|
-
return
|
|
1534
|
+
camelToSnake(text2) {
|
|
1535
|
+
return text2.replace(/[A-Z]/g, (letter) => "_" + letter.toLowerCase());
|
|
1539
1536
|
},
|
|
1540
1537
|
/**
|
|
1541
1538
|
* 下划线转驼峰
|
|
1542
1539
|
*/
|
|
1543
|
-
snakeToCamel(
|
|
1544
|
-
return
|
|
1540
|
+
snakeToCamel(text2) {
|
|
1541
|
+
return text2.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
1545
1542
|
},
|
|
1546
1543
|
/**
|
|
1547
1544
|
* 生成随机字符串
|
|
@@ -4266,14 +4263,14 @@ var BubbleShooterBoard = ({ config: inputConfig, className }) => {
|
|
|
4266
4263
|
if (status !== "shooting") {
|
|
4267
4264
|
return;
|
|
4268
4265
|
}
|
|
4269
|
-
const step = (
|
|
4266
|
+
const step = (timestamp2) => {
|
|
4270
4267
|
if (statusRef.current !== "shooting") {
|
|
4271
4268
|
lastTsRef.current = 0;
|
|
4272
4269
|
return;
|
|
4273
4270
|
}
|
|
4274
|
-
const previousTs = lastTsRef.current ||
|
|
4275
|
-
const deltaSec = Math.min((
|
|
4276
|
-
lastTsRef.current =
|
|
4271
|
+
const previousTs = lastTsRef.current || timestamp2;
|
|
4272
|
+
const deltaSec = Math.min((timestamp2 - previousTs) / 1e3, 0.05);
|
|
4273
|
+
lastTsRef.current = timestamp2;
|
|
4277
4274
|
let shouldContinue = true;
|
|
4278
4275
|
setProjectile((prev) => {
|
|
4279
4276
|
if (!prev || statusRef.current !== "shooting") {
|
|
@@ -5580,7 +5577,7 @@ function resolveUploadFolderPath(options) {
|
|
|
5580
5577
|
}
|
|
5581
5578
|
function buildModuleUploadPath(options) {
|
|
5582
5579
|
const extension = options.fileName.split(".").pop()?.toLowerCase() || "jpg";
|
|
5583
|
-
const
|
|
5580
|
+
const timestamp2 = Date.now();
|
|
5584
5581
|
const randomId2 = Math.random().toString(36).slice(2, 11);
|
|
5585
5582
|
const segments = [
|
|
5586
5583
|
options.moduleId,
|
|
@@ -5588,7 +5585,7 @@ function buildModuleUploadPath(options) {
|
|
|
5588
5585
|
options.subfolder
|
|
5589
5586
|
].filter(Boolean);
|
|
5590
5587
|
const base = segments.length > 0 ? segments.join("/") : options.moduleId;
|
|
5591
|
-
return `${base}/${
|
|
5588
|
+
return `${base}/${timestamp2}_${randomId2}.${extension}`;
|
|
5592
5589
|
}
|
|
5593
5590
|
|
|
5594
5591
|
// src/ossFile/shared/httpClient.ts
|
|
@@ -7114,12 +7111,7 @@ var UniversalExportButton = ({
|
|
|
7114
7111
|
// src/common/auth/index.ts
|
|
7115
7112
|
var auth_exports = {};
|
|
7116
7113
|
__export(auth_exports, {
|
|
7117
|
-
API_ROUTES: () => API_ROUTES,
|
|
7118
|
-
BaseApiClient: () => BaseApiClient,
|
|
7119
|
-
STORAGE_KEYS: () => STORAGE_KEYS,
|
|
7120
7114
|
createSa2kitAuthClient: () => createSa2kitAuthClient,
|
|
7121
|
-
useAuth: () => useAuth,
|
|
7122
|
-
useAuthForm: () => useAuthForm,
|
|
7123
7115
|
useSession: () => useSession
|
|
7124
7116
|
});
|
|
7125
7117
|
function buildSa2kitAuthClient(options) {
|
|
@@ -7133,395 +7125,10 @@ function createSa2kitAuthClient(options) {
|
|
|
7133
7125
|
return buildSa2kitAuthClient(options);
|
|
7134
7126
|
}
|
|
7135
7127
|
|
|
7136
|
-
// src/common/auth/client/types.ts
|
|
7137
|
-
var STORAGE_KEYS = {
|
|
7138
|
-
AUTH_TOKEN: "auth_token",
|
|
7139
|
-
USER_DATA: "user_data"
|
|
7140
|
-
};
|
|
7141
|
-
var API_ROUTES = {
|
|
7142
|
-
AUTH: {
|
|
7143
|
-
LOGIN: "/auth/login",
|
|
7144
|
-
REGISTER: "/auth/register",
|
|
7145
|
-
LOGOUT: "/auth/logout",
|
|
7146
|
-
ME: "/auth/me"
|
|
7147
|
-
}
|
|
7148
|
-
};
|
|
7149
|
-
|
|
7150
|
-
// src/common/auth/client/base-api-client.ts
|
|
7151
|
-
var BaseApiClient = class {
|
|
7152
|
-
constructor(storage, request, baseUrl) {
|
|
7153
|
-
this.storage = storage;
|
|
7154
|
-
this.request = request;
|
|
7155
|
-
this.baseUrl = baseUrl;
|
|
7156
|
-
this.token = null;
|
|
7157
|
-
this.user = null;
|
|
7158
|
-
}
|
|
7159
|
-
/**
|
|
7160
|
-
* 初始化 - 从存储中加载 token 和用户信息
|
|
7161
|
-
*/
|
|
7162
|
-
async init() {
|
|
7163
|
-
try {
|
|
7164
|
-
this.token = await this.storage.getItem(STORAGE_KEYS.AUTH_TOKEN);
|
|
7165
|
-
const userData = await this.storage.getItem(STORAGE_KEYS.USER_DATA);
|
|
7166
|
-
if (userData) {
|
|
7167
|
-
this.user = JSON.parse(userData);
|
|
7168
|
-
}
|
|
7169
|
-
} catch (error) {
|
|
7170
|
-
console.error("Failed to load auth data:", error);
|
|
7171
|
-
}
|
|
7172
|
-
}
|
|
7173
|
-
/**
|
|
7174
|
-
* 设置认证 token
|
|
7175
|
-
*/
|
|
7176
|
-
async setToken(token) {
|
|
7177
|
-
this.token = token;
|
|
7178
|
-
if (token) {
|
|
7179
|
-
await this.storage.setItem(STORAGE_KEYS.AUTH_TOKEN, token);
|
|
7180
|
-
} else {
|
|
7181
|
-
await this.storage.removeItem(STORAGE_KEYS.AUTH_TOKEN);
|
|
7182
|
-
}
|
|
7183
|
-
}
|
|
7184
|
-
/**
|
|
7185
|
-
* 设置用户信息
|
|
7186
|
-
*/
|
|
7187
|
-
async setUser(user2) {
|
|
7188
|
-
this.user = user2;
|
|
7189
|
-
if (user2) {
|
|
7190
|
-
await this.storage.setItem(STORAGE_KEYS.USER_DATA, JSON.stringify(user2));
|
|
7191
|
-
} else {
|
|
7192
|
-
await this.storage.removeItem(STORAGE_KEYS.USER_DATA);
|
|
7193
|
-
}
|
|
7194
|
-
}
|
|
7195
|
-
/**
|
|
7196
|
-
* 获取当前 token
|
|
7197
|
-
*/
|
|
7198
|
-
getToken() {
|
|
7199
|
-
return this.token;
|
|
7200
|
-
}
|
|
7201
|
-
/**
|
|
7202
|
-
* 获取当前用户
|
|
7203
|
-
*/
|
|
7204
|
-
getUser() {
|
|
7205
|
-
return this.user;
|
|
7206
|
-
}
|
|
7207
|
-
/**
|
|
7208
|
-
* 检查是否已登录
|
|
7209
|
-
*/
|
|
7210
|
-
async isAuthenticated() {
|
|
7211
|
-
return !!this.token;
|
|
7212
|
-
}
|
|
7213
|
-
/**
|
|
7214
|
-
* 清除用户数据
|
|
7215
|
-
*/
|
|
7216
|
-
async clearUserData() {
|
|
7217
|
-
await this.storage.removeItem(STORAGE_KEYS.AUTH_TOKEN);
|
|
7218
|
-
await this.storage.removeItem(STORAGE_KEYS.USER_DATA);
|
|
7219
|
-
this.token = null;
|
|
7220
|
-
this.user = null;
|
|
7221
|
-
}
|
|
7222
|
-
/**
|
|
7223
|
-
* 发送请求的通用方法
|
|
7224
|
-
*/
|
|
7225
|
-
async sendRequest(config) {
|
|
7226
|
-
try {
|
|
7227
|
-
const headers = {
|
|
7228
|
-
"Content-Type": "application/json",
|
|
7229
|
-
...config.headers || {}
|
|
7230
|
-
};
|
|
7231
|
-
if (this.token) {
|
|
7232
|
-
headers["Authorization"] = "Bearer " + this.token;
|
|
7233
|
-
}
|
|
7234
|
-
const response = await this.request.request({
|
|
7235
|
-
...config,
|
|
7236
|
-
url: this.baseUrl + config.url,
|
|
7237
|
-
headers
|
|
7238
|
-
});
|
|
7239
|
-
return response;
|
|
7240
|
-
} catch (error) {
|
|
7241
|
-
console.error("API request error:", error);
|
|
7242
|
-
return {
|
|
7243
|
-
success: false,
|
|
7244
|
-
error: error instanceof Error ? error.message : "\u7F51\u7EDC\u9519\u8BEF\uFF0C\u8BF7\u91CD\u8BD5"
|
|
7245
|
-
};
|
|
7246
|
-
}
|
|
7247
|
-
}
|
|
7248
|
-
// ==================== 认证相关 API ====================
|
|
7249
|
-
/**
|
|
7250
|
-
* 用户注册
|
|
7251
|
-
*/
|
|
7252
|
-
async register(email, password, username) {
|
|
7253
|
-
const response = await this.sendRequest({
|
|
7254
|
-
url: API_ROUTES.AUTH.REGISTER,
|
|
7255
|
-
method: "POST",
|
|
7256
|
-
body: { email, password, username }
|
|
7257
|
-
});
|
|
7258
|
-
if (response.success && response.data) {
|
|
7259
|
-
await this.setToken(response.data.token);
|
|
7260
|
-
await this.setUser(response.data.user);
|
|
7261
|
-
}
|
|
7262
|
-
return response;
|
|
7263
|
-
}
|
|
7264
|
-
/**
|
|
7265
|
-
* 用户登录
|
|
7266
|
-
*/
|
|
7267
|
-
async login(email, password) {
|
|
7268
|
-
const response = await this.sendRequest({
|
|
7269
|
-
url: API_ROUTES.AUTH.LOGIN,
|
|
7270
|
-
method: "POST",
|
|
7271
|
-
body: { email, password }
|
|
7272
|
-
});
|
|
7273
|
-
if (response.success && response.data) {
|
|
7274
|
-
await this.setToken(response.data.token);
|
|
7275
|
-
await this.setUser(response.data.user);
|
|
7276
|
-
if (typeof window !== "undefined") {
|
|
7277
|
-
window.dispatchEvent(
|
|
7278
|
-
new CustomEvent("user_login_success", {
|
|
7279
|
-
detail: {
|
|
7280
|
-
userId: response.data.user.id,
|
|
7281
|
-
email: response.data.user.email,
|
|
7282
|
-
role: response.data.user.role
|
|
7283
|
-
}
|
|
7284
|
-
})
|
|
7285
|
-
);
|
|
7286
|
-
}
|
|
7287
|
-
}
|
|
7288
|
-
return response;
|
|
7289
|
-
}
|
|
7290
|
-
/**
|
|
7291
|
-
* 用户退出登录
|
|
7292
|
-
*/
|
|
7293
|
-
async logout() {
|
|
7294
|
-
await this.sendRequest({
|
|
7295
|
-
url: API_ROUTES.AUTH.LOGOUT,
|
|
7296
|
-
method: "POST"
|
|
7297
|
-
});
|
|
7298
|
-
await this.clearUserData();
|
|
7299
|
-
}
|
|
7300
|
-
/**
|
|
7301
|
-
* 获取当前用户信息
|
|
7302
|
-
*/
|
|
7303
|
-
async getCurrentUser() {
|
|
7304
|
-
const response = await this.sendRequest({
|
|
7305
|
-
url: API_ROUTES.AUTH.ME,
|
|
7306
|
-
method: "GET"
|
|
7307
|
-
});
|
|
7308
|
-
if (response.success && response.data) {
|
|
7309
|
-
const userData = response.data.user || response.data;
|
|
7310
|
-
await this.setUser(userData);
|
|
7311
|
-
return {
|
|
7312
|
-
...response,
|
|
7313
|
-
data: userData
|
|
7314
|
-
};
|
|
7315
|
-
}
|
|
7316
|
-
return response;
|
|
7317
|
-
}
|
|
7318
|
-
// ==================== 通用方法 ====================
|
|
7319
|
-
/**
|
|
7320
|
-
* 发送 GET 请求
|
|
7321
|
-
*/
|
|
7322
|
-
async get(url, params) {
|
|
7323
|
-
return this.sendRequest({ url, method: "GET", params });
|
|
7324
|
-
}
|
|
7325
|
-
/**
|
|
7326
|
-
* 发送 POST 请求
|
|
7327
|
-
*/
|
|
7328
|
-
async post(url, body) {
|
|
7329
|
-
return this.sendRequest({ url, method: "POST", body });
|
|
7330
|
-
}
|
|
7331
|
-
/**
|
|
7332
|
-
* 发送 PUT 请求
|
|
7333
|
-
*/
|
|
7334
|
-
async put(url, body) {
|
|
7335
|
-
return this.sendRequest({ url, method: "PUT", body });
|
|
7336
|
-
}
|
|
7337
|
-
/**
|
|
7338
|
-
* 发送 DELETE 请求
|
|
7339
|
-
*/
|
|
7340
|
-
async delete(url) {
|
|
7341
|
-
return this.sendRequest({ url, method: "DELETE" });
|
|
7342
|
-
}
|
|
7343
|
-
};
|
|
7344
|
-
|
|
7345
7128
|
// src/common/auth/hooks/useSession.ts
|
|
7346
7129
|
function useSession(authClient) {
|
|
7347
7130
|
return authClient.useSession();
|
|
7348
7131
|
}
|
|
7349
|
-
function useAuth(apiClient) {
|
|
7350
|
-
const [user2, setUser] = useState(null);
|
|
7351
|
-
const [isLoggedIn, setIsLoggedIn] = useState(false);
|
|
7352
|
-
const [loading, setLoading] = useState(false);
|
|
7353
|
-
const [checkingAuth, setCheckingAuth] = useState(true);
|
|
7354
|
-
const [error, setError] = useState(null);
|
|
7355
|
-
const checkAuthStatus = useCallback(async () => {
|
|
7356
|
-
try {
|
|
7357
|
-
setCheckingAuth(true);
|
|
7358
|
-
setError(null);
|
|
7359
|
-
const isAuth = await apiClient.isAuthenticated();
|
|
7360
|
-
if (isAuth) {
|
|
7361
|
-
const response = await apiClient.getCurrentUser();
|
|
7362
|
-
if (response.success && response.data) {
|
|
7363
|
-
setUser(response.data);
|
|
7364
|
-
setIsLoggedIn(true);
|
|
7365
|
-
} else {
|
|
7366
|
-
await apiClient.clearUserData();
|
|
7367
|
-
setUser(null);
|
|
7368
|
-
setIsLoggedIn(false);
|
|
7369
|
-
}
|
|
7370
|
-
} else {
|
|
7371
|
-
setUser(null);
|
|
7372
|
-
setIsLoggedIn(false);
|
|
7373
|
-
}
|
|
7374
|
-
} catch (err) {
|
|
7375
|
-
console.error("\u68C0\u67E5\u767B\u5F55\u72B6\u6001\u5931\u8D25:", err);
|
|
7376
|
-
setError(err instanceof Error ? err.message : "\u68C0\u67E5\u767B\u5F55\u72B6\u6001\u5931\u8D25");
|
|
7377
|
-
setUser(null);
|
|
7378
|
-
setIsLoggedIn(false);
|
|
7379
|
-
} finally {
|
|
7380
|
-
setCheckingAuth(false);
|
|
7381
|
-
}
|
|
7382
|
-
}, [apiClient]);
|
|
7383
|
-
const login = useCallback(
|
|
7384
|
-
async (email, password) => {
|
|
7385
|
-
setLoading(true);
|
|
7386
|
-
setError(null);
|
|
7387
|
-
try {
|
|
7388
|
-
const response = await apiClient.login(email, password);
|
|
7389
|
-
if (response.success && response.data) {
|
|
7390
|
-
setUser(response.data.user);
|
|
7391
|
-
setIsLoggedIn(true);
|
|
7392
|
-
return { success: true };
|
|
7393
|
-
} else {
|
|
7394
|
-
const errorMsg = response.error || "\u767B\u5F55\u5931\u8D25";
|
|
7395
|
-
setError(errorMsg);
|
|
7396
|
-
return { success: false, error: errorMsg };
|
|
7397
|
-
}
|
|
7398
|
-
} catch (err) {
|
|
7399
|
-
const errorMsg = err instanceof Error ? err.message : "\u767B\u5F55\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5";
|
|
7400
|
-
setError(errorMsg);
|
|
7401
|
-
return { success: false, error: errorMsg };
|
|
7402
|
-
} finally {
|
|
7403
|
-
setLoading(false);
|
|
7404
|
-
}
|
|
7405
|
-
},
|
|
7406
|
-
[apiClient]
|
|
7407
|
-
);
|
|
7408
|
-
const register = useCallback(
|
|
7409
|
-
async (email, password, username) => {
|
|
7410
|
-
setLoading(true);
|
|
7411
|
-
setError(null);
|
|
7412
|
-
try {
|
|
7413
|
-
const response = await apiClient.register(email, password, username);
|
|
7414
|
-
if (response.success && response.data) {
|
|
7415
|
-
setUser(response.data.user);
|
|
7416
|
-
setIsLoggedIn(true);
|
|
7417
|
-
return { success: true };
|
|
7418
|
-
} else {
|
|
7419
|
-
const errorMsg = response.error || "\u6CE8\u518C\u5931\u8D25";
|
|
7420
|
-
setError(errorMsg);
|
|
7421
|
-
return { success: false, error: errorMsg };
|
|
7422
|
-
}
|
|
7423
|
-
} catch (err) {
|
|
7424
|
-
const errorMsg = err instanceof Error ? err.message : "\u6CE8\u518C\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5";
|
|
7425
|
-
setError(errorMsg);
|
|
7426
|
-
return { success: false, error: errorMsg };
|
|
7427
|
-
} finally {
|
|
7428
|
-
setLoading(false);
|
|
7429
|
-
}
|
|
7430
|
-
},
|
|
7431
|
-
[apiClient]
|
|
7432
|
-
);
|
|
7433
|
-
const logout = useCallback(async () => {
|
|
7434
|
-
setLoading(true);
|
|
7435
|
-
setError(null);
|
|
7436
|
-
try {
|
|
7437
|
-
await apiClient.logout();
|
|
7438
|
-
setUser(null);
|
|
7439
|
-
setIsLoggedIn(false);
|
|
7440
|
-
} catch (err) {
|
|
7441
|
-
console.error("\u767B\u51FA\u5931\u8D25:", err);
|
|
7442
|
-
setError(err instanceof Error ? err.message : "\u767B\u51FA\u5931\u8D25");
|
|
7443
|
-
setUser(null);
|
|
7444
|
-
setIsLoggedIn(false);
|
|
7445
|
-
} finally {
|
|
7446
|
-
setLoading(false);
|
|
7447
|
-
}
|
|
7448
|
-
}, [apiClient]);
|
|
7449
|
-
const clearError = useCallback(() => {
|
|
7450
|
-
setError(null);
|
|
7451
|
-
}, []);
|
|
7452
|
-
useEffect(() => {
|
|
7453
|
-
checkAuthStatus();
|
|
7454
|
-
}, [checkAuthStatus]);
|
|
7455
|
-
return {
|
|
7456
|
-
// 状态
|
|
7457
|
-
user: user2,
|
|
7458
|
-
isLoggedIn,
|
|
7459
|
-
loading,
|
|
7460
|
-
checkingAuth,
|
|
7461
|
-
error,
|
|
7462
|
-
// 操作方法
|
|
7463
|
-
login,
|
|
7464
|
-
register,
|
|
7465
|
-
logout,
|
|
7466
|
-
refresh: checkAuthStatus,
|
|
7467
|
-
clearError
|
|
7468
|
-
};
|
|
7469
|
-
}
|
|
7470
|
-
function useAuthForm(initialValues) {
|
|
7471
|
-
const [values, setValues] = useState(initialValues);
|
|
7472
|
-
const [errors, setErrors] = useState({});
|
|
7473
|
-
const [touched, setTouched] = useState({});
|
|
7474
|
-
const handleChange = useCallback(
|
|
7475
|
-
(field, value) => {
|
|
7476
|
-
setValues((prev) => ({ ...prev, [field]: value }));
|
|
7477
|
-
if (errors[field]) {
|
|
7478
|
-
setErrors((prev) => {
|
|
7479
|
-
const newErrors = { ...prev };
|
|
7480
|
-
delete newErrors[field];
|
|
7481
|
-
return newErrors;
|
|
7482
|
-
});
|
|
7483
|
-
}
|
|
7484
|
-
},
|
|
7485
|
-
[errors]
|
|
7486
|
-
);
|
|
7487
|
-
const handleBlur = useCallback((field) => {
|
|
7488
|
-
setTouched((prev) => ({ ...prev, [field]: true }));
|
|
7489
|
-
}, []);
|
|
7490
|
-
const validate = useCallback(
|
|
7491
|
-
(validationRules) => {
|
|
7492
|
-
const newErrors = {};
|
|
7493
|
-
Object.keys(validationRules).forEach((key) => {
|
|
7494
|
-
const field = key;
|
|
7495
|
-
const rule = validationRules[field];
|
|
7496
|
-
if (rule) {
|
|
7497
|
-
const error = rule(values[field]);
|
|
7498
|
-
if (error) {
|
|
7499
|
-
newErrors[field] = error;
|
|
7500
|
-
}
|
|
7501
|
-
}
|
|
7502
|
-
});
|
|
7503
|
-
setErrors(newErrors);
|
|
7504
|
-
return Object.keys(newErrors).length === 0;
|
|
7505
|
-
},
|
|
7506
|
-
[values]
|
|
7507
|
-
);
|
|
7508
|
-
const reset = useCallback(() => {
|
|
7509
|
-
setValues(initialValues);
|
|
7510
|
-
setErrors({});
|
|
7511
|
-
setTouched({});
|
|
7512
|
-
}, [initialValues]);
|
|
7513
|
-
return {
|
|
7514
|
-
values,
|
|
7515
|
-
errors,
|
|
7516
|
-
touched,
|
|
7517
|
-
handleChange,
|
|
7518
|
-
handleBlur,
|
|
7519
|
-
validate,
|
|
7520
|
-
reset,
|
|
7521
|
-
setValues,
|
|
7522
|
-
setErrors
|
|
7523
|
-
};
|
|
7524
|
-
}
|
|
7525
7132
|
|
|
7526
7133
|
// src/common/platform/index.ts
|
|
7527
7134
|
var platform_exports = {};
|
|
@@ -9310,9 +8917,9 @@ function mergeEventProperties(baseProperties, ...additionalProperties) {
|
|
|
9310
8917
|
return Object.assign({}, baseProperties, ...additionalProperties);
|
|
9311
8918
|
}
|
|
9312
8919
|
function generateUniqueId(prefix = "") {
|
|
9313
|
-
const
|
|
8920
|
+
const timestamp2 = Date.now();
|
|
9314
8921
|
const random = Math.random().toString(36).substring(2, 15);
|
|
9315
|
-
return prefix ? prefix + "_" +
|
|
8922
|
+
return prefix ? prefix + "_" + timestamp2 + "_" + random : timestamp2 + "_" + random;
|
|
9316
8923
|
}
|
|
9317
8924
|
function isMobile() {
|
|
9318
8925
|
if (typeof navigator === "undefined") return false;
|
|
@@ -9321,8 +8928,8 @@ function isMobile() {
|
|
|
9321
8928
|
function isDevelopment() {
|
|
9322
8929
|
return process.env.NODE_ENV === "development";
|
|
9323
8930
|
}
|
|
9324
|
-
function formatTimestamp(
|
|
9325
|
-
const date = new Date(
|
|
8931
|
+
function formatTimestamp(timestamp2, format = "datetime") {
|
|
8932
|
+
const date = new Date(timestamp2);
|
|
9326
8933
|
switch (format) {
|
|
9327
8934
|
case "date":
|
|
9328
8935
|
return date.toLocaleDateString();
|
|
@@ -9959,9 +9566,9 @@ var MobileDeviceAdapter = class {
|
|
|
9959
9566
|
}
|
|
9960
9567
|
}
|
|
9961
9568
|
async generateDeviceId() {
|
|
9962
|
-
const
|
|
9569
|
+
const timestamp2 = Date.now();
|
|
9963
9570
|
const random = Math.random().toString(36).substring(2, 15);
|
|
9964
|
-
return "mobile_" +
|
|
9571
|
+
return "mobile_" + timestamp2 + "_" + random;
|
|
9965
9572
|
}
|
|
9966
9573
|
getDefaultDeviceInfo() {
|
|
9967
9574
|
return {
|
|
@@ -10141,9 +9748,9 @@ var MiniappDeviceAdapter = class {
|
|
|
10141
9748
|
}
|
|
10142
9749
|
}
|
|
10143
9750
|
async generateDeviceId() {
|
|
10144
|
-
const
|
|
9751
|
+
const timestamp2 = Date.now();
|
|
10145
9752
|
const random = Math.random().toString(36).substring(2, 15);
|
|
10146
|
-
return "miniapp_" +
|
|
9753
|
+
return "miniapp_" + timestamp2 + "_" + random;
|
|
10147
9754
|
}
|
|
10148
9755
|
getDefaultDeviceInfo() {
|
|
10149
9756
|
return {
|
|
@@ -10375,8 +9982,8 @@ var EventList = ({
|
|
|
10375
9982
|
};
|
|
10376
9983
|
return colors[eventType] || "bg-gray-100 text-gray-800";
|
|
10377
9984
|
};
|
|
10378
|
-
const formatTimestamp2 = (
|
|
10379
|
-
const date = new Date(
|
|
9985
|
+
const formatTimestamp2 = (timestamp2) => {
|
|
9986
|
+
const date = new Date(timestamp2);
|
|
10380
9987
|
const now = /* @__PURE__ */ new Date();
|
|
10381
9988
|
const diff = now.getTime() - date.getTime();
|
|
10382
9989
|
const minutes = Math.floor(diff / 6e4);
|
|
@@ -11130,7 +10737,7 @@ function invalidateAllConfigs(apiBaseUrl = "") {
|
|
|
11130
10737
|
// src/api/index.ts
|
|
11131
10738
|
var api_exports = {};
|
|
11132
10739
|
__export(api_exports, {
|
|
11133
|
-
BaseApiClient: () =>
|
|
10740
|
+
BaseApiClient: () => BaseApiClient,
|
|
11134
10741
|
DEFAULT_API_ROUTES: () => DEFAULT_API_ROUTES,
|
|
11135
10742
|
DEFAULT_STORAGE_KEYS: () => DEFAULT_STORAGE_KEYS
|
|
11136
10743
|
});
|
|
@@ -11157,7 +10764,7 @@ var DEFAULT_API_ROUTES = {
|
|
|
11157
10764
|
};
|
|
11158
10765
|
|
|
11159
10766
|
// src/api/BaseApiClient.ts
|
|
11160
|
-
var
|
|
10767
|
+
var BaseApiClient = class {
|
|
11161
10768
|
constructor(config) {
|
|
11162
10769
|
this.token = null;
|
|
11163
10770
|
this.user = null;
|
|
@@ -11209,10 +10816,10 @@ var BaseApiClient2 = class {
|
|
|
11209
10816
|
/**
|
|
11210
10817
|
* 设置用户信息
|
|
11211
10818
|
*/
|
|
11212
|
-
async setUser(
|
|
11213
|
-
this.user =
|
|
11214
|
-
if (
|
|
11215
|
-
await this.storage.setItem(this.storageKeys.USER_DATA, JSON.stringify(
|
|
10819
|
+
async setUser(user) {
|
|
10820
|
+
this.user = user;
|
|
10821
|
+
if (user) {
|
|
10822
|
+
await this.storage.setItem(this.storageKeys.USER_DATA, JSON.stringify(user));
|
|
11216
10823
|
} else {
|
|
11217
10824
|
await this.storage.removeItem(this.storageKeys.USER_DATA);
|
|
11218
10825
|
}
|
|
@@ -12924,82 +12531,26 @@ var DraggableExperimentGrid = ({
|
|
|
12924
12531
|
)
|
|
12925
12532
|
));
|
|
12926
12533
|
};
|
|
12927
|
-
|
|
12928
|
-
|
|
12929
|
-
|
|
12930
|
-
|
|
12931
|
-
|
|
12932
|
-
|
|
12933
|
-
|
|
12934
|
-
|
|
12935
|
-
|
|
12936
|
-
|
|
12937
|
-
|
|
12938
|
-
|
|
12939
|
-
});
|
|
12940
|
-
var session = pgTable("session", {
|
|
12941
|
-
id: text("id").primaryKey().notNull(),
|
|
12942
|
-
userId: text("userId").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
12943
|
-
token: text("token").notNull(),
|
|
12944
|
-
expiresAt: timestamp("expiresAt", { precision: 3, mode: "date" }).notNull(),
|
|
12945
|
-
ipAddress: text("ipAddress"),
|
|
12946
|
-
userAgent: text("userAgent"),
|
|
12947
|
-
createdAt: timestamp("createdAt", { precision: 3, mode: "date" }).default(sql`CURRENT_TIMESTAMP`).notNull(),
|
|
12948
|
-
updatedAt: timestamp("updatedAt", { precision: 3, mode: "date" }).default(sql`CURRENT_TIMESTAMP`).notNull()
|
|
12949
|
-
});
|
|
12950
|
-
var account = pgTable("account", {
|
|
12951
|
-
id: text("id").primaryKey().notNull(),
|
|
12952
|
-
accountId: text("accountId").notNull(),
|
|
12953
|
-
providerId: text("providerId").notNull(),
|
|
12954
|
-
userId: text("userId").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
12955
|
-
accessToken: text("accessToken"),
|
|
12956
|
-
refreshToken: text("refreshToken"),
|
|
12957
|
-
idToken: text("idToken"),
|
|
12958
|
-
accessTokenExpiresAt: timestamp("accessTokenExpiresAt", { precision: 3, mode: "date" }),
|
|
12959
|
-
refreshTokenExpiresAt: timestamp("refreshTokenExpiresAt", { precision: 3, mode: "date" }),
|
|
12960
|
-
scope: text("scope"),
|
|
12961
|
-
password: text("password"),
|
|
12962
|
-
createdAt: timestamp("createdAt", { precision: 3, mode: "date" }).default(sql`CURRENT_TIMESTAMP`).notNull(),
|
|
12963
|
-
updatedAt: timestamp("updatedAt", { precision: 3, mode: "date" }).default(sql`CURRENT_TIMESTAMP`).notNull()
|
|
12964
|
-
});
|
|
12965
|
-
pgTable("verification", {
|
|
12966
|
-
id: text("id").primaryKey().notNull(),
|
|
12967
|
-
identifier: text("identifier").notNull(),
|
|
12968
|
-
value: text("value").notNull(),
|
|
12969
|
-
expiresAt: timestamp("expiresAt", { precision: 3, mode: "date" }).notNull(),
|
|
12970
|
-
createdAt: timestamp("createdAt", { precision: 3, mode: "date" }).default(sql`CURRENT_TIMESTAMP`).notNull(),
|
|
12971
|
-
updatedAt: timestamp("updatedAt", { precision: 3, mode: "date" }).default(sql`CURRENT_TIMESTAMP`).notNull()
|
|
12972
|
-
});
|
|
12973
|
-
relations(user, ({ many }) => ({
|
|
12974
|
-
sessions: many(session),
|
|
12975
|
-
accounts: many(account)
|
|
12976
|
-
}));
|
|
12977
|
-
relations(session, ({ one }) => ({
|
|
12978
|
-
user: one(user, {
|
|
12979
|
-
fields: [session.userId],
|
|
12980
|
-
references: [user.id]
|
|
12981
|
-
})
|
|
12982
|
-
}));
|
|
12983
|
-
relations(account, ({ one }) => ({
|
|
12984
|
-
user: one(user, {
|
|
12985
|
-
fields: [account.userId],
|
|
12986
|
-
references: [user.id]
|
|
12987
|
-
})
|
|
12988
|
-
}));
|
|
12989
|
-
var PermissionGuard = ({
|
|
12990
|
-
apiClient,
|
|
12991
|
-
children,
|
|
12992
|
-
fallback
|
|
12993
|
-
}) => {
|
|
12994
|
-
const { user: user2, isLoggedIn } = useAuth(apiClient);
|
|
12534
|
+
|
|
12535
|
+
// src/common/auth/context/AuthProvider.tsx
|
|
12536
|
+
var AuthContext = createContext(null);
|
|
12537
|
+
function useAuthContext() {
|
|
12538
|
+
const ctx = useContext(AuthContext);
|
|
12539
|
+
if (!ctx) {
|
|
12540
|
+
throw new Error("useAuthContext \u5FC5\u987B\u5728 AuthProvider \u5185\u4F7F\u7528");
|
|
12541
|
+
}
|
|
12542
|
+
return ctx;
|
|
12543
|
+
}
|
|
12544
|
+
var PermissionGuard = ({ children, fallback }) => {
|
|
12545
|
+
const { user, isAuthenticated } = useAuthContext();
|
|
12995
12546
|
const hasPermission = () => {
|
|
12996
|
-
if (!
|
|
12547
|
+
if (!isAuthenticated || !user) {
|
|
12997
12548
|
return false;
|
|
12998
12549
|
}
|
|
12999
12550
|
return true;
|
|
13000
12551
|
};
|
|
13001
12552
|
if (!hasPermission()) {
|
|
13002
|
-
return fallback
|
|
12553
|
+
return fallback ?? /* @__PURE__ */ React45__default.createElement("div", { className: "min-h-screen bg-gray-50 flex items-center justify-center" }, /* @__PURE__ */ React45__default.createElement("div", { className: "max-w-md w-full bg-white rounded-lg shadow-lg p-8 text-center" }, /* @__PURE__ */ React45__default.createElement("div", { className: "flex items-center justify-center mb-4" }, /* @__PURE__ */ React45__default.createElement(Shield, { className: "w-12 h-12 text-red-500" })), /* @__PURE__ */ React45__default.createElement("h2", { className: "text-xl font-semibold text-gray-900 mb-2" }, "\u9700\u8981\u767B\u5F55"), /* @__PURE__ */ React45__default.createElement("p", { className: "text-gray-600 mb-4" }, "\u8BF7\u5148\u767B\u5F55\u4EE5\u8BBF\u95EE\u5B9E\u9A8C\u7530\u529F\u80FD\u3002"), /* @__PURE__ */ React45__default.createElement("div", { className: "flex items-center justify-center text-sm text-gray-500 mb-4" }, /* @__PURE__ */ React45__default.createElement(AlertTriangle, { className: "w-4 h-4 mr-1" }), "\u5B9E\u9A8C\u7530\u5BF9\u6240\u6709\u6CE8\u518C\u7528\u6237\u5F00\u653E"), /* @__PURE__ */ React45__default.createElement(
|
|
13003
12554
|
"button",
|
|
13004
12555
|
{
|
|
13005
12556
|
onClick: () => window.history.back(),
|
|
@@ -13010,20 +12561,20 @@ var PermissionGuard = ({
|
|
|
13010
12561
|
}
|
|
13011
12562
|
return /* @__PURE__ */ React45__default.createElement(React45__default.Fragment, null, children);
|
|
13012
12563
|
};
|
|
13013
|
-
var UserInfoBar = (
|
|
13014
|
-
const { user
|
|
12564
|
+
var UserInfoBar = () => {
|
|
12565
|
+
const { user, signOut, isAuthenticated } = useAuthContext();
|
|
13015
12566
|
const handleLogout = async () => {
|
|
13016
12567
|
try {
|
|
13017
|
-
await
|
|
12568
|
+
await signOut();
|
|
13018
12569
|
window.location.href = "/";
|
|
13019
12570
|
} catch (error) {
|
|
13020
12571
|
console.error("\u767B\u51FA\u5931\u8D25:", error);
|
|
13021
12572
|
}
|
|
13022
12573
|
};
|
|
13023
|
-
if (!
|
|
12574
|
+
if (!isAuthenticated || !user) {
|
|
13024
12575
|
return null;
|
|
13025
12576
|
}
|
|
13026
|
-
return /* @__PURE__ */ React45__default.createElement("div", { className: "bg-white border-b border-gray-200 px-4 py-3" }, /* @__PURE__ */ React45__default.createElement("div", { className: "flex items-center justify-between" }, /* @__PURE__ */ React45__default.createElement("div", { className: "flex items-center space-x-3" }, /* @__PURE__ */ React45__default.createElement("div", { className: "flex items-center space-x-2" }, /* @__PURE__ */ React45__default.createElement(User, { className: "w-5 h-5 text-gray-600" }), /* @__PURE__ */ React45__default.createElement("span", { className: "text-sm font-medium text-gray-900" },
|
|
12577
|
+
return /* @__PURE__ */ React45__default.createElement("div", { className: "bg-white border-b border-gray-200 px-4 py-3" }, /* @__PURE__ */ React45__default.createElement("div", { className: "flex items-center justify-between" }, /* @__PURE__ */ React45__default.createElement("div", { className: "flex items-center space-x-3" }, /* @__PURE__ */ React45__default.createElement("div", { className: "flex items-center space-x-2" }, /* @__PURE__ */ React45__default.createElement(User, { className: "w-5 h-5 text-gray-600" }), /* @__PURE__ */ React45__default.createElement("span", { className: "text-sm font-medium text-gray-900" }, user.name || user.email || "\u7528\u6237"), user.role && /* @__PURE__ */ React45__default.createElement("span", { className: "inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-green-100 text-green-800" }, user.role))), /* @__PURE__ */ React45__default.createElement("div", { className: "flex items-center space-x-2" }, /* @__PURE__ */ React45__default.createElement("div", { className: "flex items-center space-x-1 text-sm text-gray-500" }, /* @__PURE__ */ React45__default.createElement(FlaskConical, { className: "w-4 h-4" }), /* @__PURE__ */ React45__default.createElement("span", null, "\u5B9E\u9A8C\u7530")), /* @__PURE__ */ React45__default.createElement(
|
|
13027
12578
|
"button",
|
|
13028
12579
|
{
|
|
13029
12580
|
onClick: handleLogout,
|
|
@@ -13034,9 +12585,9 @@ var UserInfoBar = ({ apiClient }) => {
|
|
|
13034
12585
|
))));
|
|
13035
12586
|
};
|
|
13036
12587
|
function DanmakuPanel({ onSend }) {
|
|
13037
|
-
const [
|
|
12588
|
+
const [text2, setText] = useState("");
|
|
13038
12589
|
const emit = () => {
|
|
13039
|
-
const value =
|
|
12590
|
+
const value = text2.trim();
|
|
13040
12591
|
if (!value) {
|
|
13041
12592
|
return;
|
|
13042
12593
|
}
|
|
@@ -13047,7 +12598,7 @@ function DanmakuPanel({ onSend }) {
|
|
|
13047
12598
|
"input",
|
|
13048
12599
|
{
|
|
13049
12600
|
type: "text",
|
|
13050
|
-
value:
|
|
12601
|
+
value: text2,
|
|
13051
12602
|
onChange: (event) => setText(event.target.value),
|
|
13052
12603
|
onKeyDown: (event) => {
|
|
13053
12604
|
if (event.key === "Enter") {
|
|
@@ -13163,8 +12714,8 @@ function useDanmakuController(options) {
|
|
|
13163
12714
|
cursorRef.current += 1;
|
|
13164
12715
|
}, []);
|
|
13165
12716
|
const send = useCallback(
|
|
13166
|
-
(
|
|
13167
|
-
const trimmed =
|
|
12717
|
+
(text2, color, sendOptions) => {
|
|
12718
|
+
const trimmed = text2.trim();
|
|
13168
12719
|
if (!trimmed) {
|
|
13169
12720
|
return null;
|
|
13170
12721
|
}
|
|
@@ -13201,26 +12752,26 @@ function useDanmakuController(options) {
|
|
|
13201
12752
|
[addIncoming, items, removeItem, send]
|
|
13202
12753
|
);
|
|
13203
12754
|
}
|
|
13204
|
-
function parseCommand(
|
|
13205
|
-
if (
|
|
13206
|
-
return { launchKind: "miku", content:
|
|
12755
|
+
function parseCommand(text2) {
|
|
12756
|
+
if (text2.startsWith("/miku ")) {
|
|
12757
|
+
return { launchKind: "miku", content: text2.replace("/miku ", "").trim() };
|
|
13207
12758
|
}
|
|
13208
|
-
if (
|
|
12759
|
+
if (text2 === "/miku") {
|
|
13209
12760
|
return { launchKind: "miku", content: "MIKU!" };
|
|
13210
12761
|
}
|
|
13211
|
-
if (
|
|
13212
|
-
return { launchKind: "avatar", content:
|
|
12762
|
+
if (text2.startsWith("/avatar ")) {
|
|
12763
|
+
return { launchKind: "avatar", content: text2.replace("/avatar ", "").trim() };
|
|
13213
12764
|
}
|
|
13214
|
-
if (
|
|
12765
|
+
if (text2 === "/avatar") {
|
|
13215
12766
|
return { launchKind: "avatar", content: "Avatar Firework!" };
|
|
13216
12767
|
}
|
|
13217
|
-
if (
|
|
13218
|
-
return { launchKind: "normal", content:
|
|
12768
|
+
if (text2.startsWith("/normal ")) {
|
|
12769
|
+
return { launchKind: "normal", content: text2.replace("/normal ", "").trim() };
|
|
13219
12770
|
}
|
|
13220
|
-
if (
|
|
12771
|
+
if (text2 === "/normal") {
|
|
13221
12772
|
return { launchKind: "normal", content: "Fireworks!" };
|
|
13222
12773
|
}
|
|
13223
|
-
return { content:
|
|
12774
|
+
return { content: text2 };
|
|
13224
12775
|
}
|
|
13225
12776
|
function createCircularSpriteTexture() {
|
|
13226
12777
|
const size = 64;
|
|
@@ -13902,12 +13453,12 @@ var WebSocketTransport = class {
|
|
|
13902
13453
|
}
|
|
13903
13454
|
};
|
|
13904
13455
|
function parseServerMessage(raw) {
|
|
13905
|
-
const
|
|
13906
|
-
if (!
|
|
13456
|
+
const text2 = decodeMessage(raw);
|
|
13457
|
+
if (!text2) {
|
|
13907
13458
|
return null;
|
|
13908
13459
|
}
|
|
13909
13460
|
try {
|
|
13910
|
-
return JSON.parse(
|
|
13461
|
+
return JSON.parse(text2);
|
|
13911
13462
|
} catch {
|
|
13912
13463
|
return null;
|
|
13913
13464
|
}
|
|
@@ -14174,8 +13725,8 @@ function MikuFireworks3D({
|
|
|
14174
13725
|
}
|
|
14175
13726
|
launch(payload);
|
|
14176
13727
|
};
|
|
14177
|
-
const handleSendDanmaku = (
|
|
14178
|
-
const result = send(
|
|
13728
|
+
const handleSendDanmaku = (text2) => {
|
|
13729
|
+
const result = send(text2, void 0, {
|
|
14179
13730
|
optimistic: !realtimeEnabled
|
|
14180
13731
|
});
|
|
14181
13732
|
if (!result) {
|
|
@@ -14274,9 +13825,9 @@ function useScreenReceiver(options) {
|
|
|
14274
13825
|
const peerRef = useRef({ pendingCandidates: [] });
|
|
14275
13826
|
const videoRef = useRef(null);
|
|
14276
13827
|
const appendLog = useCallback(
|
|
14277
|
-
(
|
|
13828
|
+
(text2) => {
|
|
14278
13829
|
logIdRef.current += 1;
|
|
14279
|
-
setLogs((prev) => [...prev, { id: logIdRef.current, text:
|
|
13830
|
+
setLogs((prev) => [...prev, { id: logIdRef.current, text: text2 }].slice(-maxLogs));
|
|
14280
13831
|
},
|
|
14281
13832
|
[maxLogs]
|
|
14282
13833
|
);
|
|
@@ -15002,8 +14553,8 @@ var withRoundedClip = (ctx, left, top, width, height, radius, draw) => {
|
|
|
15002
14553
|
draw();
|
|
15003
14554
|
ctx.restore();
|
|
15004
14555
|
};
|
|
15005
|
-
var drawMultilineText = (ctx,
|
|
15006
|
-
const paragraphs =
|
|
14556
|
+
var drawMultilineText = (ctx, text2, left, top, maxWidth, lineHeight) => {
|
|
14557
|
+
const paragraphs = text2.split("\n");
|
|
15007
14558
|
let currentY = top;
|
|
15008
14559
|
paragraphs.forEach((paragraph, index) => {
|
|
15009
14560
|
const words = paragraph.split("");
|
|
@@ -16222,11 +15773,11 @@ var validateByType = (type, input) => {
|
|
|
16222
15773
|
break;
|
|
16223
15774
|
}
|
|
16224
15775
|
case "text": {
|
|
16225
|
-
const
|
|
16226
|
-
if (!
|
|
15776
|
+
const text2 = content.textContent || "";
|
|
15777
|
+
if (!text2.trim()) {
|
|
16227
15778
|
errors.push("\u6587\u5B57\u7C7B\u4F5C\u54C1\u9700\u586B\u5199\u6B63\u6587");
|
|
16228
15779
|
}
|
|
16229
|
-
if (
|
|
15780
|
+
if (text2.length > TEXT_CONTENT_LIMIT) {
|
|
16230
15781
|
errors.push(`\u6587\u5B57\u6B63\u6587\u4E0D\u80FD\u8D85\u8FC7 ${TEXT_CONTENT_LIMIT} \u5B57`);
|
|
16231
15782
|
}
|
|
16232
15783
|
break;
|