first commit

This commit is contained in:
x ronger 2020-06-21 21:56:34 +08:00
parent dffb88bf1c
commit 509773ccbf
12 changed files with 338 additions and 320 deletions

View File

@ -1,7 +1,7 @@
<template>
<el-row class="wrapper">
<el-col :xs="24" :sm="24" :xl="24" style="margin: 0 auto;">
<el-col v-for="article in articles" :key="article.idArticle" style="padding-bottom: 1rem;">
<el-col v-for="article in articles.data" :key="article.idArticle" style="padding-bottom: 1rem;">
<el-card>
<div class="card-body d-flex flex-column">
<el-link @click="onRouter('article',article.articleLink)" :underline="false" style="margin-bottom: .5rem;">
@ -49,52 +49,29 @@
</template>
<script>
export default {
name: "AsideMain",
import Vue from 'vue';
import { mapState } from 'vuex';
export default Vue.extend({
name: "PcAside",
data() {
return {
articles: [],
pagination: {
currentPage: 1,
pageSize: 10,
total: 0
}
}
},
computed: {
...mapState({
articles: state => state.article.list.data,
pagination: state => state.article.list.data.pagination
})
},
methods: {
currentChange(val){
this.getData(val);
},
async getData(p){
let _ts = this;
const responseTopData = await this.axios.get('/console/articles?page='+p);
if (responseTopData) {
responseTopData.pagination.currentPage = p;
_ts.$set(_ts, 'articles', responseTopData.articles);
_ts.$set(_ts, 'pagination', responseTopData.pagination);
window.scrollTo(0, 0);
}
},
onRouter (name, data) {
if (name === 'article') {
this.$router.push({
path: data
})
} else {
this.$router.push(
{
path: '/user/' + data
}
)
}
currentChange(p) {
console.log(p);
}
},
mounted () {
this.$store.commit('setActiveMenu', 'home');
const p = this.pagination.currentPage;
this.getData(p);
}
}
})
</script>
<style scoped>

View File

@ -13,6 +13,7 @@
</template>
<script>
import { mapState } from 'vuex'
import HeaderView from "./header";
import FooterView from "./footer";
import AsideView from './aside/main';
@ -23,6 +24,9 @@
HeaderView,
FooterView,
AsideView
},
computed: {
...mapState('global', [])
}
}
</script>

15
environment.js Normal file
View File

@ -0,0 +1,15 @@
/**
* @file Environment / ES module
* @module environment
* @author Surmon <https://github.com/surmon-china>
*/
export const environment = process.env
export const NODE_ENV = environment.NODE_ENV
export const isDevMode = Object.is(NODE_ENV, 'development')
export const isProdMode = Object.is(NODE_ENV, 'production')
export const isStatic = process && process.static
export const isServer = process && process.server
export const isBrowser = process && process.browser
export const isModern = process && process.modern

View File

@ -1,8 +1,30 @@
<template>
<div>
<nuxt />
<pc-main-view v-if="!isMobile"/>
<mobile-main-view v-else/>
</div>
</template>
<script>
import Vue from 'vue';
import PcMainView from '~/components/layouts/pc/main.vue';
import MobileMainView from '~/components/layouts/mobile/main.vue';
export default Vue.extend({
name: 'App',
components: {
PcMainView,
MobileMainView
},
computed: {
theme() {
return this.$store.state.global.theme
},
isMobile() {
return this.$store.state.global.isMobile
}
}
})
</script>
<style>
body {
@ -15,11 +37,13 @@
}
a, li {
text-decoration:none !important;
text-decoration: none !important;
}
h1 a, h2 a, h3 a, h4 a, h5 a, h6 a, .h1 a, .h2 a, .h3 a, .h4 a, .h5 a, .h6 a {
color: inherit;
}
h4, .h4 {
font-size: 1.125rem;
}
@ -81,38 +105,38 @@
}
.article-summary-md {
position:relative;
line-height:1.4em;
position: relative;
line-height: 1.4em;
/* 3 times the line-height to show 3 lines */
height:4.2em;
overflow:hidden;
height: 4.2em;
overflow: hidden;
}
.article-summary-md::after {
content:"...";
font-weight:bold;
position:absolute;
bottom:0;
right:0;
padding:0 20px 1px 45px;
content: "...";
font-weight: bold;
position: absolute;
bottom: 0;
right: 0;
padding: 0 20px 1px 45px;
/*background:url(http://newimg88.b0.upaiyun.com/newimg88/2014/09/ellipsis_bg.png) repeat-y;*/
}
.article-summary-sd {
position:relative;
line-height:1.4em;
position: relative;
line-height: 1.4em;
/* 1 times the line-height to show 1 lines */
height:1.4em;
overflow:hidden;
height: 1.4em;
overflow: hidden;
}
.article-summary-sd::after {
content:"...";
font-weight:bold;
position:absolute;
bottom:0;
right:0;
padding:0 20px 1px 45px;
content: "...";
font-weight: bold;
position: absolute;
bottom: 0;
right: 0;
padding: 0 20px 1px 45px;
/*background:url(http://newimg88.b0.upaiyun.com/newimg88/2014/09/ellipsis_bg.png) repeat-y;*/
}
@ -154,6 +178,7 @@
.text-left {
text-align: left;
}
.text-right {
text-align: right;
}

View File

@ -6,11 +6,23 @@ export default {
*/
mode: 'universal',
/*
** Render configuration
*/
render: {
csp: true
},
/*
** Environment variable configuration
*/
env: {
baseUrl: 'http://127.0.0.1:8099'
},
/*
** Headers of the page
** See https://nuxtjs.org/api/configuration-head
*/
head: {
title: process.env.npm_package_name || '',
title: 'RYMCU - 嵌入式知识学习交流平台',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
@ -32,7 +44,7 @@ export default {
*/
plugins: [
'@/plugins/element-ui',
'@/plugins/axios'
// '@/plugins/axios'
],
/*
** Nuxt.js dev-modules
@ -43,6 +55,7 @@ export default {
** Nuxt.js modules
*/
modules: [
'@nuxtjs/axios'
],
/*
** Build configuration
@ -52,6 +65,9 @@ export default {
transpile: [/^element-ui/],
},
proxy: {
'/api': 'http://localhost:8099/vertical/'
'/api': {
target: 'http://localhost:8099/vertical/',
}
}
}

127
package-lock.json generated
View File

@ -1404,6 +1404,27 @@
"webpackbar": "^4.0.0"
}
},
"@nuxtjs/axios": {
"version": "5.11.0",
"resolved": "https://registry.npm.taobao.org/@nuxtjs/axios/download/@nuxtjs/axios-5.11.0.tgz",
"integrity": "sha1-J9cpemnhHDkDm5ysrGHi4NDgDx8=",
"requires": {
"@nuxtjs/proxy": "^2.0.0",
"axios": "^0.19.2",
"axios-retry": "^3.1.8",
"consola": "^2.11.3",
"defu": "^2.0.2"
}
},
"@nuxtjs/proxy": {
"version": "2.0.0",
"resolved": "https://registry.npm.taobao.org/@nuxtjs/proxy/download/@nuxtjs/proxy-2.0.0.tgz",
"integrity": "sha1-zxmJTqxyGirYlik/JBNx8Ebbcec=",
"requires": {
"consola": "^2.11.3",
"http-proxy-middleware": "^1.0.4"
}
},
"@nuxtjs/youch": {
"version": "4.2.3",
"resolved": "https://registry.npm.taobao.org/@nuxtjs/youch/download/@nuxtjs/youch-4.2.3.tgz",
@ -1436,6 +1457,14 @@
"resolved": "https://registry.npm.taobao.org/@types/html-minifier-terser/download/@types/html-minifier-terser-5.1.0.tgz",
"integrity": "sha1-VRpFibbuLMnB3/CAVhKK7Cm5SIA="
},
"@types/http-proxy": {
"version": "1.17.4",
"resolved": "https://registry.npm.taobao.org/@types/http-proxy/download/@types/http-proxy-1.17.4.tgz",
"integrity": "sha1-58kuPb4+E6p5lED/QubToXqdBFs=",
"requires": {
"@types/node": "*"
}
},
"@types/json-schema": {
"version": "7.0.5",
"resolved": "https://registry.npm.taobao.org/@types/json-schema/download/@types/json-schema-7.0.5.tgz?cache=0&sync_timestamp=1591720889158&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40types%2Fjson-schema%2Fdownload%2F%40types%2Fjson-schema-7.0.5.tgz",
@ -2081,6 +2110,14 @@
"follow-redirects": "1.5.10"
}
},
"axios-retry": {
"version": "3.1.8",
"resolved": "https://registry.npm.taobao.org/axios-retry/download/axios-retry-3.1.8.tgz",
"integrity": "sha1-/8/tdX4fq4y/gy+FBbsOCvR8Ugw=",
"requires": {
"is-retry-allowed": "^1.1.0"
}
},
"babel-helper-vue-jsx-merge-props": {
"version": "2.0.3",
"resolved": "https://registry.npm.taobao.org/babel-helper-vue-jsx-merge-props/download/babel-helper-vue-jsx-merge-props-2.0.3.tgz",
@ -3196,6 +3233,14 @@
"resolved": "https://registry.npm.taobao.org/create-require/download/create-require-1.0.2.tgz",
"integrity": "sha1-A/l60IIoJuUGll84X9kDiPUFFiQ="
},
"cross-env": {
"version": "7.0.2",
"resolved": "https://registry.npm.taobao.org/cross-env/download/cross-env-7.0.2.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcross-env%2Fdownload%2Fcross-env-7.0.2.tgz",
"integrity": "sha1-vV7TEzmpOjQYrE88qco0Awgq5fk=",
"requires": {
"cross-spawn": "^7.0.1"
}
},
"cross-spawn": {
"version": "7.0.3",
"resolved": "https://registry.npm.taobao.org/cross-spawn/download/cross-spawn-7.0.3.tgz",
@ -3956,6 +4001,11 @@
"resolved": "https://registry.npm.taobao.org/etag/download/etag-1.8.1.tgz",
"integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc="
},
"eventemitter3": {
"version": "4.0.4",
"resolved": "https://registry.npm.taobao.org/eventemitter3/download/eventemitter3-4.0.4.tgz?cache=0&sync_timestamp=1589283150629&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Feventemitter3%2Fdownload%2Feventemitter3-4.0.4.tgz",
"integrity": "sha1-tUY6zmNaCD0Bi9x8kXtMXxCoU4Q="
},
"events": {
"version": "3.1.0",
"resolved": "https://registry.npm.taobao.org/events/download/events-3.1.0.tgz",
@ -5040,6 +5090,68 @@
}
}
},
"http-proxy": {
"version": "1.18.1",
"resolved": "https://registry.npm.taobao.org/http-proxy/download/http-proxy-1.18.1.tgz",
"integrity": "sha1-QBVB8FNIhLv5UmAzTnL4juOXZUk=",
"requires": {
"eventemitter3": "^4.0.0",
"follow-redirects": "^1.0.0",
"requires-port": "^1.0.0"
}
},
"http-proxy-middleware": {
"version": "1.0.4",
"resolved": "https://registry.npm.taobao.org/http-proxy-middleware/download/http-proxy-middleware-1.0.4.tgz?cache=0&sync_timestamp=1589915551464&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fhttp-proxy-middleware%2Fdownload%2Fhttp-proxy-middleware-1.0.4.tgz",
"integrity": "sha1-Ql6hd5hqDNo0+cgeyWHHGa22wqk=",
"requires": {
"@types/http-proxy": "^1.17.4",
"http-proxy": "^1.18.1",
"is-glob": "^4.0.1",
"lodash": "^4.17.15",
"micromatch": "^4.0.2"
},
"dependencies": {
"braces": {
"version": "3.0.2",
"resolved": "https://registry.npm.taobao.org/braces/download/braces-3.0.2.tgz",
"integrity": "sha1-NFThpGLujVmeI23zNs2epPiv4Qc=",
"requires": {
"fill-range": "^7.0.1"
}
},
"fill-range": {
"version": "7.0.1",
"resolved": "https://registry.npm.taobao.org/fill-range/download/fill-range-7.0.1.tgz",
"integrity": "sha1-GRmmp8df44ssfHflGYU12prN2kA=",
"requires": {
"to-regex-range": "^5.0.1"
}
},
"is-number": {
"version": "7.0.0",
"resolved": "https://registry.npm.taobao.org/is-number/download/is-number-7.0.0.tgz",
"integrity": "sha1-dTU0W4lnNNX4DE0GxQlVUnoU8Ss="
},
"micromatch": {
"version": "4.0.2",
"resolved": "https://registry.npm.taobao.org/micromatch/download/micromatch-4.0.2.tgz?cache=0&sync_timestamp=1588851826089&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fmicromatch%2Fdownload%2Fmicromatch-4.0.2.tgz",
"integrity": "sha1-T8sJmb+fvC/L3SEvbWKbmlbDklk=",
"requires": {
"braces": "^3.0.1",
"picomatch": "^2.0.5"
}
},
"to-regex-range": {
"version": "5.0.1",
"resolved": "https://registry.npm.taobao.org/to-regex-range/download/to-regex-range-5.0.1.tgz",
"integrity": "sha1-FkjESq58jZiKMmAY7XL1tN0DkuQ=",
"requires": {
"is-number": "^7.0.0"
}
}
}
},
"https-browserify": {
"version": "1.0.0",
"resolved": "https://registry.npm.taobao.org/https-browserify/download/https-browserify-1.0.0.tgz",
@ -5417,6 +5529,11 @@
"resolved": "https://registry.npm.taobao.org/is-resolvable/download/is-resolvable-1.1.0.tgz",
"integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg="
},
"is-retry-allowed": {
"version": "1.2.0",
"resolved": "https://registry.npm.taobao.org/is-retry-allowed/download/is-retry-allowed-1.2.0.tgz",
"integrity": "sha1-13hIi9CkZmo76KFIK58rqv7eqLQ="
},
"is-ssh": {
"version": "1.3.1",
"resolved": "https://registry.npm.taobao.org/is-ssh/download/is-ssh-1.3.1.tgz",
@ -8079,6 +8196,11 @@
"resolved": "https://registry.npm.taobao.org/repeat-string/download/repeat-string-1.6.1.tgz",
"integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc="
},
"requires-port": {
"version": "1.0.0",
"resolved": "https://registry.npm.taobao.org/requires-port/download/requires-port-1.0.0.tgz",
"integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8="
},
"resize-observer-polyfill": {
"version": "1.5.1",
"resolved": "https://registry.npm.taobao.org/resize-observer-polyfill/download/resize-observer-polyfill-1.5.1.tgz",
@ -9421,11 +9543,6 @@
"resolved": "https://registry.npm.taobao.org/vue/download/vue-2.6.11.tgz",
"integrity": "sha1-dllNh31LEiNEBuhONSdcbVFBJcU="
},
"vue-axios": {
"version": "2.1.5",
"resolved": "https://registry.npm.taobao.org/vue-axios/download/vue-axios-2.1.5.tgz",
"integrity": "sha1-GvS/EhjtcTCcdq+zjQ9oPjEsJKc="
},
"vue-client-only": {
"version": "2.0.0",
"resolved": "https://registry.npm.taobao.org/vue-client-only/download/vue-client-only-2.0.0.tgz",

View File

@ -9,11 +9,11 @@
"generate": "nuxt generate"
},
"dependencies": {
"axios": "^0.19.2",
"@nuxtjs/axios": "^5.11.0",
"cross-env": "^7.0.2",
"element-ui": "^2.13.2",
"nuxt": "^2.13.0",
"vditor": "^3.3.2",
"vue-axios": "^2.1.5"
"vditor": "^3.3.2"
},
"devDependencies": {}
}

View File

@ -1,30 +1,8 @@
<template>
<div>
<pc-main-view v-if="!isMobile"/>
<mobile-main-view v-else/>
</div>
</template>
<script>
import PcMainView from '~/components/layouts/pc/main.vue'
import MobileMainView from '~/components/layouts/mobile/main.vue'
export default {
components: {
PcMainView,
MobileMainView
},
computed: {
theme() {
return this.$store.state.theme
},
isMobile() {
return this.$store.state.isMobile
}
}
}
</script>
<style>
.el-header {
padding-bottom: 1rem;

View File

@ -1,88 +1,16 @@
import axios from 'axios'
import VueAxios from 'vue-axios'
import Vue from 'vue'
// eslint-disable-next-line no-unused-vars
export default (ctx) => {
const customAxios = axios.create({
baseURL: '/api',
timeout:'10000',
withCredentials: true
});
customAxios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
customAxios.defaults.headers.common['x-requested-with'] = 'XMLHttpRequest';
Vue.use(VueAxios, customAxios);
customAxios.interceptors.request.use((config) => {
if(config.url){
let token = localStorage.getItem("x-auth-token");
if (token) { // 判断是否存在token如果存在的话则每个http header都加上token
if (!(config.url.indexOf('console') > -1)){
config.headers.Authorization = `${token}`;
}
}
} else {
config.url = '/console/heartbeat'
}
// clear cache
// if (config.method === 'get') {
// let char = '?'
// if (config.url.split('?').length > 1) {
// char = '&'
// }
// config.url += `${char}${(new Date()).getTime()}`
// }
return config
}, function (error) {
return Promise.reject(error);
});
customAxios.interceptors.response.use((response) => {
let message;
if (typeof(response.data.data) !== 'undefined') {
message = response.data.data.message
} else if (typeof(response.data) !== 'undefined') {
message = response.data.message
}
if (response.data.success) {
return response.data.data
} else {
if(response.data.code === 0){
window.app.$message(message);
}else if(response.data.code === 401){
window.app.$store.commit('logout');
window.app.$router.push({
name: 'login',
query: {
historyUrl: window.location.href
}
})
}else if(response.data.code === 402){
window.app.$store.commit('logout');
window.app.$router.push({
name: 'login',
query: {
historyUrl: window.location.href
}
})
}else if(response.data.code === 404){
window.app.$message('操作失败,请稍后再试......')
}else if(response.data.code === 500){
window.app.$message('服务器正在开小差,请稍后再试......')
}
return false
}
}, (error) => {
/*console.log(ctx.app.store.state.locale)
ctx.store.commit('setSnackBar', {
snackBar: true,
snackMsg: ctx.app.i18n.t('requestError', ctx.app.store.state.locale)
})*/
return Promise.reject(error)
})
return customAxios
export default function ({ app: { $axios, $cookies } }) {
$axios.defaults.baseURL = process.env.baseUrl
$axios.defaults.timeout = 30000
$axios.interceptors.request.use(config => {
config.headers['X-Token'] = $cookies.get('token') || ''
config.headers['X-Device-Id'] = $cookies.get('clientId') || ''
config.headers['X-Uid'] = $cookies.get('userId') || ''
return config
})
$axios.interceptors.response.use(response => {
if (/^[4|5]/.test(response.status)) {
return Promise.reject(response.statusText)
}
return response.data
})
}

69
store/article.js Normal file
View File

@ -0,0 +1,69 @@
import Vue from 'vue';
import { isBrowser } from '~/environment';
const ARTICLE_API_PATH = 'article';
const getDefaultListData = () => {
return {
data: [],
pagination: {
total: 0,
currentPage: 0
}
}
}
export const state = () => ({
list: {
fetching: false,
data: getDefaultListData()
},
detail: {
fetching: false,
data: {}
}
})
export const mutations = () => ({
// 文章列表
updateListFetching(state, action) {
state.list.fetching = action
},
updateListData(state, action) {
state.list.data = action
},
// 文章详情
updateDetailFetching(state, action) {
state.detail.fetching = action
},
updateDetailData(state, action) {
state.detail.data = action
}
})
export const actions = () => ({
// 获取文章列表
fetchList({commit}, params = {}) {
const isRestart = !params.page || params.page === 1
const isLoadMore = params.page && params.page > 1
console.log(isRestart, isLoadMore)
// 清空已有数据
isRestart && commit('updateListData', getDefaultListData())
commit('updateListFetching', true)
return this.$axios
.$get(ARTICLE_API_PATH, {params})
.then(response => {
commit('updateListFetching', false)
isLoadMore
? commit('updateExistingListData', response.result)
: commit('updateListData', response.result)
if (isLoadMore && isBrowser) {
Vue.nextTick(() => {
window.scrollTo(0, 0);
})
}
})
.catch(error => commit('updateListFetching', false))
}
})

21
store/global.js Normal file
View File

@ -0,0 +1,21 @@
export const state = () => ({
theme: 'default',
isMobile: false,
// ua
userAgent: '',
// 默认语言
language: '',
})
export const getters = () => ({
isMobile: state => state.isMobile
})
export const mutations = () => ({
})
export const actions = () => ({
})

View File

@ -1,142 +1,10 @@
export const state = () => ({
locale: 'zh_CN',
version: '1.0.0',
isInit: false,
isLogin: false,
token: '',
nickname: '',
idUser: '',
blogTitle: '',
avatarURL: '',
blogURL: '/',
role: 0, // 0-no login, 1-admin, 2-blog admin, 3-blog author, 4-blog user, 5-visitor
blogs: [{
title: '',
id: ''
}],
snackMsg: '',
snackBar: false,
snackModify: 'error',
menu: [],
tagsItems: [],
bodySide: '',
login: false,
activeMenu: 'home',
activeAdminMenu: 'admin-dashboard',
activeTopic: '51mcu',
activeTag: 'news',
uploadHeaders: '',
theme: '',
isMobile: false
})
export const mutations = () => ({
setLogin(state, data) {
state.login = data
},
setActiveMenu(state, data) {
state.activeMenu = data
},
setActiveAdminMenu(state, data) {
state.activeAdminMenu = data
},
setActiveTopic(state, data) {
state.activeTopic = data
},
setActiveTag(state, data) {
state.activeTag = data
},
setUserInfo(state, data) {
state.avatarURL = data.avatarUrl;
state.nickname = data.nickname;
localStorage.setItem('avatarURL', data.avatarUrl);
localStorage.setItem('nickname', data.nickname);
},
initLogin(state, data) {
state.isLogin = true;
state.avatarURL = data.avatarUrl;
state.nickname = data.nickname;
state.token = data.token;
state.account = data.account;
state.role = data.weights;
state.idUser = data.idUser;
localStorage.setItem('isLogin', 'true');
localStorage.setItem('avatarURL', data.avatarUrl);
localStorage.setItem('nickname', data.nickname);
localStorage.setItem('account', data.account);
localStorage.setItem('idUser', data.idUser);
localStorage.setItem('x-auth-token', data.token);
localStorage.setItem('role', data.weights);
},
logout(state) {
state.isLogin = false;
state.avatarURL = '';
state.nickname = '';
state.token = '';
state.account = '';
state.role = '';
state.idUser = '';
localStorage.removeItem('isLogin');
localStorage.removeItem('avatarURL');
localStorage.removeItem('nickname');
localStorage.removeItem('account');
localStorage.removeItem('idUser');
localStorage.removeItem('x-auth-token');
localStorage.removeItem('role');
},
setUploadHeaders(state, data) {
state.uploadHeaders = data
}
})
export const actions = () => ({})
export const getters = () => ({
uploadHeaders(state) {
return state.uploadHeaders;
},
isLogin(state) {
if (!state.isLogin) {
state.isLogin = localStorage.getItem('isLogin'); //从localStorage中读取状态
state.nickname = localStorage.getItem('nickname');
state.avatarURL = localStorage.getItem('avatarURL') !== 'undefined' ? localStorage.getItem('avatarURL') : "";
state.token = localStorage.getItem('x-auth-token');
state.account = localStorage.getItem('account');
state.idUser = localStorage.getItem('idUser');
state.role = Number(localStorage.getItem('role'));
}
return state.isLogin
},
hasPermissions: (state) => (scenes) => {
let hasPermissions = false;
if (state.role) {
switch (scenes) {
case 'user':
hasPermissions = state.role < 5;
break;
case 'role':
hasPermissions = state.role < 2;
break;
case 'topic':
hasPermissions = state.role < 3;
break;
case 'tag':
hasPermissions = state.role < 3;
break;
case 'admin':
hasPermissions = state.role < 2;
break;
case 'blog_admin':
hasPermissions = state.role < 3;
break;
default:
hasPermissions = false;
window.app.$store.commit('logout');
}
}
return hasPermissions;
},
isAuthor: (state) => (scenes) => {
return state.nickname === scenes ? true : false;
export const actions = () => ({
nuxtServerInit(store, {req}) {
// 初始化时的全局任务
const initFetchAppData = [
// 内容数据
store.dispatch('article/fetchList')
]
return Promise.all(initFetchAppData)
}
})