forked from gzydong/LumenIM
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* develop: 代码优化 优化代码
- Loading branch information
Showing
15 changed files
with
653 additions
and
607 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,47 @@ | ||
import SocketInstance from './socket-instance'; | ||
import { | ||
ServeGetUserSetting | ||
} from "@/api/user"; | ||
import SocketInstance from './socket-instance' | ||
import { ServeGetUserSetting } from '@/api/user' | ||
|
||
export default { | ||
created() { | ||
// 判断用户是否登录 | ||
if (this.$store.getters.loginStatus) { | ||
this.initialize(); | ||
} | ||
created() { | ||
// 判断用户是否登录 | ||
if (this.$store.getters.loginStatus) { | ||
this.initialize() | ||
} | ||
}, | ||
methods: { | ||
// 页面初始化设置 | ||
initialize() { | ||
SocketInstance.connect() | ||
this.loadUserSetting() | ||
}, | ||
methods: { | ||
// 页面初始化设置 | ||
initialize() { | ||
SocketInstance.connect(); | ||
this.loadUserSetting(); | ||
}, | ||
|
||
// 加载用户相关设置信息,更新本地缓存 | ||
loadUserSetting() { | ||
ServeGetUserSetting().then(res => { | ||
if (res.code == 200) { | ||
const { | ||
user_info | ||
} = res.data; | ||
// 加载用户相关设置信息,更新本地缓存 | ||
loadUserSetting() { | ||
ServeGetUserSetting().then(res => { | ||
if (res.code == 200) { | ||
const { user_info } = res.data | ||
|
||
this.$store.commit('UPDATE_USER_INFO', { | ||
uid: user_info.uid, | ||
nickname: user_info.nickname, | ||
sex: user_info.gender, | ||
signature: user_info.motto, | ||
avatar: user_info.avatar | ||
}); | ||
} | ||
}); | ||
}, | ||
this.$store.commit('UPDATE_USER_INFO', { | ||
uid: user_info.uid, | ||
nickname: user_info.nickname, | ||
sex: user_info.gender, | ||
signature: user_info.motto, | ||
avatar: user_info.avatar, | ||
}) | ||
} | ||
}) | ||
}, | ||
|
||
// 跳转到指定好友对话页 | ||
dumpTalkPage(index_name) { | ||
sessionStorage.setItem("send_message_index_name", index_name); | ||
// 跳转到指定好友对话页 | ||
dumpTalkPage(index_name) { | ||
sessionStorage.setItem('send_message_index_name', index_name) | ||
|
||
if (this.$route.path == '/message') { | ||
this.$root.$children[0].refreshView(); | ||
return; | ||
} | ||
if (this.$route.path == '/message') { | ||
this.$root.$children[0].refreshView() | ||
return | ||
} | ||
|
||
this.$router.push('/message'); | ||
} | ||
} | ||
} | ||
this.$router.push('/message') | ||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
import 'core-js/stable'; | ||
import 'regenerator-runtime/runtime'; | ||
import 'core-js/stable' | ||
import 'regenerator-runtime/runtime' | ||
|
||
import Vue from 'vue'; | ||
import App from '@/App'; | ||
import store from '@/store'; | ||
import router from '@/router'; | ||
import mixin from './main-mixin'; | ||
import Vue from 'vue' | ||
import App from '@/App' | ||
import store from '@/store' | ||
import router from '@/router' | ||
import mixin from './main-mixin' | ||
|
||
import './core/lazy-use'; | ||
import './core/global-component'; | ||
import './core/filter'; | ||
import './core/directives'; | ||
import '@/permission'; | ||
import '@/icons'; | ||
import './core/lazy-use' | ||
import './core/global-component' | ||
import './core/filter' | ||
import './core/directives' | ||
import '@/permission' | ||
import '@/icons' | ||
|
||
// 引入自定义全局css | ||
import '@/assets/css/global.less'; | ||
import '@/assets/css/global.less' | ||
|
||
Vue.config.productionTip = false; | ||
Vue.config.productionTip = false | ||
|
||
const Instance = new Vue({ | ||
router, | ||
store, | ||
mixins: [mixin], | ||
render: h => h(App) | ||
}).$mount('#app'); | ||
render: h => h(App), | ||
}).$mount('#app') | ||
|
||
export default Instance; | ||
export default Instance |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,36 @@ | ||
import router from '@/router'; | ||
import NProgress from 'nprogress'; | ||
import 'nprogress/nprogress.css'; | ||
import config from '@/config/config'; | ||
import { | ||
getToken | ||
} from '@/utils/auth'; | ||
import router from '@/router' | ||
import NProgress from 'nprogress' | ||
import 'nprogress/nprogress.css' | ||
import config from '@/config/config' | ||
import { getToken } from '@/utils/auth' | ||
|
||
NProgress.configure({ | ||
showSpinner:false | ||
}); | ||
showSpinner: false, | ||
}) | ||
|
||
const WEBSITE_NAME = config.WEBSITE_NAME; | ||
const WEBSITE_NAME = config.WEBSITE_NAME | ||
|
||
// 登录用户强制重定向页面 | ||
const login_redirect = ['/login', '/register', '/forget']; | ||
const redirect = ['/login', '/register', '/forget'] | ||
|
||
router.beforeEach((to, from, next) => { | ||
document.title = to.meta.title ? `${WEBSITE_NAME} | ${to.meta.title}` : WEBSITE_NAME; | ||
document.title = to.meta.title | ||
? `${WEBSITE_NAME} | ${to.meta.title}` | ||
: WEBSITE_NAME | ||
|
||
// 如果有token说明该用户已登陆 | ||
if (getToken()) { | ||
if (login_redirect.indexOf(to.path) >= 0) { | ||
next('/'); | ||
if (redirect.indexOf(to.path) >= 0) { | ||
next('/') | ||
} | ||
} else if (to.meta.needLogin) { | ||
next('/login'); | ||
next('/login') | ||
} | ||
|
||
NProgress.start(); | ||
next(); | ||
}); | ||
NProgress.start() | ||
next() | ||
}) | ||
|
||
router.afterEach(() => { | ||
NProgress.done(); | ||
}); | ||
NProgress.done() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.