token和uuid读写删规范化
Former-commit-id: 5ff408c16c699f9f091a62074faf5c106efd32f5 [formerly 0d9ff5deffb9da11589abd20110adf0e521eea2b] [formerly 5ff408c16c699f9f091a62074faf5c106efd32f5 [formerly 0d9ff5deffb9da11589abd20110adf0e521eea2b] [formerly 5ff408c16c699f9f091a62074faf5c106efd32f5 [formerly 0d9ff5deffb9da11589abd20110adf0e521eea2b] [formerly 0d9ff5deffb9da11589abd20110adf0e521eea2b [formerly ec676c00b7d7b5b3de61ef47d9aac8d011c283c1 [formerly c00f0271d0b118666a8756a52e249e4a586eacb3]]]]] Former-commit-id: 7130c868e62e0dba1950cc14574880c96aebb8a7 Former-commit-id: 6525fbdf43121e93600361ed4337e691c481ce6d Former-commit-id: 70ca5629d20eed82c03ddcd2a2c25b10ea336d8e [formerly 486ff5e6084bdc51abe51b4bdda7436477ccd26a] Former-commit-id: 2809e202549f5586a5a0be20f04be268c0e326ea Former-commit-id: 818655905c96238e07983c596e94326a4dc1a315 Former-commit-id: aa3e2b37cc07f231fb860edfc4803ebc3df5ec4f Former-commit-id: 22df71608a20275b7c0a7b290b1c588fa3c9d02b Former-commit-id: 121632e21d5161f53048cd6513d0f7d07a9cb580
This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
* [ 修改 ] d2-container 组件重构,每种模式现都支持 scroll 属性以及 header footer 插槽
|
* [ 修改 ] d2-container 组件重构,每种模式现都支持 scroll 属性以及 header footer 插槽
|
||||||
* [ 修改 ] 修复全屏按钮退出全屏状态不更新的 bug
|
* [ 修改 ] 修复全屏按钮退出全屏状态不更新的 bug
|
||||||
* [ 修改 ] 修复多标签页缓存逻辑 bug
|
* [ 修改 ] 修复多标签页缓存逻辑 bug
|
||||||
|
* [ 新增 ] 持久化存储根据系统版本区分数据,防止因更新导致数据错乱
|
||||||
|
|
||||||
## v1.1.4
|
## v1.1.4
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import low from 'lowdb'
|
import low from 'lowdb'
|
||||||
import LocalStorage from 'lowdb/adapters/LocalStorage'
|
import LocalStorage from 'lowdb/adapters/LocalStorage'
|
||||||
import packJson from '../../package'
|
import { version } from '../../package'
|
||||||
|
|
||||||
const adapter = new LocalStorage(`d2admin${packJson.version}`)
|
const adapter = new LocalStorage(`d2admin-${version}`)
|
||||||
const db = low(adapter)
|
const db = low(adapter)
|
||||||
|
|
||||||
db.defaults({
|
db.defaults({
|
||||||
|
|||||||
@@ -1,20 +1,64 @@
|
|||||||
// 插件
|
|
||||||
import Cookies from 'js-cookie'
|
import Cookies from 'js-cookie'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import semver from 'semver'
|
import semver from 'semver'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import UaParser from 'ua-parser-js'
|
import UaParser from 'ua-parser-js'
|
||||||
|
import { version } from '../../package.json'
|
||||||
// 获取项目信息
|
|
||||||
import packJson from '../../package.json'
|
|
||||||
|
|
||||||
let util = {}
|
let util = {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 存储 uuid 到 cookie
|
||||||
|
* @param {string} value uuid value
|
||||||
|
* @param {object} setting cookie setting
|
||||||
|
*/
|
||||||
|
util.uuidSet = function (value = '', setting = {}) {
|
||||||
|
let cookieSetting = {
|
||||||
|
expires: 1
|
||||||
|
}
|
||||||
|
Object.assign(cookieSetting, setting)
|
||||||
|
Cookies.set(`d2admin-${version}-uuid`, value, cookieSetting)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 得到现在的用户 uuid
|
* @description 得到现在的用户 uuid
|
||||||
*/
|
*/
|
||||||
util.uuid = function () {
|
util.uuidGet = function () {
|
||||||
return Cookies.get('uuid')
|
return Cookies.get(`d2admin-${version}-uuid`)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 删除用户 uuid
|
||||||
|
*/
|
||||||
|
util.uuidRemove = function () {
|
||||||
|
return Cookies.remove(`d2admin-${version}-uuid`)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 存储 token 到 cookie
|
||||||
|
* @param {string} value token value
|
||||||
|
* @param {object} setting cookie setting
|
||||||
|
*/
|
||||||
|
util.tokenSet = function (value = '', setting = {}) {
|
||||||
|
let cookieSetting = {
|
||||||
|
expires: 1
|
||||||
|
}
|
||||||
|
Object.assign(cookieSetting, setting)
|
||||||
|
Cookies.set(`d2admin-${version}-token`, value, cookieSetting)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 得到现在的用户 token
|
||||||
|
*/
|
||||||
|
util.tokenGet = function () {
|
||||||
|
return Cookies.get(`d2admin-${version}-token`)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 删除用户 token
|
||||||
|
*/
|
||||||
|
util.tokenRemove = function () {
|
||||||
|
return Cookies.remove(`d2admin-${version}-token`)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -66,8 +110,8 @@ util.logCapsule = function (title, info) {
|
|||||||
util.checkUpdate = function (vm) {
|
util.checkUpdate = function (vm) {
|
||||||
axios.get('https://api.github.com/repos/FairyEver/d2-admin/releases/latest')
|
axios.get('https://api.github.com/repos/FairyEver/d2-admin/releases/latest')
|
||||||
.then(res => {
|
.then(res => {
|
||||||
let version = res.tag_name
|
let versionGet = res.tag_name
|
||||||
const update = semver.lt(packJson.version, version)
|
const update = semver.lt(version, versionGet)
|
||||||
if (update) {
|
if (update) {
|
||||||
util.logCapsule('D2Admin', `New version ${res.name}`)
|
util.logCapsule('D2Admin', `New version ${res.name}`)
|
||||||
console.log(`${dayjs(res.created_at).format('YYYY年M月D日')}更新 版本号: ${res.tag_name} | 详情${res.html_url}`)
|
console.log(`${dayjs(res.created_at).format('YYYY年M月D日')}更新 版本号: ${res.tag_name} | 详情${res.html_url}`)
|
||||||
@@ -83,7 +127,7 @@ util.checkUpdate = function (vm) {
|
|||||||
* @description 显示版本信息
|
* @description 显示版本信息
|
||||||
*/
|
*/
|
||||||
util.showInfo = function showInfo () {
|
util.showInfo = function showInfo () {
|
||||||
util.logCapsule('D2Admin', `v${packJson.version}`)
|
util.logCapsule('D2Admin', `v${version}`)
|
||||||
console.log('Github https://github.com/d2-projects/d2-admin')
|
console.log('Github https://github.com/d2-projects/d2-admin')
|
||||||
console.log('Doc http://d2admin.fairyever.com/zh/')
|
console.log('Doc http://d2admin.fairyever.com/zh/')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import VueRouter from 'vue-router'
|
import VueRouter from 'vue-router'
|
||||||
import Cookies from 'js-cookie'
|
|
||||||
|
|
||||||
import util from '@/libs/util.js'
|
import util from '@/libs/util.js'
|
||||||
|
|
||||||
@@ -20,7 +19,7 @@ router.beforeEach((to, from, next) => {
|
|||||||
if (to.matched.some(r => r.meta.requiresAuth)) {
|
if (to.matched.some(r => r.meta.requiresAuth)) {
|
||||||
// 这里暂时将cookie里是否存有token作为验证是否登陆的条件
|
// 这里暂时将cookie里是否存有token作为验证是否登陆的条件
|
||||||
// 请根据自身业务需要修改
|
// 请根据自身业务需要修改
|
||||||
const token = Cookies.get('token')
|
const token = util.tokenGet()
|
||||||
if (token && token !== 'undefined') {
|
if (token && token !== 'undefined') {
|
||||||
next()
|
next()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
64064c51b45b2afec348c3affc84f8e669fd4ab6
|
1e89dc28cf748ef4d1f3174b7b791e527d4a4c1b
|
||||||
Reference in New Issue
Block a user