Skip to content
This repository was archived by the owner on Jul 19, 2020. It is now read-only.

Commit

Permalink
fix: load today meal as async (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
junhoyeo authored Jul 10, 2019
1 parent c1533c1 commit 222b72b
Show file tree
Hide file tree
Showing 8 changed files with 278 additions and 57 deletions.
6 changes: 5 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"presets": [
"@babel/preset-env",
["env", {
"targets": {
"browsers": ["last 2 Chrome versions"]
}
}]
]
}
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
node_modules
216 changes: 216 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules",
"lint:vue": "eslint src/ --ext .vue --fix",
"lint:css": "stylelint \"**/*.{scss,vue}\" --fix",
"snyk-protect": "snyk protect",
"prepare": "npm run snyk-protect"
"lint:js": "eslint \"**/*.{vue,js}\" --fix",
"lint:css": "stylelint \"**/*.{scss,vue}\" --fix"
},
"dependencies": {
"@babel/preset-env": "^7.4.4",
Expand Down
2 changes: 1 addition & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ Vue.prototype.moment = moment;

new Vue({
el: '#app',
render: (h) => h(App),
render: h => h(App),
});
21 changes: 10 additions & 11 deletions src/pages/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ export default {
timeIndex() {
const timeTable = (this.todayIndex === 2) ? this.time.table.slice(0, 6) : this.time.table;
const current = Number(this.moment().format('HHmm'));
const idx = timeTable.findIndex((base) => current < base);
const idx = timeTable.findIndex(base => current < base);
return idx === -1 ? timeTable.length : idx + 1;
},
mealIndex() {
const current = Number(this.moment().format('HHmm'));
const idx = time.meal.findIndex((base) => current < base);
const idx = time.meal.findIndex(base => current < base);
return idx === -1 ? time.meal.length - 1 : idx;
},
Expand All @@ -52,20 +52,19 @@ export default {
},
},
created() {
this.getDimibob();
async created() {
await this.getDimibob();
this.getTimetable();
},
methods: {
getDimibob() {
async getDimibob() {
const today = this.moment().format('YYYYMMDD');
this.$api.get(`https://dev-api.dimigo.in/dimibobs/${today}`)
.then((res) => {
this.dimibob.breakfast = res.data.breakfast || 'μ•„μΉ¨ 급식 정보가 μ—†μŠ΅λ‹ˆλ‹€.';
this.dimibob.lunch = res.data.lunch || '점심 급식 정보가 μ—†μŠ΅λ‹ˆλ‹€.';
this.dimibob.dinner = res.data.dinner || '저녁 급식 정보가 μ—†μŠ΅λ‹ˆλ‹€.';
});
const { data: { breakfast, lunch, dinner } } = await this.$api.get(`https://dev-api.dimigo.in/dimibobs/${today}`);
console.log(breakfast);
this.dimibob.breakfast = breakfast || 'μ•„μΉ¨ 급식 정보가 μ—†μŠ΅λ‹ˆλ‹€.';
this.dimibob.lunch = lunch || '점심 급식 정보가 μ—†μŠ΅λ‹ˆλ‹€.';
this.dimibob.dinner = dinner || '저녁 급식 정보가 μ—†μŠ΅λ‹ˆλ‹€.';
},
getTimetable() {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Week.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default {
let num = 0;
this.table[this.grade][this.tab].forEach((day) => {
num += day.filter((subject) => (subject === this.query)).length;
num += day.filter(subject => (subject === this.query)).length;
});
return postposition.parse(`${this.query}[λŠ”|은] ν•œ 주에 ${num}번 λ“€μ—ˆμ–΄μš”.`);
},
Expand Down
Loading

0 comments on commit 222b72b

Please sign in to comment.