Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  代码优化
  优化代码
  • Loading branch information
gzydong committed Apr 10, 2021
2 parents 0c18703 + 75fe4c9 commit d4d7f19
Show file tree
Hide file tree
Showing 15 changed files with 653 additions and 607 deletions.
4 changes: 3 additions & 1 deletion src/api/article.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ export const ServeDownloadAnnex = (annex_id) => {
let link = document.createElement('a');
link.href = `${api}/api/v1/download/article-annex?annex_id=${annex_id}&token=${getToken()}`;
link.click();
} catch (e) {}
} catch (e) {
console.error(e)
}
}

//更新笔记标签服务接口
Expand Down
5 changes: 4 additions & 1 deletion src/components/editor/MeEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,10 @@ export default {
ServeSendTalkImage(fileData)
.then(res => {
if (res.code == 200) ref.closeBox()
ref.loading = false
if (res.code == 200) {
ref.closeBox()
}
})
.finally(() => {
ref.loading = false
Expand Down
82 changes: 39 additions & 43 deletions src/main-mixin.js
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')
},
},
}
36 changes: 18 additions & 18 deletions src/main.js
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
40 changes: 20 additions & 20 deletions src/permission.js
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()
})
14 changes: 7 additions & 7 deletions src/plugins/recorder/recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,30 +132,30 @@ export default class Recorder {
this.recorder.onaudioprocess = function (e) {
self.audioData.input(e.inputBuffer.getChannelData(0));
};
};
}

//停止
stop() {
this.recorder.disconnect();
};
}

//获取音频文件
getBlob() {
this.stop();
return this.audioData.encodeWAV();
};
}

//回放
play(audio) {
audio.src = window.URL.createObjectURL(this.getBlob());
};
}

//清理缓存的录音数据
clear(audio) {
this.audioData.buffer = [];
this.audioData.size = 0;
audio.src = ''
};
}

static checkError(e) {
const {
Expand Down Expand Up @@ -194,7 +194,7 @@ export default class Recorder {
return {
error: errorMsg
}
};
}

static get(callback, config) {
if (callback) {
Expand All @@ -221,5 +221,5 @@ export default class Recorder {
})
}
}
};
}
}
2 changes: 1 addition & 1 deletion src/plugins/socket/ws-socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class WsSocket {
let reconnect = this.config.reconnect;
if (reconnect.lockReconnect || reconnect.number == 0) {
return;
};
}

this.config.reconnect.lockReconnect = true;

Expand Down
Loading

0 comments on commit d4d7f19

Please sign in to comment.