Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sample-form-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
sample-form-platform
Commits
6f9715ff
Commit
6f9715ff
authored
Sep 06, 2023
by
“yiyousong”
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf:修改vuex状态持久化
parent
c92465df
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
94 additions
and
5 deletions
+94
-5
sample-form-manager-ui/admin/package.json
sample-form-manager-ui/admin/package.json
+1
-0
sample-form-manager-ui/admin/src/store/index.js
sample-form-manager-ui/admin/src/store/index.js
+6
-5
sample-form-manager-ui/admin/src/utils/index.js
sample-form-manager-ui/admin/src/utils/index.js
+82
-0
sample-form-manager-ui/admin/yarn.lock
sample-form-manager-ui/admin/yarn.lock
+5
-0
No files found.
sample-form-manager-ui/admin/package.json
View file @
6f9715ff
...
...
@@ -17,6 +17,7 @@
"beautifier"
:
"^0.1.7"
,
"clipboard"
:
"^2.0.4"
,
"core-js"
:
"^3.8.3"
,
"crypto-js"
:
"^4.1.1"
,
"css-loader"
:
"^3.5.3"
,
"element-china-area-data"
:
"^5.0.2"
,
"element-ui"
:
"^2.15.10"
,
...
...
sample-form-manager-ui/admin/src/store/index.js
View file @
6f9715ff
import
Vue
from
"
vue
"
;
import
Vuex
from
"
vuex
"
;
import
createPersistedState
from
"
vuex-persistedstate
"
;
import
SecureLS
from
"
secure-ls
"
;
var
ls
=
new
SecureLS
({
isCompression
:
false
});
// import SecureLS from "secure-ls";
// var ls = new SecureLS({ isCompression: false });
import
{
SessionCrypto
}
from
"
@/utils
"
;
Vue
.
use
(
Vuex
);
export
default
new
Vuex
.
Store
({
...
...
@@ -62,9 +63,9 @@ export default new Vuex.Store({
createPersistedState
({
key
:
"
sample
"
,
storage
:
{
getItem
:
(
key
)
=>
ls
.
get
(
key
),
setItem
:
(
key
,
value
)
=>
ls
.
set
(
key
,
value
),
removeItem
:
(
key
)
=>
ls
.
remove
(
key
),
getItem
:
(
key
)
=>
SessionCrypto
.
getItem
(
key
),
setItem
:
(
key
,
value
)
=>
SessionCrypto
.
setItem
(
key
,
value
),
removeItem
:
(
key
)
=>
SessionCrypto
.
remove
(
key
),
},
}),
],
...
...
sample-form-manager-ui/admin/src/utils/index.js
View file @
6f9715ff
import
CryptoJS
from
"
crypto-js
"
;
// 递归获取底层子数组
export
function
findBottomSubarrays
(
arr
)
{
let
bottomSubarrays
=
[];
...
...
@@ -14,3 +16,83 @@ export function findBottomSubarrays(arr) {
recursiveSearch
(
arr
);
return
bottomSubarrays
;
}
// 加密数据
export
let
encrypt
=
(
str
,
keyStr
,
ivStr
)
=>
{
keyStr
=
keyStr
?
keyStr
:
"
0000000671595991
"
;
ivStr
=
ivStr
?
ivStr
:
"
tdrdadq59tbss5n7
"
;
//密钥16位
let
key
=
CryptoJS
.
enc
.
Utf8
.
parse
(
keyStr
);
//加密向量16位
let
iv
=
CryptoJS
.
enc
.
Utf8
.
parse
(
ivStr
);
let
encrypted
=
CryptoJS
.
AES
.
encrypt
(
str
,
key
,
{
iv
:
iv
,
mode
:
CryptoJS
.
mode
.
CBC
,
padding
:
CryptoJS
.
pad
.
Pkcs7
,
});
return
encrypted
.
toString
();
};
// 解密
export
const
decrypt
=
(
word
,
keyStr
,
ivStr
)
=>
{
keyStr
=
keyStr
?
keyStr
:
"
0000000671595991
"
;
ivStr
=
ivStr
?
ivStr
:
"
tdrdadq59tbss5n7
"
;
let
key
=
CryptoJS
.
enc
.
Utf8
.
parse
(
keyStr
);
let
iv
=
CryptoJS
.
enc
.
Utf8
.
parse
(
ivStr
);
let
decrypt
=
CryptoJS
.
AES
.
decrypt
(
word
,
key
,
{
iv
,
mode
:
CryptoJS
.
mode
.
CBC
,
padding
:
CryptoJS
.
pad
.
Pkcs7
,
});
return
decrypt
.
toString
(
CryptoJS
.
enc
.
Utf8
);
};
/**
* 加密存储临时数据并解析对象
*/
const
aseKey
=
"
**_FXxx_1234_KEY
"
;
const
KEY
=
"
KEY_EXTRA
"
;
export
class
SessionCrypto
{
// 加密
static
setItem
(
key
=
KEY
,
value
=
""
)
{
if
(
typeof
key
===
"
string
"
)
{
const
stringify
=
JSON
.
stringify
(
value
);
const
encrypt
=
CryptoJS
.
AES
.
encrypt
(
stringify
,
CryptoJS
.
enc
.
Utf8
.
parse
(
aseKey
),
{
mode
:
CryptoJS
.
mode
.
ECB
,
padding
:
CryptoJS
.
pad
.
Pkcs7
,
}
).
toString
();
window
.
sessionStorage
.
setItem
(
key
,
encrypt
);
return
encrypt
;
}
}
// 解密
static
getItem
(
key
=
KEY
)
{
const
ssStr
=
window
.
sessionStorage
.
getItem
(
key
)
||
""
;
try
{
if
(
ssStr
)
{
const
decrypt
=
CryptoJS
.
AES
.
decrypt
(
ssStr
,
CryptoJS
.
enc
.
Utf8
.
parse
(
aseKey
),
{
mode
:
CryptoJS
.
mode
.
ECB
,
padding
:
CryptoJS
.
pad
.
Pkcs7
,
}
).
toString
(
CryptoJS
.
enc
.
Utf8
);
const
parseStr
=
JSON
.
parse
(
decrypt
);
return
parseStr
;
}
return
""
;
}
catch
(
e
)
{
return
""
;
}
}
// 删除
static
remove
(
key
)
{
window
.
sessionStorage
.
removeItem
(
key
);
}
}
sample-form-manager-ui/admin/yarn.lock
View file @
6f9715ff
...
...
@@ -3014,6 +3014,11 @@ crypto-js@^3.1.6:
resolved "https://registry.npmmirror.com/crypto-js/-/crypto-js-3.3.0.tgz#846dd1cce2f68aacfa156c8578f926a609b7976b"
integrity sha512-DIT51nX0dCfKltpRiXV+/TVZq+Qq2NgF4644+K7Ttnla7zEzqc+kjJyiB96BHNyUTBxyjzRcZYpUdZa+QAqi6Q==
crypto-js@^4.1.1:
version "4.1.1"
resolved "https://registry.npmmirror.com/crypto-js/-/crypto-js-4.1.1.tgz#9e485bcf03521041bd85844786b83fb7619736cf"
integrity sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw==
crypto-random-string@^1.0.0:
version "1.0.0"
resolved "https://registry.npmmirror.com/crypto-random-string/-/crypto-random-string-1.0.0.tgz#a230f64f568310e1498009940790ec99545bca7e"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment