diff --git a/components/archive/list.vue b/components/archive/list.vue
index 18cb4b1..edd7652 100644
--- a/components/archive/list.vue
+++ b/components/archive/list.vue
@@ -23,7 +23,7 @@
-
+
{{ article.articleAuthorName }}
diff --git a/components/common/notification/list.vue b/components/common/notification/list.vue
index d6278a8..71e8393 100644
--- a/components/common/notification/list.vue
+++ b/components/common/notification/list.vue
@@ -6,18 +6,7 @@
- {{ notification.createdTime }}
-
-
-
-
-
-
-
-
-
-
- {{ notification.createdTime }}
+ {{ notification.createdTime }}
@@ -26,14 +15,26 @@
-
-
- {{ notification.createdTime }}
+
+
-
-
- 标记已读
-
+
+
+
+
+ {{ notification.createdTime }}
+
+
+ {{ notification.dataSummary }}
+
+
+
+
+ 标记已读
+
+
@@ -68,19 +69,15 @@
},
read(id) {
let _ts = this;
- this.$axios.$put('/api/notification/read/' + id).then(function (res) {
+ this.$axios.$put('/api/notification/read/' + id).then(function () {
_ts.currentChange(1);
}).catch(error => console.log(error));
},
onRouter(notification) {
- if ('0' === notification.dataType) {
- if (notification.hasRead === '0') {
- this.read(notification.idNotification);
- }
- this.$router.push({
- path: '/article/' + notification.dataId
- })
+ if (notification.hasRead === '0') {
+ this.read(notification.idNotification);
}
+ window.location.href = notification.dataUrl;
}
}
}
diff --git a/components/layouts/mobile/header.vue b/components/layouts/mobile/header.vue
index ad08646..434800f 100644
--- a/components/layouts/mobile/header.vue
+++ b/components/layouts/mobile/header.vue
@@ -1,25 +1,12 @@
-
+
RYMCU
-
-
-
-
- 首页
- 专题
- 开源代码
- 资料下载
-
-
-
-
@@ -32,52 +19,53 @@
@select="handleSelect"
/>
-
-
- 创建作品集
-
- 发帖
-
-
-
-
-
-
- {{ notification.dataSummary }}
-
- 查看所有消息
-
-
-
-
-
-
-
-
-
-
-
- {{ nickname }}
-
- 系统管理
- 资料与账号
- 我的草稿
- 退出登录
-
-
-
-
-
-
- 登录
-
-
- 注册
-
-
+
+
+
+ 发帖
+
+
+
+
+
+
+
+ {{ notification.dataSummary }}
+
+ 查看所有消息
+
+
+
+
+
+
+
+
+
+
+
+ {{ nickname }}
+
+ 系统管理
+ 资料与账号
+ 我的草稿
+ 退出登录
+
+
+
+
+
+
+ 登录
+
+
+ 注册
+
+
+
@@ -91,7 +79,7 @@
getActiveMenu() {
return this.$store.state.activeMenu;
},
- isLogin() {
+ user() {
return this.$store.state.oauth;
},
avatarURL() {
@@ -115,7 +103,7 @@
};
},
watch: {
- isLogin: function () {
+ user: function () {
this.getUnreadNotifications();
}
},
@@ -145,25 +133,23 @@
let _ts = this;
let activeMenu = _ts.$store.state.activeMenu;
if (activeMenu !== item) {
- if (item === 'topic') {
- _ts.$router.push(
- {
- name: item,
- params: {
- name: '51mcu'
+ switch (item) {
+ case 'topic':
+ _ts.$router.push({
+ path: '/topic/news'
+ })
+ break;
+ case 'github':
+ window.open("https://github.com/rymcu");
+ return false;
+ break;
+ default:
+ _ts.$router.push(
+ {
+ name: item
}
- }
- )
+ )
}
- if (item === 'github') {
- window.open("https://github.com/Hugh-rymcu");
- return false;
- }
- _ts.$router.push(
- {
- name: item
- }
- )
}
},
handleSelect(item) {
@@ -171,48 +157,44 @@
},
handleCommand(item) {
let _ts = this;
- if (item === 'user') {
- _ts.$router.push({
- path: '/user/' + _ts.$store.state.nickname
- })
+ switch (item) {
+ case 'user':
+ _ts.$router.push({
+ path: '/user/' + _ts.nickname
+ })
+ break;
+ case 'user-info':
+ _ts.$router.push({
+ path: '/user/settings/account'
+ })
+ break;
+ case 'logout':
+ Cookie.remove('auth')
+ _ts.$store.commit('setAuth', null)
+ item = 'login';
+ break;
+ default:
+ _ts.$router.push({
+ name: item
+ })
}
- if (item === 'user-info') {
- _ts.$router.push({
- name: 'account',
- params: {
- id: _ts.$store.state.idUser
- }
- })
- }
- if (item === 'logout') {
- Cookie.remove('auth')
- _ts.$store.commit('setAuth', null)
- item = 'login';
- }
- _ts.$router.push({
- name: item
- })
},
getUnreadNotifications() {
let _ts = this;
- if (_ts.isLogin) {
- _ts.$axios.$get('/api/notification/unread', {
- headers: {
- Authorization: _ts.$store.state.oauth?.accessToken
- }
- }).then(function (res) {
+ if (_ts.user) {
+ _ts.$axios.$get('/api/notification/unread').then(function (res) {
if (res) {
- _ts.$set(_ts, 'notifications', res.data.notifications);
- _ts.$set(_ts, 'notificationNumbers', res.data.notifications.length == 0 ? "" : res.data.notifications.length);
+ _ts.$set(_ts, 'notifications', res.notifications);
+ _ts.$set(_ts, 'notificationNumbers', res.notifications.length == 0 ? "" : res.notifications.length);
}
})
}
}
},
mounted() {
- this.restaurants = this.loadAll();
- let isLogin = this.isLogin;
- if (isLogin) {
+ // this.restaurants = this.loadAll();
+ let user = this.user;
+ if (user) {
this.getUnreadNotifications();
}
}
diff --git a/components/layouts/mobile/main.vue b/components/layouts/mobile/main.vue
index f9e4ab1..ffa7946 100644
--- a/components/layouts/mobile/main.vue
+++ b/components/layouts/mobile/main.vue
@@ -6,7 +6,7 @@
-
+
@@ -41,7 +41,7 @@
padding: 20px 0;
background-attachment: fixed;
min-height: 280px;
- margin-bottom: 60px;
+ margin-bottom: 6rem;
overflow-x: hidden;
}
diff --git a/pages/article/_article_id.vue b/pages/article/_article_id.vue
index d1a1f0a..948c7b8 100644
--- a/pages/article/_article_id.vue
+++ b/pages/article/_article_id.vue
@@ -46,8 +46,8 @@
所属作品集
-
-
+
+
diff --git a/pages/portfolio/_portfolio_id.vue b/pages/portfolio/_portfolio_id.vue
index 0e750f8..55946a6 100644
--- a/pages/portfolio/_portfolio_id.vue
+++ b/pages/portfolio/_portfolio_id.vue
@@ -24,13 +24,13 @@
-
+
管理
-
+
diff --git a/store/global.js b/store/global.js
index 4c96108..177c836 100644
--- a/store/global.js
+++ b/store/global.js
@@ -13,7 +13,10 @@ export const getters = {
}
export const mutations = {
-
+ // 设置是否移动端状态
+ updateMobileState(state, action) {
+ state.isMobile = action
+}
}
export const actions ={
diff --git a/store/index.js b/store/index.js
index 09886e5..5493a95 100644
--- a/store/index.js
+++ b/store/index.js
@@ -1,3 +1,5 @@
+import { isServer } from '~/environment'
+
const cookieparser = process.server ? require('cookieparser') : undefined
export const state = () => {
@@ -28,6 +30,27 @@ export const mutations = {
export const actions = {
nuxtServerInit(store, {req}) {
// 初始化时的全局任务
+ const userAgent = isServer ? req.headers['user-agent'] : navigator.userAgent
+ const browser = {
+ versions: function() {
+ return { //移动终端浏览器版本信息
+ trident: userAgent.indexOf('Trident') > -1, //IE内核
+ presto: userAgent.indexOf('Presto') > -1, //opera内核
+ webKit: userAgent.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
+ gecko: userAgent.indexOf('Gecko') > -1 && userAgent.indexOf('KHTML') == -1, //火狐内核
+ mobile: !!userAgent.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
+ ios: !!userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
+ android: userAgent.indexOf('Android') > -1 || userAgent.indexOf('Linux') > -1, //android终端或uc浏览器
+ iPhone: userAgent.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器
+ iPad: userAgent.indexOf('iPad') > -1, //是否iPad
+ webApp: userAgent.indexOf('Safari') == -1 //是否web应该程序,没有头部与底部
+ };
+ } ()
+ }
+ if (browser.versions.mobile) {
+ // 移动端
+ store.commit('global/updateMobileState', true)
+ }
let auth = null
if (req.headers.cookie) {
const parsed = cookieparser.parse(req.headers.cookie)