reset localstorage func
This commit is contained in:
parent
f53442594f
commit
dd31401231
@ -2,9 +2,9 @@ import axios from 'axios'
|
|||||||
|
|
||||||
export const api = axios.create({
|
export const api = axios.create({
|
||||||
// baseURL: 'https://ccb.canary.moe/api/',
|
// baseURL: 'https://ccb.canary.moe/api/',
|
||||||
baseURL: window.location.origin + '/api/',
|
// baseURL: window.location.origin + '/api/',
|
||||||
// baseURL: 'https://canary.lacus.site/api/',
|
// baseURL: 'https://canary.lacus.site/api/',
|
||||||
// baseURL: 'https://canary.lacus.icu/api/',
|
baseURL: 'https://canary.lacus.icu/api/',
|
||||||
// baseURL: 'http://beta.lacus.site/api/',
|
// baseURL: 'http://beta.lacus.site/api/',
|
||||||
// baseURL: 'http://152.136.99.231:8001' + '/api/',
|
// baseURL: 'http://152.136.99.231:8001' + '/api/',
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -44,36 +44,44 @@ export default new Vuex.Store({
|
|||||||
commit
|
commit
|
||||||
}, arg) {
|
}, arg) {
|
||||||
commit('SET_USERINFO', arg[0]);
|
commit('SET_USERINFO', arg[0]);
|
||||||
localStorage.setItem("storeState", JSON.stringify(arg[1].$store.state));
|
setItem.call(arg[1])
|
||||||
},
|
},
|
||||||
// 设置aes化的密码信息
|
// 设置aes化的密码信息
|
||||||
setRowData({
|
setRowData({
|
||||||
commit
|
commit
|
||||||
}, arg) {
|
}, arg) {
|
||||||
commit('SET_ROWDATA', arg[0]);
|
commit('SET_ROWDATA', arg[0]);
|
||||||
localStorage.setItem("storeState", JSON.stringify(arg[1].$store.state));
|
setItem.call(arg[1])
|
||||||
},
|
},
|
||||||
// 设置aes化的用户主密码
|
// 设置aes化的用户主密码
|
||||||
setRowPwd({
|
setRowPwd({
|
||||||
commit
|
commit
|
||||||
}, arg) {
|
}, arg) {
|
||||||
commit('SET_ROWPWD', arg[0]);
|
commit('SET_ROWPWD', arg[0]);
|
||||||
localStorage.setItem("storeState", JSON.stringify(arg[1].$store.state));
|
setItem.call(arg[1])
|
||||||
},
|
},
|
||||||
// 设置配置信息
|
// 设置配置信息
|
||||||
setSettings({
|
setSettings({
|
||||||
commit
|
commit
|
||||||
}, arg) {
|
}, arg) {
|
||||||
commit('SET_SETTINGS', arg[0]);
|
commit('SET_SETTINGS', arg[0]);
|
||||||
localStorage.setItem("storeState", JSON.stringify(arg[1].$store.state));
|
setItem.call(arg[1])
|
||||||
},
|
},
|
||||||
// 设置主页状态
|
// 设置主页状态
|
||||||
setHomeState({
|
setHomeState({
|
||||||
commit
|
commit
|
||||||
}, arg) {
|
}, arg) {
|
||||||
commit('SET_HOMESTATE', arg[0]);
|
commit('SET_HOMESTATE', arg[0]);
|
||||||
localStorage.setItem("storeState", JSON.stringify(arg[1].$store.state));
|
setItem.call(arg[1])
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
modules: {}
|
modules: {}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
function setItem() {
|
||||||
|
let state = this.$store.state
|
||||||
|
for(let key of Object.keys(state)) {
|
||||||
|
localStorage.setItem("canary_" + key , JSON.stringify(state[key]));
|
||||||
|
}
|
||||||
|
}
|
50
src/utils/getStore.js
Normal file
50
src/utils/getStore.js
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
export function replaceState() {
|
||||||
|
let state = {}
|
||||||
|
for (let key of Object.keys(this.$store.state)) {
|
||||||
|
let content = JSON.parse(localStorage.getItem("canary_" + key))
|
||||||
|
if (content == null) content = ''
|
||||||
|
state[key] = content
|
||||||
|
}
|
||||||
|
this.$store.replaceState(
|
||||||
|
Object.assign(
|
||||||
|
this.$store.state,
|
||||||
|
state
|
||||||
|
)
|
||||||
|
);
|
||||||
|
// 初始化
|
||||||
|
initUserInfo.call(this);
|
||||||
|
initSettings.call(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化用户信息
|
||||||
|
function initUserInfo() {
|
||||||
|
if (Object.keys(this.user_infos).length == 0) {
|
||||||
|
// 初始化用户信息
|
||||||
|
let user_infos = {
|
||||||
|
user_name: "A Little Canary",
|
||||||
|
cid: "Codebook",
|
||||||
|
row_login_pwd: "",
|
||||||
|
drivce: "",
|
||||||
|
cloud_drivce: this.settings.is_chinese ? "暂无" : "unknown",
|
||||||
|
update_time: new Date().getTime(),
|
||||||
|
};
|
||||||
|
this.setUserInfo([user_infos, this]);
|
||||||
|
console.log("用户信息覆写完成");
|
||||||
|
}
|
||||||
|
console.log("用户信息初始化完成");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化配置信息
|
||||||
|
function initSettings() {
|
||||||
|
if (Object.keys(this.settings).length == 0) {
|
||||||
|
// 初始化配置信息
|
||||||
|
let settings = {
|
||||||
|
is_chinese: true,
|
||||||
|
is_dark_mode: false,
|
||||||
|
expired_time: 300000, // 5分钟
|
||||||
|
};
|
||||||
|
this.setSettings([settings, this]);
|
||||||
|
console.log("配置信息覆写完成");
|
||||||
|
}
|
||||||
|
console.log("配置信息初始化完成");
|
||||||
|
}
|
@ -201,7 +201,7 @@ export function lang() {
|
|||||||
submit: '登录'
|
submit: '登录'
|
||||||
},
|
},
|
||||||
account: {
|
account: {
|
||||||
label: ['云端信息最后修改时间', '云端信息最后修改设备名', '同步本地密码本至云端', '同步云端密码本至本地'],
|
label: ['云盘信息最后修改时间', '云盘信息最后修改设备名', '同步本地密码本至云盘', '同步云盘密码本至本地'],
|
||||||
logout: '退出登录'
|
logout: '退出登录'
|
||||||
},
|
},
|
||||||
cid_errmsg: ['教务账号不能为空'],
|
cid_errmsg: ['教务账号不能为空'],
|
||||||
|
@ -123,6 +123,7 @@ import {
|
|||||||
import { syncLocal, syncCloud } from "@/axios/api.js";
|
import { syncLocal, syncCloud } from "@/axios/api.js";
|
||||||
import { lang } from "@/utils/language.js";
|
import { lang } from "@/utils/language.js";
|
||||||
import { setHtmlFontSize } from "@/utils/px2rem.js";
|
import { setHtmlFontSize } from "@/utils/px2rem.js";
|
||||||
|
import { replaceState } from "@/utils/getStore.js";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Add",
|
name: "Add",
|
||||||
@ -152,7 +153,7 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(["setUserInfo", "setRowData", "setRowPwd"]),
|
...mapActions(["setRowData", "setRowPwd", "setSettings", "setUserInfo"]),
|
||||||
// 修改md-app的最小高度
|
// 修改md-app的最小高度
|
||||||
changeFixed(clientHeight) {
|
changeFixed(clientHeight) {
|
||||||
//动态修改样式
|
//动态修改样式
|
||||||
@ -169,13 +170,8 @@ export default {
|
|||||||
},
|
},
|
||||||
// 初始化
|
// 初始化
|
||||||
init() {
|
init() {
|
||||||
// 刷新vuex
|
// 刷新本页vuex
|
||||||
this.$store.replaceState(
|
replaceState.call(this);
|
||||||
Object.assign(
|
|
||||||
this.$store.state,
|
|
||||||
JSON.parse(localStorage.getItem("storeState"))
|
|
||||||
)
|
|
||||||
);
|
|
||||||
this.initLanguage();
|
this.initLanguage();
|
||||||
// 判断页面类型
|
// 判断页面类型
|
||||||
if (
|
if (
|
||||||
|
@ -120,6 +120,8 @@ import {
|
|||||||
import { lang } from "@/utils/language.js";
|
import { lang } from "@/utils/language.js";
|
||||||
import { setHtmlFontSize } from "@/utils/px2rem.js";
|
import { setHtmlFontSize } from "@/utils/px2rem.js";
|
||||||
import { generatePassword } from "@/utils/generator.js";
|
import { generatePassword } from "@/utils/generator.js";
|
||||||
|
import { replaceState } from "@/utils/getStore.js";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Add",
|
name: "Add",
|
||||||
data() {
|
data() {
|
||||||
@ -155,7 +157,7 @@ export default {
|
|||||||
...mapState(["row_data", "row_pwd", "settings"]),
|
...mapState(["row_data", "row_pwd", "settings"]),
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(["setRowData", "setRowPwd"]),
|
...mapActions(["setRowData", "setRowPwd", "setSettings", "setUserInfo"]),
|
||||||
// 修改md-app的最小高度
|
// 修改md-app的最小高度
|
||||||
changeFixed(clientHeight) {
|
changeFixed(clientHeight) {
|
||||||
//动态修改样式
|
//动态修改样式
|
||||||
@ -172,13 +174,8 @@ export default {
|
|||||||
},
|
},
|
||||||
// 初始化
|
// 初始化
|
||||||
init() {
|
init() {
|
||||||
// 刷新vuex
|
// 刷新本页vuex
|
||||||
this.$store.replaceState(
|
replaceState.call(this);
|
||||||
Object.assign(
|
|
||||||
this.$store.state,
|
|
||||||
JSON.parse(localStorage.getItem("storeState"))
|
|
||||||
)
|
|
||||||
);
|
|
||||||
// 判断有无用户密码
|
// 判断有无用户密码
|
||||||
if (Object.keys(this.row_pwd).length != 0) {
|
if (Object.keys(this.row_pwd).length != 0) {
|
||||||
// 有密码,已经输入过了
|
// 有密码,已经输入过了
|
||||||
|
@ -106,6 +106,7 @@ import {
|
|||||||
} from "@/utils/aes.js";
|
} from "@/utils/aes.js";
|
||||||
import { lang } from "@/utils/language.js";
|
import { lang } from "@/utils/language.js";
|
||||||
import { setHtmlFontSize } from "@/utils/px2rem.js";
|
import { setHtmlFontSize } from "@/utils/px2rem.js";
|
||||||
|
import { replaceState } from "@/utils/getStore.js";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Add",
|
name: "Add",
|
||||||
@ -133,7 +134,7 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(["setRowData", "setRowPwd"]),
|
...mapActions(["setRowData", "setRowPwd", "setSettings", "setUserInfo"]),
|
||||||
// 修改md-app的最小高度
|
// 修改md-app的最小高度
|
||||||
changeFixed(clientHeight) {
|
changeFixed(clientHeight) {
|
||||||
//动态修改样式
|
//动态修改样式
|
||||||
@ -149,13 +150,8 @@ export default {
|
|||||||
},
|
},
|
||||||
// 初始化
|
// 初始化
|
||||||
init() {
|
init() {
|
||||||
// 刷新vuex
|
// 刷新本页vuex
|
||||||
this.$store.replaceState(
|
replaceState.call(this);
|
||||||
Object.assign(
|
|
||||||
this.$store.state,
|
|
||||||
JSON.parse(localStorage.getItem("storeState"))
|
|
||||||
)
|
|
||||||
);
|
|
||||||
// 判断是否有参数
|
// 判断是否有参数
|
||||||
if (this.$route.params.code_content) {
|
if (this.$route.params.code_content) {
|
||||||
// 判断有无用户密码
|
// 判断有无用户密码
|
||||||
|
@ -78,6 +78,7 @@ import { mapState, mapActions } from "vuex";
|
|||||||
import { lang } from "@/utils/language.js";
|
import { lang } from "@/utils/language.js";
|
||||||
import { generatePassword } from "@/utils/generator.js";
|
import { generatePassword } from "@/utils/generator.js";
|
||||||
import { setHtmlFontSize } from "@/utils/px2rem.js";
|
import { setHtmlFontSize } from "@/utils/px2rem.js";
|
||||||
|
import { replaceState } from "@/utils/getStore.js";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Add",
|
name: "Add",
|
||||||
@ -127,13 +128,8 @@ export default {
|
|||||||
},
|
},
|
||||||
// 初始化
|
// 初始化
|
||||||
init() {
|
init() {
|
||||||
// 刷新vuex
|
// 刷新本页vuex
|
||||||
this.$store.replaceState(
|
replaceState.call(this);
|
||||||
Object.assign(
|
|
||||||
this.$store.state,
|
|
||||||
JSON.parse(localStorage.getItem("storeState"))
|
|
||||||
)
|
|
||||||
);
|
|
||||||
// 判断有无用户密码
|
// 判断有无用户密码
|
||||||
if (Object.keys(this.row_pwd).length != 0) {
|
if (Object.keys(this.row_pwd).length != 0) {
|
||||||
// 有密码,已经输入过了
|
// 有密码,已经输入过了
|
||||||
|
@ -152,6 +152,7 @@ import {
|
|||||||
} from "@/utils/aes.js";
|
} from "@/utils/aes.js";
|
||||||
import { lang } from "@/utils/language.js";
|
import { lang } from "@/utils/language.js";
|
||||||
import { setHtmlFontSize } from "@/utils/px2rem.js";
|
import { setHtmlFontSize } from "@/utils/px2rem.js";
|
||||||
|
import { replaceState } from "@/utils/getStore.js";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Home",
|
name: "Home",
|
||||||
@ -215,16 +216,9 @@ export default {
|
|||||||
|
|
||||||
// 初始化
|
// 初始化
|
||||||
init() {
|
init() {
|
||||||
// 刷新vuex
|
// 刷新本页vuex
|
||||||
this.$store.replaceState(
|
replaceState.call(this);
|
||||||
Object.assign(
|
this.initLanguage();
|
||||||
this.$store.state,
|
|
||||||
JSON.parse(localStorage.getItem("storeState"))
|
|
||||||
)
|
|
||||||
);
|
|
||||||
// 初始化
|
|
||||||
this.initUserInfo();
|
|
||||||
this.initSettings();
|
|
||||||
// 判断有无用户密码
|
// 判断有无用户密码
|
||||||
if (Object.keys(this.row_pwd).length != 0) {
|
if (Object.keys(this.row_pwd).length != 0) {
|
||||||
// 有密码,已经输入过了
|
// 有密码,已经输入过了
|
||||||
@ -282,44 +276,14 @@ export default {
|
|||||||
console.log(this.unlock ? "已解锁" : "未解锁");
|
console.log(this.unlock ? "已解锁" : "未解锁");
|
||||||
},
|
},
|
||||||
|
|
||||||
// 初始化用户信息
|
// 配置语言
|
||||||
initUserInfo() {
|
initLanguage() {
|
||||||
if (Object.keys(this.user_infos).length == 0) {
|
|
||||||
// 初始化用户信息
|
|
||||||
let user_infos = {
|
|
||||||
user_name: "A Little Canary",
|
|
||||||
cid: "Codebook",
|
|
||||||
row_login_pwd: "",
|
|
||||||
drivce: "",
|
|
||||||
cloud_drivce: this.settings.is_chinese ? "暂无" : "unknown",
|
|
||||||
update_time: new Date().getTime(),
|
|
||||||
};
|
|
||||||
this.setUserInfo([user_infos, this]);
|
|
||||||
console.log("用户信息覆写完成");
|
|
||||||
}
|
|
||||||
console.log("用户信息初始化完成");
|
|
||||||
},
|
|
||||||
|
|
||||||
// 初始化配置信息
|
|
||||||
initSettings() {
|
|
||||||
if (Object.keys(this.settings).length == 0) {
|
|
||||||
// 初始化配置信息
|
|
||||||
let settings = {
|
|
||||||
is_chinese: true,
|
|
||||||
is_dark_mode: false,
|
|
||||||
expired_time: 300000, // 5分钟
|
|
||||||
};
|
|
||||||
this.setSettings([settings, this]);
|
|
||||||
console.log("配置信息覆写完成");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.settings.is_chinese) {
|
if (this.settings.is_chinese) {
|
||||||
this.lang = lang().home.CHS;
|
this.lang = lang().home.CHS;
|
||||||
} else {
|
} else {
|
||||||
this.lang = lang().home.EN;
|
this.lang = lang().home.EN;
|
||||||
}
|
}
|
||||||
console.log("语言配置完成");
|
console.log("语言配置完成");
|
||||||
console.log("配置信息初始化完成");
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// 修改排序
|
// 修改排序
|
||||||
|
@ -100,6 +100,8 @@
|
|||||||
</md-list-item>
|
</md-list-item>
|
||||||
</md-list>
|
</md-list>
|
||||||
|
|
||||||
|
<div style="height: 1rem;"></div>
|
||||||
|
|
||||||
<md-dialog-prompt
|
<md-dialog-prompt
|
||||||
:md-active.sync="reset_row_data_active"
|
:md-active.sync="reset_row_data_active"
|
||||||
v-model="new_row_data"
|
v-model="new_row_data"
|
||||||
@ -152,6 +154,7 @@ import {
|
|||||||
import { login, activation, syncLocal, syncCloud } from "@/axios/api.js";
|
import { login, activation, syncLocal, syncCloud } from "@/axios/api.js";
|
||||||
import { lang } from "@/utils/language.js";
|
import { lang } from "@/utils/language.js";
|
||||||
import { setHtmlFontSize } from "@/utils/px2rem.js";
|
import { setHtmlFontSize } from "@/utils/px2rem.js";
|
||||||
|
import { replaceState } from "@/utils/getStore.js";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Add",
|
name: "Add",
|
||||||
@ -209,13 +212,8 @@ export default {
|
|||||||
},
|
},
|
||||||
// 初始化
|
// 初始化
|
||||||
init() {
|
init() {
|
||||||
// 刷新vuex
|
// 刷新本页vuex
|
||||||
this.$store.replaceState(
|
replaceState.call(this);
|
||||||
Object.assign(
|
|
||||||
this.$store.state,
|
|
||||||
JSON.parse(localStorage.getItem("storeState"))
|
|
||||||
)
|
|
||||||
);
|
|
||||||
// 判断有无用户密码
|
// 判断有无用户密码
|
||||||
if (Object.keys(this.row_pwd).length != 0) {
|
if (Object.keys(this.row_pwd).length != 0) {
|
||||||
// 有密码,已经输入过了
|
// 有密码,已经输入过了
|
||||||
|
@ -30,7 +30,10 @@
|
|||||||
|
|
||||||
<p class="center tips">
|
<p class="center tips">
|
||||||
此密码本为长理专版,未开启同步密码将加密后存放本地,开启同步密码将加密后存放在您的长理网盘中,请放心使用
|
此密码本为长理专版,未开启同步密码将加密后存放本地,开启同步密码将加密后存放在您的长理网盘中,请放心使用
|
||||||
<span class="qq-link" @click="openQQ()">点我加入用户群</span>
|
<span
|
||||||
|
class="qq-link"
|
||||||
|
@click="openQQ()"
|
||||||
|
>点我加入用户群</span>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<md-dialog-confirm
|
<md-dialog-confirm
|
||||||
@ -59,6 +62,7 @@ import {
|
|||||||
decryptMainCode,
|
decryptMainCode,
|
||||||
} from "@/utils/aes.js";
|
} from "@/utils/aes.js";
|
||||||
import { lang } from "@/utils/language.js";
|
import { lang } from "@/utils/language.js";
|
||||||
|
import { replaceState } from "@/utils/getStore.js";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Unlock",
|
name: "Unlock",
|
||||||
@ -92,17 +96,12 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(["setRowPwd", "setUserInfo"]),
|
...mapActions(["setRowPwd", "setSettings", "setUserInfo"]),
|
||||||
|
|
||||||
// 初始化
|
// 初始化
|
||||||
init() {
|
init() {
|
||||||
// 刷新vuex
|
// 刷新本页vuex
|
||||||
this.$store.replaceState(
|
replaceState.call(this);
|
||||||
Object.assign(
|
|
||||||
this.$store.state,
|
|
||||||
JSON.parse(localStorage.getItem("storeState"))
|
|
||||||
)
|
|
||||||
);
|
|
||||||
this.initLanguage();
|
this.initLanguage();
|
||||||
// 判断是创建密码还是输入密码
|
// 判断是创建密码还是输入密码
|
||||||
this.is_create = !this.row_data && !this.user_infos.drivce;
|
this.is_create = !this.row_data && !this.user_infos.drivce;
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
import { mapState } from "vuex";
|
import { mapState } from "vuex";
|
||||||
import { lang } from "@/utils/language.js";
|
import { lang } from "@/utils/language.js";
|
||||||
import { setHtmlFontSize } from "@/utils/px2rem.js";
|
import { setHtmlFontSize } from "@/utils/px2rem.js";
|
||||||
|
import { replaceState } from "@/utils/getStore.js";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "UpdateLog",
|
name: "UpdateLog",
|
||||||
@ -50,6 +51,7 @@ export default {
|
|||||||
...mapState(["row_pwd", "settings"]),
|
...mapState(["row_pwd", "settings"]),
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
...mapActions(["setSettings", "setUserInfo"]),
|
||||||
// 修改md-app的最小高度
|
// 修改md-app的最小高度
|
||||||
changeFixed(clientHeight) {
|
changeFixed(clientHeight) {
|
||||||
//动态修改样式
|
//动态修改样式
|
||||||
@ -67,13 +69,8 @@ export default {
|
|||||||
|
|
||||||
// 初始化
|
// 初始化
|
||||||
init() {
|
init() {
|
||||||
// 刷新vuex
|
// 刷新本页vuex
|
||||||
this.$store.replaceState(
|
replaceState.call(this);
|
||||||
Object.assign(
|
|
||||||
this.$store.state,
|
|
||||||
JSON.parse(localStorage.getItem("storeState"))
|
|
||||||
)
|
|
||||||
);
|
|
||||||
// 判断有无用户密码
|
// 判断有无用户密码
|
||||||
if (Object.keys(this.row_pwd).length != 0) {
|
if (Object.keys(this.row_pwd).length != 0) {
|
||||||
// 有密码,已经输入过了
|
// 有密码,已经输入过了
|
||||||
|
Loading…
x
Reference in New Issue
Block a user