Skip to content

Commit

Permalink
feat: add redirectLogin
Browse files Browse the repository at this point in the history
  • Loading branch information
supersonictw committed Nov 9, 2024
1 parent c1c3404 commit d0e7f61
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/components/AppHeaderMenuData.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import {
redirectLogin,
} from "../plugins/profile";

export const title = "Chew 口香糖";
export const subtitle = "文字片段分享";

export const isSaraEnabled = true;
export const onClickSara = () => {
const {
VITE_SARA_INTE_HOST: saraInteHost,
} = import.meta.env;
location.assign(saraInteHost);
redirectLogin();
};

export const menuItems = [];
14 changes: 13 additions & 1 deletion src/plugins/profile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { jwtDecode } from "jwt-decode";

const {
VITE_SARA_INTE_HOST: saraInteHost,
VITE_SARA_TOKEN_NAME: saraTokenName,
} = import.meta.env;

Expand All @@ -22,4 +23,15 @@ export const useProfile = () => {
location.reload();
return null;
}
};
};

export const redirectLogin = (isWithRefer=false) => {
if (!isWithRefer) {
location.assign(saraInteHost);
return;
}

const {href: refer} = location;
const params = new URLSearchParams({refer});
location.assign(`${saraInteHost}/?${params}`);
};
1 change: 0 additions & 1 deletion tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ export default {
},
plugins: [],
}

0 comments on commit d0e7f61

Please sign in to comment.