优化代码

super_signature
nineven 5 years ago
parent 33e16c9284
commit b32a12a597
  1. 4
      fir_client/src/components/FirAppInfosBase.vue
  2. 6
      fir_client/src/components/FirAppInfosbaseinfo.vue
  3. 2
      fir_client/src/components/FirAppInfoscombo.vue
  4. 6
      fir_client/src/components/FirApps.vue
  5. 2
      fir_client/src/components/FirHeader.vue
  6. 8
      fir_client/src/components/FirLogin.vue
  7. 2
      fir_client/src/components/FirSuperSignBase.vue
  8. 6
      fir_client/src/components/FirUserProfileBase.vue
  9. 2
      fir_client/src/components/FirUserProfileInfo.vue
  10. 2
      fir_client/src/main.js
  11. 13
      fir_client/src/restful/index.js
  12. 6
      fir_client/src/store/index.js
  13. 6
      fir_client/src/utils/index.js
  14. 2
      fir_download/src/restful/download.js
  15. 1
      fir_ser/api/utils/auth.py

@ -141,14 +141,14 @@
if (data.code === 1000) { if (data.code === 1000) {
this.appinfos = data.data; this.appinfos = data.data;
this.master_release = data.data.master_release; this.master_release = data.data.master_release;
this.$store.dispatch("getUser", data.userinfo); this.$store.dispatch("doUserinfo", data.userinfo);
this.appinfos["icon_url"] = this.master_release.icon_url; this.appinfos["icon_url"] = this.master_release.icon_url;
this.$store.dispatch('doucurrentapp', this.appinfos); this.$store.dispatch('doucurrentapp', this.appinfos);
} else if (data.code === 1003) { } else if (data.code === 1003) {
this.$router.push({name: 'FirApps'}); this.$router.push({name: 'FirApps'});
} else { } else {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log("失败了"); console.log("Error");
} }
}, { }, {
"methods": "GET", "methods": "GET",

@ -76,7 +76,7 @@
uploadimgs(data => { uploadimgs(data => {
if (data.code === 1000) { if (data.code === 1000) {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log(data.data); // console.log(data.data);
this.$message.success('上传成功'); this.$message.success('上传成功');
this.updateinfo(); this.updateinfo();
@ -153,7 +153,7 @@
if (data.code === 1000) { if (data.code === 1000) {
this.appinfos = data.data; this.appinfos = data.data;
this.master_release = data.data.master_release; this.master_release = data.data.master_release;
this.$store.dispatch("getUser", data.userinfo); this.$store.dispatch("doUserinfo", data.userinfo);
this.appinfos["icon_url"] = this.master_release.icon_url; this.appinfos["icon_url"] = this.master_release.icon_url;
this.$store.dispatch('doucurrentapp', this.appinfos); this.$store.dispatch('doucurrentapp', this.appinfos);
@ -161,7 +161,7 @@
this.$router.push({name: 'FirApps'}); this.$router.push({name: 'FirApps'});
} else { } else {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log("失败了"); console.log("Error");
} }
}, { }, {
"methods": "GET", "methods": "GET",

@ -130,7 +130,7 @@
} else { } else {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log("失败了"); console.log("Error");
} }
}, { }, {

@ -279,7 +279,7 @@
<div <div
ref="appmain" style="margin: 40px 20px"> ref="appmain" style="margin: 40px 20px;height: 100%">
<el-row style="max-height: 460px; margin: 0 auto;" :gutter="10" class="page-apps"> <el-row style="max-height: 460px; margin: 0 auto;" :gutter="10" class="page-apps">
@ -661,7 +661,7 @@
this.has_next = data.has_next; this.has_next = data.has_next;
this.orgapplists = this.applists.slice(); // this.orgapplists = this.applists.slice(); //
this.hdata = data.hdata; this.hdata = data.hdata;
this.$store.dispatch("getUser", data.userinfo); this.$store.dispatch("doUserinfo", data.userinfo);
this.searchapps(); this.searchapps();
// this.$store.dispatch('doucurrentapp', {'firapps':1}); // this.$store.dispatch('doucurrentapp', {'firapps':1});
@ -692,7 +692,7 @@
loading.close(); loading.close();
this.$message.error("应用解析失败,请检查是否为APP应用"); this.$message.error("应用解析失败,请检查是否为APP应用");
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log('err ----> ', err); console.log('Error ', err);
}); });
return false; return false;
}, },

@ -76,7 +76,7 @@
this.$cookies.remove("username"); this.$cookies.remove("username");
this.$cookies.remove("first_name"); this.$cookies.remove("first_name");
this.$store.dispatch('doucurrentapp', {}); this.$store.dispatch('doucurrentapp', {});
this.$store.dispatch('getUser', {}); this.$store.dispatch('doUserinfo', {});
this.$router.push({name: 'FirLogin'}); this.$router.push({name: 'FirLogin'});
} else { } else {
this.$message.error("退出失败") this.$message.error("退出失败")

@ -86,10 +86,10 @@
type: 'success' type: 'success'
}); });
this.$cookies.remove("auth_token"); this.$cookies.remove("auth_token");
this.$cookies.set("token", data['token']); this.$cookies.set("token", data['token'],3600 * 24 * 30);
this.$cookies.set("username", data.userinfo.username); this.$cookies.set("username", data.userinfo.username,3600 * 24 * 30);
this.$cookies.set("first_name", data.userinfo.first_name); this.$cookies.set("first_name", data.userinfo.first_name,3600 * 24 * 30);
this.$store.dispatch("get_user", data.userinfo); this.$store.dispatch("doUserinfo", data.userinfo);
set_auth_token(); set_auth_token();
this.$router.push({name: 'FirApps'}) this.$router.push({name: 'FirApps'})
} else { } else {

@ -614,7 +614,7 @@
getUserInfoFun() { getUserInfoFun() {
userinfos(data => { userinfos(data => {
if (data.code === 1000) { if (data.code === 1000) {
this.$store.dispatch("getUser", data.data); this.$store.dispatch("doUserinfo", data.data);
} else { } else {
this.$message.error("用户信息获取失败") this.$message.error("用户信息获取失败")
} }

@ -79,7 +79,7 @@
uploadimgs(data => { uploadimgs(data => {
if (data.code === 1000) { if (data.code === 1000) {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log(data.data); // console.log(data.data);
this.$message.success('上传成功'); this.$message.success('上传成功');
this.updateUserInfo({"methods": 'GET'}); this.updateUserInfo({"methods": 'GET'});
@ -122,7 +122,7 @@
userinfos(data => { userinfos(data => {
if (data.code === 1000) { if (data.code === 1000) {
this.userinfo = data.data; this.userinfo = data.data;
this.$store.dispatch("getUser", data.data); this.$store.dispatch("doUserinfo", data.data);
this.$store.dispatch('doucurrentapp', {}); this.$store.dispatch('doucurrentapp', {});
this.imageUrl = data.data.head_img; this.imageUrl = data.data.head_img;
@ -144,7 +144,7 @@
uploadimgs(data => { uploadimgs(data => {
if (data.code === 1000) { if (data.code === 1000) {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log(data.data); // console.log(data.data);
let certinfo = data.data; let certinfo = data.data;
this.uploadtostorage(file, certinfo); this.uploadtostorage(file, certinfo);
} }

@ -118,7 +118,7 @@
userinfos(data => { userinfos(data => {
if (data.code === 1000) { if (data.code === 1000) {
this.userinfo = data.data; this.userinfo = data.data;
this.$store.dispatch("getUser", data.data); this.$store.dispatch("doUserinfo", data.data);
if (data.data.sms_code) { if (data.data.sms_code) {
this.$notify({ this.$notify({
title: '验证码', title: '验证码',

@ -32,7 +32,7 @@ router.beforeEach((to, from, next) => {
avatar: VueCookies.get('avatar'), avatar: VueCookies.get('avatar'),
notice_num: VueCookies.get('notice_num') notice_num: VueCookies.get('notice_num')
}; };
store.dispatch('getUser', user) store.dispatch('doUserinfo', user)
} }
next() next()

@ -30,7 +30,7 @@ export function set_auth_token() {
} else { } else {
let token = VueCookies.get('token'); let token = VueCookies.get('token');
let username = VueCookies.get('username'); let username = VueCookies.get('username');
VueCookies.set("auth_token", Base64.encode(token + ':' + username)); VueCookies.set("auth_token", Base64.encode(token + ':' + username),3600 * 24 * 30);
} }
} }
// 更改加载的样式 // 更改加载的样式
@ -111,7 +111,7 @@ function getData(methods = true, url, params = {}, callBack, load, isCode = fals
}) })
.catch(function (error) { .catch(function (error) {
ErrorMsg(error); ErrorMsg(error);
callBack(null); callBack({"code":-1});
}); });
} else if (methods === "PUT") { } else if (methods === "PUT") {
@ -126,7 +126,7 @@ function getData(methods = true, url, params = {}, callBack, load, isCode = fals
}) })
.catch(function (error) { .catch(function (error) {
ErrorMsg(error); ErrorMsg(error);
callBack(null); callBack({"code":-1});
}); });
} else if (methods === 'POST') { } else if (methods === 'POST') {
@ -142,7 +142,7 @@ function getData(methods = true, url, params = {}, callBack, load, isCode = fals
}) })
.catch(function (error) { .catch(function (error) {
ErrorMsg(error); ErrorMsg(error);
callBack(null); callBack({"code":-1});
}); });
} else { } else {
Axios Axios
@ -152,8 +152,7 @@ function getData(methods = true, url, params = {}, callBack, load, isCode = fals
}) })
.catch(function (error) { .catch(function (error) {
ErrorMsg(error); ErrorMsg(error);
callBack({"code":-1});
callBack(null);
}); });
} }
} }
@ -345,7 +344,7 @@ export function uploadstorage(certinfo, file, successCallback, processCallback)
data.append('certinfo', JSON.stringify(certinfo)); data.append('certinfo', JSON.stringify(certinfo));
Axios.post(certinfo.upload_url, data, config).then(res => { Axios.post(certinfo.upload_url, data, config).then(res => {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log(res); // console.log(res);
successCallback(res) successCallback(res)
}).catch(err => { }).catch(err => {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console

@ -17,7 +17,7 @@ const store = new Vuex.Store({
userInfoIndex: 0, userInfoIndex: 0,
}, },
mutations: { mutations: {
get_user(state, data) { setuserinfo(state, data) {
state.userinfo = data; state.userinfo = data;
}, },
setappInfoIndex(state, val) { setappInfoIndex(state, val) {
@ -31,8 +31,8 @@ const store = new Vuex.Store({
} }
}, },
actions: { actions: {
getUser(context, data) { doUserinfo(context, data) {
context.commit('get_user', data); context.commit('setuserinfo', data);
}, },
doappInfoIndex(context, val) { doappInfoIndex(context, val) {
context.commit('setappInfoIndex', val) context.commit('setappInfoIndex', val)

@ -140,9 +140,9 @@ export function uploadaliyunoss(file, certinfo, app, successcallback, processcal
const progress = async function progress(p, checkpoint) { const progress = async function progress(p, checkpoint) {
currentCheckpoint = checkpoint; currentCheckpoint = checkpoint;
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log(Math.floor(p * 100)); // console.log(Math.floor(p * 100));
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log(checkpoint); // console.log(checkpoint);
processcallback(Math.floor(p * 100)); processcallback(Math.floor(p * 100));
}; };
@ -156,7 +156,7 @@ export function uploadaliyunoss(file, certinfo, app, successcallback, processcal
}; };
client.multipartUpload(certinfo.upload_key, file, options).then((res) => { client.multipartUpload(certinfo.upload_key, file, options).then((res) => {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log('upload success: %j', res); // console.log('upload success: %j', res);
successcallback(res); successcallback(res);
currentCheckpoint = null; currentCheckpoint = null;
}).catch((err) => { }).catch((err) => {

@ -85,7 +85,7 @@ function getData(url, params = {}, callBack) {
alert('网络连接失败') alert('网络连接失败')
} }
callBack(null); callBack({"code":-1});
}); });
} }

@ -38,6 +38,7 @@ class ExpiringTokenAuthentication(BaseAuthentication):
raise AuthenticationFailed({"code": 1001, "error": "无效的token"}) raise AuthenticationFailed({"code": 1001, "error": "无效的token"})
if user_obj.is_active: if user_obj.is_active:
cache.set(auth_key, cacheuserinfo, 3600 * 24 * 7) cache.set(auth_key, cacheuserinfo, 3600 * 24 * 7)
# cache.expire(auth_key, timeout=3600 * 24 * 7)
return user_obj, auth_token return user_obj, auth_token
else: else:
raise AuthenticationFailed({"code": 1001, "error": "用户被禁用"}) raise AuthenticationFailed({"code": 1001, "error": "用户被禁用"})

Loading…
Cancel
Save