Merge branch 'master' into chore/update
This commit is contained in:
commit
c1ce24081e
|
@ -155,7 +155,7 @@ export default {
|
||||||
toLastView(visitedViews, view) {
|
toLastView(visitedViews, view) {
|
||||||
const latestView = visitedViews.slice(-1)[0]
|
const latestView = visitedViews.slice(-1)[0]
|
||||||
if (latestView) {
|
if (latestView) {
|
||||||
this.$router.push(latestView)
|
this.$router.push(latestView.fullPath)
|
||||||
} else {
|
} else {
|
||||||
// now the default is to redirect to the home page if there is no tags-view,
|
// now the default is to redirect to the home page if there is no tags-view,
|
||||||
// you can adjust it according to your needs.
|
// you can adjust it according to your needs.
|
||||||
|
|
|
@ -28,13 +28,8 @@ const mutations = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
DEL_CACHED_VIEW: (state, view) => {
|
DEL_CACHED_VIEW: (state, view) => {
|
||||||
for (const i of state.cachedViews) {
|
const index = state.cachedViews.indexOf(view.name)
|
||||||
if (i === view.name) {
|
index > -1 && state.cachedViews.splice(index, 1)
|
||||||
const index = state.cachedViews.indexOf(i)
|
|
||||||
state.cachedViews.splice(index, 1)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
DEL_OTHERS_VISITED_VIEWS: (state, view) => {
|
DEL_OTHERS_VISITED_VIEWS: (state, view) => {
|
||||||
|
@ -43,12 +38,12 @@ const mutations = {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
DEL_OTHERS_CACHED_VIEWS: (state, view) => {
|
DEL_OTHERS_CACHED_VIEWS: (state, view) => {
|
||||||
for (const i of state.cachedViews) {
|
const index = state.cachedViews.indexOf(view.name)
|
||||||
if (i === view.name) {
|
if (index > -1) {
|
||||||
const index = state.cachedViews.indexOf(i)
|
|
||||||
state.cachedViews = state.cachedViews.slice(index, index + 1)
|
state.cachedViews = state.cachedViews.slice(index, index + 1)
|
||||||
break
|
} else {
|
||||||
}
|
// if index = -1, there is no cached tags
|
||||||
|
state.cachedViews = []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -73,13 +73,18 @@ const actions = {
|
||||||
},
|
},
|
||||||
|
|
||||||
// user logout
|
// user logout
|
||||||
logout({ commit, state }) {
|
logout({ commit, state, dispatch }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
logout(state.token).then(() => {
|
logout(state.token).then(() => {
|
||||||
commit('SET_TOKEN', '')
|
commit('SET_TOKEN', '')
|
||||||
commit('SET_ROLES', [])
|
commit('SET_ROLES', [])
|
||||||
removeToken()
|
removeToken()
|
||||||
resetRouter()
|
resetRouter()
|
||||||
|
|
||||||
|
// reset visited views and cached views
|
||||||
|
// to fixed https://github.com/PanJiaChen/vue-element-admin/issues/2485
|
||||||
|
dispatch('tagsView/delAllViews', null, { root: true })
|
||||||
|
|
||||||
resolve()
|
resolve()
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
reject(error)
|
reject(error)
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* Parse the time to string
|
* Parse the time to string
|
||||||
* @param {(Object|string|number)} time
|
* @param {(Object|string|number)} time
|
||||||
* @param {string} cFormat
|
* @param {string} cFormat
|
||||||
* @returns {string}
|
* @returns {string | null}
|
||||||
*/
|
*/
|
||||||
export function parseTime(time, cFormat) {
|
export function parseTime(time, cFormat) {
|
||||||
if (arguments.length === 0) {
|
if (arguments.length === 0) {
|
||||||
|
@ -34,14 +34,11 @@ export function parseTime(time, cFormat) {
|
||||||
s: date.getSeconds(),
|
s: date.getSeconds(),
|
||||||
a: date.getDay()
|
a: date.getDay()
|
||||||
}
|
}
|
||||||
const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
|
const time_str = format.replace(/{([ymdhisa])+}/g, (result, key) => {
|
||||||
let value = formatObj[key]
|
const value = formatObj[key]
|
||||||
// Note: getDay() returns 0 on Sunday
|
// Note: getDay() returns 0 on Sunday
|
||||||
if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value ] }
|
if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value ] }
|
||||||
if (result.length > 0 && value < 10) {
|
return value.toString().padStart(2, '0')
|
||||||
value = '0' + value
|
|
||||||
}
|
|
||||||
return value || 0
|
|
||||||
})
|
})
|
||||||
return time_str
|
return time_str
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,8 +170,6 @@ export default {
|
||||||
if (this.isEdit) {
|
if (this.isEdit) {
|
||||||
const id = this.$route.params && this.$route.params.id
|
const id = this.$route.params && this.$route.params.id
|
||||||
this.fetchData(id)
|
this.fetchData(id)
|
||||||
} else {
|
|
||||||
this.postForm = Object.assign({}, defaultForm)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Why need to make a copy of this.$route here?
|
// Why need to make a copy of this.$route here?
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
import ArticleDetail from './components/ArticleDetail'
|
import ArticleDetail from './components/ArticleDetail'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'CreateForm',
|
name: 'CreateArticle',
|
||||||
components: { ArticleDetail }
|
components: { ArticleDetail }
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue