Skip to content

Commit 57fa1a4

Browse files
committed
优化loading
1 parent b1dd3df commit 57fa1a4

File tree

8 files changed

+57
-39
lines changed

8 files changed

+57
-39
lines changed

src/components/Loading/Loading.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export default {
7272
align-items: center;
7373
justify-content: center;
7474
background-color: rgba(255, 255, 255, 1);
75-
z-index: 1000;
75+
z-index: 100;
7676
&-fullscreen {
7777
position: fixed !important;
7878
}

src/components/Loading/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Vue from "vue";
22
import Loading from "./Loading";
33

44
const LoadingCtor = Vue.extend(Loading);
5-
const fullscreenLoading = new LoadingCtor();
5+
// const fullscreenLoading = new LoadingCtor();
66

77
LoadingCtor.install = (Vue) => {
88
Vue.directive("loading", {

src/components/header.vue

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
<li class="navbar-item">
2626
<a href="https://job.bytedance.com/campus/" target="_blank">校园招聘</a>
2727
</li>
28-
</ul>
29-
|
28+
</ul>|
3029
<div class="user">
3130
<div class="login" v-if="!state.isLogin">
3231
<router-link to="/user">
@@ -56,48 +55,48 @@ import store from "@/store";
5655
export default {
5756
name: "Header",
5857
data: () => ({
59-
state: store.state,
58+
state: store.state
6059
}),
6160
created() {
6261
store
6362
.requestLoginStatus()
64-
.then((isLogin) => {
63+
.then(isLogin => {
6564
if (!isLogin) {
6665
store.expireLogin();
6766
} else if (isLogin && !this.state.userInfo.email) {
6867
console.log(this.state.userInfo.email);
6968
store
7069
.requestUserInfo()
71-
.then((res) => {})
72-
.catch((err) => {});
70+
.then(res => {})
71+
.catch(err => {});
7372
}
7473
})
75-
.catch((err) => {
74+
.catch(err => {
7675
store.expireLogin();
7776
});
7877
},
7978
props: {
8079
fixedToTop: {
8180
type: Boolean,
82-
default: false,
81+
default: false
8382
},
8483
themeColor: {
8584
type: String,
86-
default: "main-color",
87-
},
85+
default: "main-color"
86+
}
8887
},
8988
methods: {
9089
handleLogout() {
9190
store
9291
.requestLogout()
93-
.then((res) => {
94-
this.$router.push('/')
92+
.then(res => {
93+
this.$router.push("/");
9594
})
96-
.catch((err) => {
97-
throw err
95+
.catch(err => {
96+
throw err;
9897
});
99-
},
100-
},
98+
}
99+
}
101100
};
102101
</script>
103102
<style lang="less" scoped>
@@ -108,9 +107,11 @@ export default {
108107
height: 60px;
109108
align-items: center;
110109
padding: 10px 100px;
110+
position: relative;
111+
z-index: 100000;
111112
&.fixedToTop {
112113
position: fixed;
113-
z-index: 100;
114+
114115
width: 100%;
115116
}
116117
&.main-color {
@@ -187,12 +188,12 @@ export default {
187188
.dropdown-menu {
188189
position: relative;
189190
z-index: 1000;
190-
&__email{
191-
line-height:2;
192-
cursor:pointer;
191+
&__email {
192+
line-height: 2;
193+
cursor: pointer;
193194
}
194195
&__wrapper {
195-
// padding-top:10px;
196+
// padding-top:10px;
196197
position: absolute;
197198
display: none;
198199
right: 0;

src/store/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ window.addEventListener("load", () => {
1919
state.userInfo = account.userInfo;
2020
});
2121

22-
const state = Vue.observable({
22+
export const state = Vue.observable({
2323
isLogin: false,
2424
userInfo: {},
2525
});

src/views/JobDetail.vue

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,37 @@
1515
<pre class="textContent">{{ jobDetail.requirement }}</pre>
1616
</div>
1717
<div class="job-detail-button job-detail-block">
18-
<bytedance-button size="large">投递</bytedance-button>
18+
<bytedance-button @click="delivery" size="large">投递</bytedance-button>
1919
</div>
2020
</div>
2121
</template>
2222
<script>
23+
import { state } from "@/store";
2324
export default {
2425
name: "job-detail",
2526
data() {
2627
return { jobDetail: {} };
2728
},
28-
beforeRouteEnter(to, from, next) {
29-
console.log(to, from, next);
30-
if(from.name==='jobs'){
31-
next()
32-
}else{
33-
29+
30+
methods: {
31+
delivery() {
32+
if (!state.isLogin) {
33+
this.$router.push("/user");
34+
} else {
35+
this.$message.warning("功能开发中...");
36+
}
3437
}
35-
next()
3638
},
3739
created() {
40+
let loading = this.$loading({ position: { top: 60 } });
3841
const { id } = this.$route.params;
3942
this.request
4043
.get(`/jobs/${id}`)
4144
.then(res => {
4245
this.jobDetail = res.job_post_detail;
46+
loading.close();
4347
})
44-
.catch(console.error);
48+
.catch(loading.close);
4549
}
4650
};
4751
</script>

src/views/Jobs.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export default {
9595
const dataRequest = this.fetchList();
9696
9797
this.loadingIns = this.$loading({
98-
position: { top: 60 },
98+
// position: { top: 60 },
9999
background: "#fff"
100100
});
101101
Promise.all([jobConfigRequest, dataRequest]).then(() => {
@@ -188,7 +188,7 @@ export default {
188188
box-shadow: 0 5px 4px rgba(0, 0, 0, 0.1);
189189
top: 0;
190190
padding: 20px 130px;
191-
191+
z-index: 1000;
192192
background-color: #fff;
193193
transform: translateY(0);
194194
}

src/views/Resume.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ export default {
387387
}
388388
},
389389
created() {
390-
const loading = this.$loading({ position: { top: 60 } });
390+
const loading = this.$loading();
391391
fetchResume().then(res => {
392392
this.resumeDetail = res.data.resume_detail;
393393
loading.close();

src/views/ResumeEditor.vue

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
:on-success="handleResumeUploadSuccess"
2525
:on-change="handleResumeUploadChange"
2626
:on-progress="handleResumeUploadProgress"
27+
:on-error="handleResumeUploadError"
2728
>
2829
<div class="uploadFile__resume">
2930
<div class="beforeUpload" v-if="!uploadData.id">
@@ -695,7 +696,7 @@
695696
class="resumeEditor-footerAction"
696697
>
697698
<el-button round @click="$router.push('/resume')">取消</el-button>
698-
<el-button round size="medium" @click="submit" type="primary">保存</el-button>
699+
<el-button round :loading="submitLoading" size="medium" @click="submit" type="primary">保存</el-button>
699700
</div>
700701
</div>
701702
</template>
@@ -715,6 +716,7 @@ let footerActionPosition = null;
715716
export default {
716717
data() {
717718
return {
719+
submitLoading: false,
718720
uploadData: {},
719721
resumeUploadUpdateHintVisible: false,
720722
shouldEvaluate: true,
@@ -1024,6 +1026,14 @@ export default {
10241026
return true;
10251027
});
10261028
},
1029+
handleResumeUploadError(err) {
1030+
this.$message({
1031+
message: err.message,
1032+
dangerouslyUseHTMLString: true,
1033+
type: "error"
1034+
// duration: 0
1035+
});
1036+
},
10271037
handleResumeUploadProgress(progressEvent) {
10281038
this.$refs.resumeUploadProgress.percentage = progressEvent.percent;
10291039
},
@@ -1103,7 +1113,7 @@ export default {
11031113
}
11041114
11051115
const payload = this.transformResumePayload(this.resume);
1106-
1116+
this.submitLoading = true;
11071117
fetchSaveResume(payload.id, {
11081118
resume: payload,
11091119
@@ -1112,8 +1122,11 @@ export default {
11121122
.then(res => {
11131123
this.$message.success("简历保存成功");
11141124
this.$router.push("/resume");
1125+
this.submitLoading = false;
11151126
})
1116-
.catch(err => {});
1127+
.catch(err => {
1128+
this.submitLoading = false;
1129+
});
11171130
},
11181131
11191132
transformResumePayload(data) {

0 commit comments

Comments
 (0)