Merge branch 'feature/today-tag' into develop

This commit is contained in:
Ching 2021-10-10 23:41:29 +08:00
commit 50fb4bada4
12 changed files with 66 additions and 49 deletions

View File

@ -7,8 +7,8 @@ django-cors-headers==3.8.0
django-filter==2.4.0 django-filter==2.4.0
djangorestframework==3.12.4 djangorestframework==3.12.4
importlib-metadata==4.6.4 importlib-metadata==4.6.4
ipdb==0.13.9 ipdb
ipython==7.16.1 ipython
ipython-genutils==0.2.0 ipython-genutils==0.2.0
jedi==0.17.2 jedi==0.17.2
Markdown==3.3.4 Markdown==3.3.4

View File

@ -1 +1 @@
.summit-recipe[data-v-16b31338]{width:100%}.el-pagination{margin:10px 0 0 0}.el-row{margin-bottom:20px;&:last-child{margin-bottom:0}}.el-col,.grid-content{border-radius:4px}.grid-content{min-height:36px}.row-bg{padding:10px 0;background-color:#f9fafc}.content{padding:20px 10px}.re-generate{margin:20px 0;width:100%}.el-tag#meal a:link,.el-tag#meal a:visited{text-decoration:none}.el-tag#meal a:active,.el-tag#meal a:hover{text-decoration:underline}.el-tag{margin:0 5px 0 0}.el-tag+.el-tag{margin:5px 0 0 0}.recipe-type-tag{margin:0 10px 0 0;padding-bottom:0}.recipe-list{height:50%}body{background-color:#f7f8fa}.recipe-create{margin:20px 16px}.recipe_type,.recipe_type .van-grid-item__content{background-color:#f2f3f5}.daily_recipes{margin-bottom:10px}.daily_recipes:last-child{margin-bottom:40px}.action-button{height:100%;width:50%}.daily_recipe{margin-top:20px}.delete-button{width:100%;height:100%}.delete-icon{font-size:16px;line-height:inherit;padding:0 5px} .summit-recipe[data-v-16b31338]{width:100%}.el-pagination{margin:10px 0 0 0}.el-row{margin-bottom:20px;&:last-child{margin-bottom:0}}.el-col,.grid-content{border-radius:4px}.grid-content{min-height:36px}.row-bg{padding:10px 0;background-color:#f9fafc}.content{padding:20px 10px}.re-generate{margin:20px 0;width:100%}.el-tag#meal a:link,.el-tag#meal a:visited{text-decoration:none}.el-tag#meal a:active,.el-tag#meal a:hover{text-decoration:underline}.el-tag{margin:0 5px 0 0}.el-tag+.el-tag{margin:5px 0 0 0}.recipe-type-tag{margin:0 10px 0 0;padding-bottom:0}.recipe-list{height:50%}body{background-color:#f7f8fa}.recipe-create{margin:20px 16px}.recipe_type,.recipe_type .van-grid-item__content{background-color:#f2f3f5}.daily_recipes{margin-bottom:10px}.daily_recipes:last-child{margin-bottom:40px}.action-button{height:100%;width:50%}.today-tag{margin-left:10px}.daily_recipe{margin-top:20px}.delete-button{width:100%;height:100%}.delete-icon{font-size:16px;line-height:inherit;padding:0 5px}

View File

@ -1,29 +1 @@
<!DOCTYPE html> <!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>frontend</title><link href="/css/app.f57a4744.css" rel="preload" as="style"><link href="/css/chunk-vendors.b9153273.css" rel="preload" as="style"><link href="/js/app.a6401c62.js" rel="preload" as="script"><link href="/js/chunk-vendors.41761e04.js" rel="preload" as="script"><link href="/css/chunk-vendors.b9153273.css" rel="stylesheet"><link href="/css/app.f57a4744.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but frontend doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="/js/chunk-vendors.41761e04.js"></script><script src="/js/app.a6401c62.js"></script></body></html>
<html lang="">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width,initial-scale=1.0,maximum-scale=1.0, user-scalable=0"
/>
<link rel="icon" href="/favicon.ico" />
<title>frontend</title>
<link href="/css/app.12f77eb5.css" rel="preload" as="style" />
<link href="/css/chunk-vendors.b9153273.css" rel="preload" as="style" />
<link href="/js/app.4a8d2f87.js" rel="preload" as="script" />
<link href="/js/chunk-vendors.4d54ba89.js" rel="preload" as="script" />
<link href="/css/chunk-vendors.b9153273.css" rel="stylesheet" />
<link href="/css/app.12f77eb5.css" rel="stylesheet" />
</head>
<body>
<noscript
><strong
>We're sorry but frontend doesn't work properly without JavaScript
enabled. Please enable it to continue.</strong
></noscript
>
<div id="app"></div>
<script src="/js/chunk-vendors.4d54ba89.js"></script>
<script src="/js/app.4a8d2f87.js"></script>
</body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
frontend/dist/js/app.a6401c62.js vendored Normal file

File diff suppressed because one or more lines are too long

1
frontend/dist/js/app.a6401c62.js.map vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -6,11 +6,16 @@
loosing-text="可以松手了..." loosing-text="可以松手了..."
> >
<div v-for:="(daily_recipe, recipe_index) in daily_recipes"> <div v-for:="(daily_recipe, recipe_index) in daily_recipes">
<van-cell-group <van-cell-group inset class="daily_recipes">
inset <template #title>
:title="formatDate(daily_recipe.date)" <span> {{ formatDate(daily_recipe.date) }}</span>
class="daily_recipes" <van-tag
type="danger"
class="today-tag"
v-if="isToday(daily_recipe.date)"
>今天</van-tag
> >
</template>
<van-swipe-cell> <van-swipe-cell>
<van-row> <van-row>
<van-col span="3" class="recipe_type"> <van-col span="3" class="recipe_type">
@ -113,6 +118,7 @@ import {
PullRefresh, PullRefresh,
Row, Row,
SwipeCell, SwipeCell,
Tag,
} from 'vant'; } from 'vant';
import axios from 'axios'; import axios from 'axios';
import config from '@/config/index'; import config from '@/config/index';
@ -120,6 +126,7 @@ import config from '@/config/index';
export default { export default {
name: 'RecipeMobileWeekRecipe', name: 'RecipeMobileWeekRecipe',
components: { components: {
[Tag.name]: Tag,
[Button.name]: Button, [Button.name]: Button,
[Cell.name]: Cell, [Cell.name]: Cell,
[CellGroup.name]: CellGroup, [CellGroup.name]: CellGroup,
@ -140,13 +147,29 @@ export default {
this.getWeekRecipe(false); this.getWeekRecipe(false);
}, },
methods: { methods: {
isToday(date) {
const today = new Date();
var date_ = new Date(date * 1000);
if (
date_.getDate() == today.getDate() &&
date_.getMonth() == today.getMonth() &&
date_.getFullYear() == today.getFullYear()
) {
return true;
}
return false;
},
formatDate(date) { formatDate(date) {
if (date === undefined) { if (date === undefined) {
return; return;
} }
var date_ = new Date(date * 1000); var date_ = new Date(date * 1000);
var days = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']; var days = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
return days[date_.getDay()]; var date_str = days[date_.getDay()];
if (this.isToday(date_)) {
date_str += ' 🌟';
}
return date_str;
}, },
onRefresh() { onRefresh() {
this.getWeekRecipe(true); this.getWeekRecipe(true);
@ -197,4 +220,7 @@ export default {
height: 100%; height: 100%;
width: 50%; width: 50%;
} }
.today-tag {
margin-left: 10px;
}
</style> </style>

View File

@ -2,12 +2,19 @@
<el-row justify="center"> <el-row justify="center">
<el-col> <el-col>
<el-table border stripe :data="daily_recipes" max-height="500"> <el-table border stripe :data="daily_recipes" max-height="500">
<el-table-column <el-table-column label="日期">
prop="date" <template #default="scope">
label="日期" {{ formatDate(scope.row, scope.column, scope.row.date) }}
:formatter="formatDate" <el-tag
width="50px" v-if:="isToday(scope.row.date)"
></el-table-column> :key="scope"
size="small"
type="danger"
effect="dark"
>今天</el-tag
>
</template>
</el-table-column>
<el-table-column prop="meat" label="肉"> <el-table-column prop="meat" label="肉">
<template #default="scope"> <template #default="scope">
<el-tag <el-tag
@ -92,6 +99,18 @@ export default {
.then((response) => (this.daily_recipes = response.data)); .then((response) => (this.daily_recipes = response.data));
}, },
methods: { methods: {
isToday(date) {
const today = new Date();
var date_ = new Date(date * 1000);
if (
date_.getDate() == today.getDate() &&
date_.getMonth() == today.getMonth() &&
date_.getFullYear() == today.getFullYear()
) {
return true;
}
return false;
},
reGenerateRecipe() { reGenerateRecipe() {
axios axios
.post(config.publicPath + '/recipe/week-recipe/') .post(config.publicPath + '/recipe/week-recipe/')