Skip to content

Commit

Permalink
feat: 支持多标签页打开已经登录的系统后无需再登录并添加7天内免登录功能 (#747)
Browse files Browse the repository at this point in the history
* feat: 支持多标签页打开已经登录的系统后无需再登录

* feat: 添加`7`天内免登录功能
  • Loading branch information
xiaoxian521 authored Oct 7, 2023
1 parent be2de40 commit 7e7b6fe
Show file tree
Hide file tree
Showing 12 changed files with 131 additions and 93 deletions.
3 changes: 2 additions & 1 deletion locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ login:
username: Username
password: Password
verifyCode: VerifyCode
remember: Remember Password
remember: No need to login for 7 days
rememberInfo: After checking and logging in, you will automatically log in to the system without entering your username and password within 7 days
sure: Sure Password
forget: Forget Password?
login: Login
Expand Down
3 changes: 2 additions & 1 deletion locales/zh-CN.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ login:
username: 账号
password: 密码
verifyCode: 验证码
remember: 记住密码
remember: 7天内免登录
rememberInfo: 勾选并登录后,7天内无需输入用户名和密码会自动登入系统
sure: 确认密码
forget: 忘记密码?
login: 登录
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
"prettier": "^3.0.3",
"rimraf": "^5.0.5",
"rollup-plugin-visualizer": "^5.9.2",
"sass": "^1.68.0",
"sass": "^1.69.0",
"sass-loader": "^13.3.2",
"stylelint": "^15.10.3",
"stylelint-config-html": "^1.1.0",
Expand All @@ -157,7 +157,7 @@
"tailwindcss": "^3.3.3",
"terser": "^5.21.0",
"typescript": "^5.2.2",
"vite": "^4.4.10",
"vite": "^4.4.11",
"vite-plugin-cdn-import": "^0.3.5",
"vite-plugin-compression": "^0.5.1",
"vite-plugin-mock": "2.9.6",
Expand Down
80 changes: 40 additions & 40 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 1 addition & 8 deletions src/layout/components/setting/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ import {
nextTick,
onBeforeMount
} from "vue";
import {
useDark,
debounce,
useGlobal,
storageLocal,
storageSession
} from "@pureadmin/utils";
import { getConfig } from "@/config";
import { useRouter } from "vue-router";
import panel from "../panel/index.vue";
Expand All @@ -27,6 +20,7 @@ import { useAppStoreHook } from "@/store/modules/app";
import { toggleTheme } from "@pureadmin/theme/dist/browser-utils";
import { useMultiTagsStoreHook } from "@/store/modules/multiTags";
import { useDataThemeChange } from "@/layout/hooks/useDataThemeChange";
import { useDark, debounce, useGlobal, storageLocal } from "@pureadmin/utils";
import dayIcon from "@/assets/svg/day.svg?component";
import darkIcon from "@/assets/svg/dark.svg?component";
Expand Down Expand Up @@ -133,7 +127,6 @@ const multiTagsCacheChange = () => {
function onReset() {
removeToken();
storageLocal().clear();
storageSession().clear();
const { Grey, Weak, MultiTagsCache, EpThemeColor, Layout } = getConfig();
useAppStoreHook().setLayout(Layout);
setEpThemeColor(EpThemeColor);
Expand Down
Loading

1 comment on commit 7e7b6fe

@xiaoxian521
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改动点描述:

1. 将存储在sessionStorage的全部信息存储到localStorage,平台默认不在sessionStorage存储信息,主要为了支持多标签页打开已经登录的系统后无需再登录功能,因为sessionStorage在多标签是不共享数据的,虽然有办法解决这个问题,但都不完美,尤其是在一个标签页修改了sessionStorage里的信息后,为了别的标签页sessionStorage信息保持一致,不得不去通知它,多了很多额外的代码,处理是比较麻烦的,所以这里建议大家如果有多标签共享信息的需求,就不要将信息存储到sessionStorage

下面两个问题也就迎刃而解了
#682
#662

2. 添加7天内免登录功能。通过判断是否勾选登录页的7天内免登录选项,对存在cookiemultiple-tabs设置过期时间。未勾选,过期时间默认为浏览器全部关闭销毁multiple-tabs,已勾选,multiple-tabs会在cookie中存储7天,浏览器全部关闭也不会销毁,除非手动清除

演示视频

Kapture.2023-10-07.at.10.40.42.mp4

Please sign in to comment.