@axiom-lattice/react-sdk 2.1.68 → 2.1.70
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/index.js +12 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -307,16 +307,22 @@ function AxiomLatticeProvider({
|
|
|
307
307
|
}) {
|
|
308
308
|
const authContext = useContext2(AuthContext);
|
|
309
309
|
const tenantId = authContext?.currentTenant?.id;
|
|
310
|
+
const effectiveApiKey = useMemo(() => {
|
|
311
|
+
if (authContext?.isAuthenticated) {
|
|
312
|
+
return sessionStorage.getItem("lattice_token") || config.apiKey;
|
|
313
|
+
}
|
|
314
|
+
return config.apiKey;
|
|
315
|
+
}, [authContext?.isAuthenticated, authContext?.currentTenant?.id, config.apiKey]);
|
|
310
316
|
const clientCacheRef = useRef(/* @__PURE__ */ new Map());
|
|
311
317
|
const baseConfig = useMemo(
|
|
312
318
|
() => ({
|
|
313
319
|
baseURL: config.baseURL,
|
|
314
|
-
apiKey:
|
|
320
|
+
apiKey: effectiveApiKey,
|
|
315
321
|
assistantId: "__BASE__",
|
|
316
322
|
// 占位符,不会被直接使用
|
|
317
323
|
transport: config.transport
|
|
318
324
|
}),
|
|
319
|
-
[config.baseURL,
|
|
325
|
+
[config.baseURL, effectiveApiKey, config.transport]
|
|
320
326
|
);
|
|
321
327
|
const baseClient = useMemo(() => {
|
|
322
328
|
const client = new Client(baseConfig);
|
|
@@ -19083,7 +19089,7 @@ var useWorkspaceContext = () => {
|
|
|
19083
19089
|
var WorkspaceContextProvider = ({
|
|
19084
19090
|
children
|
|
19085
19091
|
}) => {
|
|
19086
|
-
const { currentTenant } = useAuth();
|
|
19092
|
+
const { currentTenant, isAuthenticated } = useAuth();
|
|
19087
19093
|
const tenantId = currentTenant?.id || "";
|
|
19088
19094
|
const { config } = useLatticeChatShellContext();
|
|
19089
19095
|
const axiomClient = useClient("__GLOBAL__");
|
|
@@ -19116,13 +19122,14 @@ var WorkspaceContextProvider = ({
|
|
|
19116
19122
|
const [loading, setLoading] = useState49(false);
|
|
19117
19123
|
const [error, setError] = useState49(null);
|
|
19118
19124
|
const client = React38.useMemo(() => {
|
|
19125
|
+
const authApiKey = isAuthenticated ? sessionStorage.getItem("lattice_token") || config.apiKey || "" : config.apiKey || "";
|
|
19119
19126
|
return new WorkspaceClient({
|
|
19120
19127
|
baseURL: config.baseURL,
|
|
19121
|
-
apiKey:
|
|
19128
|
+
apiKey: authApiKey,
|
|
19122
19129
|
assistantId: "",
|
|
19123
19130
|
transport: "sse"
|
|
19124
19131
|
}, tenantId);
|
|
19125
|
-
}, [config.baseURL, config.apiKey, tenantId]);
|
|
19132
|
+
}, [config.baseURL, config.apiKey, tenantId, isAuthenticated]);
|
|
19126
19133
|
const resetSelectedWorkspace = useCallback26(() => {
|
|
19127
19134
|
setProjects([]);
|
|
19128
19135
|
setWorkspaceId(null);
|