feat: manually mirror opencoze's code from bytedance
Change-Id: I09a73aadda978ad9511264a756b2ce51f5761adf
This commit is contained in:
43
frontend/packages/foundation/foundation-sdk/src/index.ts
Normal file
43
frontend/packages/foundation/foundation-sdk/src/index.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { type useCurrentTheme as useCurrentThemeOfSDK } from '@coze-arch/foundation-sdk';
|
||||
import { useTheme } from '@coze-arch/coze-design';
|
||||
|
||||
export const useCurrentTheme: typeof useCurrentThemeOfSDK = () =>
|
||||
useTheme().theme;
|
||||
|
||||
export { logoutOnly, uploadAvatar } from './passport';
|
||||
|
||||
export {
|
||||
getIsSettled,
|
||||
getIsLogined,
|
||||
getUserInfo,
|
||||
getUserAuthInfos,
|
||||
useIsSettled,
|
||||
useIsLogined,
|
||||
useUserInfo,
|
||||
useUserAuthInfo,
|
||||
useUserLabel,
|
||||
subscribeUserAuthInfos,
|
||||
refreshUserInfo,
|
||||
useLoginStatus,
|
||||
getLoginStatus,
|
||||
} from './user';
|
||||
|
||||
export { BackButton, SideSheetMenu } from '@coze-foundation/layout';
|
||||
|
||||
export { useSpace } from './space';
|
||||
29
frontend/packages/foundation/foundation-sdk/src/passport.ts
Normal file
29
frontend/packages/foundation/foundation-sdk/src/passport.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {
|
||||
type logoutOnly as logoutOnlyOfSdk,
|
||||
type uploadAvatar as uploadAvatarOfSdk,
|
||||
} from '@coze-arch/foundation-sdk';
|
||||
import {
|
||||
logout as logoutOnlyImpl,
|
||||
passportApi,
|
||||
} from '@coze-foundation/account-adapter';
|
||||
|
||||
export const logoutOnly = logoutOnlyImpl satisfies typeof logoutOnlyOfSdk;
|
||||
|
||||
export const uploadAvatar: typeof uploadAvatarOfSdk = (avatar: File) =>
|
||||
passportApi.uploadAvatar({ avatar });
|
||||
24
frontend/packages/foundation/foundation-sdk/src/space.ts
Normal file
24
frontend/packages/foundation/foundation-sdk/src/space.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { type BotSpace } from '@coze-arch/bot-api/developer_api';
|
||||
import { useSpace as useInternalSpace } from '@coze-foundation/space-store';
|
||||
|
||||
export function useSpace(spaceId: string): BotSpace | undefined {
|
||||
const { space } = useInternalSpace(spaceId);
|
||||
|
||||
return space;
|
||||
}
|
||||
76
frontend/packages/foundation/foundation-sdk/src/user.ts
Normal file
76
frontend/packages/foundation/foundation-sdk/src/user.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {
|
||||
type refreshUserInfo as refreshUserInfoOfSdk,
|
||||
type getIsSettled as getIsSettledOfSdk,
|
||||
type getIsLogined as getIsLoginedOfSdk,
|
||||
type getUserInfo as getUserInfoOfSdk,
|
||||
type useIsSettled as useIsSettledOfSdk,
|
||||
type useIsLogined as useIsLoginedOfSdk,
|
||||
type useUserInfo as useUserInfoOfSdk,
|
||||
type getLoginStatus as getLoginStatusOfSdk,
|
||||
type useLoginStatus as useLoginStatusOfSdk,
|
||||
type getUserAuthInfos as getUserAuthInfosOfSdk,
|
||||
type useUserAuthInfo as useUserAuthInfoOfSdk,
|
||||
type useUserLabel as useUserLabelOfSdk,
|
||||
type subscribeUserAuthInfos as subscribeUserAuthInfosOfSdk,
|
||||
} from '@coze-arch/foundation-sdk';
|
||||
import {
|
||||
refreshUserInfo as refreshUserInfoImpl,
|
||||
getLoginStatus as getLoginStatusImpl,
|
||||
useLoginStatus as useLoginStatusImpl,
|
||||
getUserInfo as getUserInfoImpl,
|
||||
useUserInfo as useUserInfoImpl,
|
||||
getUserAuthInfos as getUserAuthInfosImpl,
|
||||
useUserAuthInfo as useUserAuthInfoImpl,
|
||||
useUserLabel as useUserLabelImpl,
|
||||
subscribeUserAuthInfos as subscribeUserAuthInfosImpl,
|
||||
} from '@coze-foundation/account-adapter';
|
||||
|
||||
/** @deprecated 使用 getLoginStatus */
|
||||
export const getIsSettled = (() =>
|
||||
getLoginStatus() !== 'settling') satisfies typeof getIsSettledOfSdk;
|
||||
/** @deprecated 使用 getLoginStatus */
|
||||
export const getIsLogined = (() =>
|
||||
getLoginStatus() === 'logined') satisfies typeof getIsLoginedOfSdk;
|
||||
export const getUserInfo = getUserInfoImpl satisfies typeof getUserInfoOfSdk;
|
||||
export const getUserAuthInfos =
|
||||
getUserAuthInfosImpl satisfies typeof getUserAuthInfosOfSdk;
|
||||
/** @deprecated 使用 useLoginStatus */
|
||||
export const useIsSettled = (() => {
|
||||
const status = useLoginStatus();
|
||||
return status !== 'settling';
|
||||
}) satisfies typeof useIsSettledOfSdk;
|
||||
/** @deprecated 使用 useLoginStatus */
|
||||
export const useIsLogined = (() => {
|
||||
const status = useLoginStatus();
|
||||
return status === 'logined';
|
||||
}) satisfies typeof useIsLoginedOfSdk;
|
||||
export const useUserInfo = useUserInfoImpl satisfies typeof useUserInfoOfSdk;
|
||||
|
||||
export const useUserAuthInfo =
|
||||
useUserAuthInfoImpl satisfies typeof useUserAuthInfoOfSdk;
|
||||
export const useUserLabel = useUserLabelImpl satisfies typeof useUserLabelOfSdk;
|
||||
export const subscribeUserAuthInfos =
|
||||
subscribeUserAuthInfosImpl satisfies typeof subscribeUserAuthInfosOfSdk;
|
||||
|
||||
export const refreshUserInfo =
|
||||
refreshUserInfoImpl satisfies typeof refreshUserInfoOfSdk;
|
||||
export const useLoginStatus =
|
||||
useLoginStatusImpl satisfies typeof useLoginStatusOfSdk;
|
||||
export const getLoginStatus =
|
||||
getLoginStatusImpl satisfies typeof getLoginStatusOfSdk;
|
||||
Reference in New Issue
Block a user