Skip to content

Commit

Permalink
add baidu keywords (labring#3127)
Browse files Browse the repository at this point in the history
  • Loading branch information
newfish-cmyk authored Nov 12, 2024
1 parent 2e1bf66 commit 2c5f88b
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 6 deletions.
3 changes: 3 additions & 0 deletions packages/global/support/user/type.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export type UserModelSchema = {
key: string;
baseUrl: string;
};
fastgpt_sem?: {
keyword: string;
};
};

export type UserType = {
Expand Down
3 changes: 3 additions & 0 deletions packages/service/support/user/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ const UserSchema = new Schema({
},
lastLoginTmbId: {
type: Schema.Types.ObjectId
},
fastgpt_sem: {
type: Object
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ const FormLayout = ({ children, setPageType, pageType }: Props) => {
: [])
];

const show_oauth = !!(feConfigs?.sso || oAuthList.length > 0);
const show_oauth =
!sessionStorage.getItem('bd_vid') && !!(feConfigs?.sso || oAuthList.length > 0);

return (
<Flex flexDirection={'column'} h={'100%'}>
Expand Down
13 changes: 12 additions & 1 deletion projects/app/src/pages/login/components/RegisterForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,24 @@ const RegisterForm = ({ setPageType, loginSuccess }: Props) => {

const { runAsync: onclickRegister, loading: requesting } = useRequest2(
async ({ username, password, code }: RegisterType) => {
const fastgpt_sem = (() => {
try {
return sessionStorage.getItem('fastgpt_sem')
? JSON.parse(sessionStorage.getItem('fastgpt_sem')!)
: undefined;
} catch {
return undefined;
}
})();

loginSuccess(
await postRegister({
username,
code,
password,
inviterId: localStorage.getItem('inviterId') || undefined,
bd_vid: localStorage.getItem('bd_vid') || undefined
bd_vid: sessionStorage.getItem('bd_vid') || undefined,
fastgpt_sem: fastgpt_sem
})
);

Expand Down
5 changes: 5 additions & 0 deletions projects/app/src/pages/login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ const Login = ({ ChineseRedirectUrl }: { ChineseRedirectUrl: string }) => {

/* default login type */
useEffect(() => {
const bd_vid = sessionStorage.getItem('bd_vid');
if (bd_vid) {
setPageType(LoginPageTypeEnum.passwordLogin);
return;
}
setPageType(
feConfigs?.oauth?.wechat ? LoginPageTypeEnum.wechat : LoginPageTypeEnum.passwordLogin
);
Expand Down
7 changes: 4 additions & 3 deletions projects/app/src/web/context/useInitApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { TrackEventName } from '../common/system/constants';

export const useInitApp = () => {
const router = useRouter();
const { hiId, bd_vid } = router.query as { hiId?: string; bd_vid?: string };
const { hiId, bd_vid, k } = router.query as { hiId?: string; bd_vid?: string; k?: string };
const { loadGitStar, setInitd, feConfigs } = useSystemStore();
const [scripts, setScripts] = useState<FastGPTFeConfigsType['scripts']>([]);
const [title, setTitle] = useState(process.env.SYSTEM_NAME || 'AI');
Expand Down Expand Up @@ -59,8 +59,9 @@ export const useInitApp = () => {

useEffect(() => {
hiId && localStorage.setItem('inviterId', hiId);
bd_vid && localStorage.setItem('bd_vid', bd_vid);
}, [bd_vid, hiId]);
bd_vid && sessionStorage.setItem('bd_vid', bd_vid);
k && sessionStorage.setItem('fastgpt_sem', JSON.stringify({ keyword: k }));
}, [bd_vid, hiId, k]);

return {
feConfigs,
Expand Down
7 changes: 6 additions & 1 deletion projects/app/src/web/support/user/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,24 @@ export const postRegister = ({
password,
code,
inviterId,
bd_vid
bd_vid,
fastgpt_sem
}: {
username: string;
code: string;
password: string;
inviterId?: string;
bd_vid?: string;
fastgpt_sem?: {
keyword: string;
};
}) =>
POST<ResLogin>(`/proApi/support/user/account/register/emailAndPhone`, {
username,
code,
inviterId,
bd_vid,
fastgpt_sem,
password: hashStr(password)
});

Expand Down

0 comments on commit 2c5f88b

Please sign in to comment.