Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-vue-admin
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-vue-admin
Commits
c620f827
提交
c620f827
authored
10月 27, 2020
作者:
vben
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
perf: set cache default time
上级
b350098f
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
16 行增加
和
6 行删除
+16
-6
CHANGELOG.zh_CN.md
CHANGELOG.zh_CN.md
+1
-0
cipherSetting.ts
src/settings/cipherSetting.ts
+3
-0
persistent.ts
src/utils/helper/persistent.ts
+6
-1
Storage.ts
src/utils/storage/Storage.ts
+6
-5
没有找到文件。
CHANGELOG.zh_CN.md
浏览文件 @
c620f827
...
...
@@ -15,6 +15,7 @@
### ⚡ Performance Improvements
-
`setTitle`
逻辑调整
-
将系统用到的 sessionStorage 及 LocalStorage 缓存设置默认
`7`
天过期
### ✨ Refactor
...
...
src/settings/cipherSetting.ts
浏览文件 @
c620f827
// System default cache time, in seconds
export
const
DEFAULT_CACHE_TIME
=
60
*
60
*
24
*
7
;
/**
* @description:
*/
...
...
src/utils/helper/persistent.ts
浏览文件 @
c620f827
...
...
@@ -6,10 +6,15 @@ import { BASE_LOCAL_CACHE_KEY, BASE_SESSION_CACHE_KEY } from '/@/enums/cacheEnum
const
ls
=
createStorage
(
localStorage
);
const
ss
=
createStorage
();
interface
CacheStore
{
local
?:
any
;
session
?:
any
;
}
/**
* @description: Persistent cache
*/
const
cacheStore
:
any
=
{
const
cacheStore
:
CacheStore
=
{
// localstorage cache
local
:
{},
// sessionstorage cache
...
...
src/utils/storage/Storage.ts
浏览文件 @
c620f827
import
{
EncryptionParams
}
from
'/@/utils/cipher/aesEncryption'
;
export
interface
CreateStorageParams
extends
EncryptionParams
{
import
{
DEFAULT_CACHE_TIME
}
from
'/@/settings/cipherSetting'
;
// import { EncryptionParams } from '/@/utils/cipher/aesEncryption';
export
interface
CreateStorageParams
{
storage
:
Storage
;
hasEncrypt
:
boolean
;
}
const
defaultTime
=
60
*
60
*
24
*
7
;
export
const
createStorage
=
({
prefixKey
=
''
,
storage
=
sessionStorage
}
=
{})
=>
{
/**
*缓存类
...
...
@@ -36,7 +37,7 @@ export const createStorage = ({ prefixKey = '', storage = sessionStorage } = {})
* @expire 过期时间 单位秒
* @memberof Cache
*/
set
(
key
:
string
,
value
:
any
,
expire
:
number
|
null
=
defaultTime
)
{
set
(
key
:
string
,
value
:
any
,
expire
:
number
|
null
=
DEFAULT_CACHE_TIME
)
{
const
stringData
=
JSON
.
stringify
({
value
,
expire
:
expire
!==
null
?
new
Date
().
getTime
()
+
expire
*
1000
:
null
,
...
...
@@ -96,7 +97,7 @@ export const createStorage = ({ prefixKey = '', storage = sessionStorage } = {})
* 例子:
* cookieData.set('name','value',)
*/
setCookie
(
name
:
string
,
value
:
any
,
expire
:
number
|
null
=
defaultTime
)
{
setCookie
(
name
:
string
,
value
:
any
,
expire
:
number
|
null
=
DEFAULT_CACHE_TIME
)
{
document
.
cookie
=
this
.
getKey
(
name
)
+
'='
+
value
+
'; Max-Age='
+
expire
;
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论