fix CustomPoem
This commit is contained in:
rsgltzyd 2024-09-17 19:49:30 +08:00
parent 07d748cb0a
commit 627384bfb9
12 changed files with 509 additions and 479 deletions

1
.gitignore vendored
View File

@ -28,3 +28,4 @@ coverage
*.sw? *.sw?
*.tsbuildinfo *.tsbuildinfo
/package-lock.json

View File

@ -1,6 +1,5 @@
<script setup> <script setup>
import { RouterLink, RouterView } from 'vue-router' import { RouterLink, RouterView } from 'vue-router'
import HelloWorld from './components/HelloWorld.vue'
</script> </script>
<template> <template>
@ -8,8 +7,6 @@ import HelloWorld from './components/HelloWorld.vue'
<img alt="Vue logo" class="logo" src="@/assets/logo.svg" width="125" height="125" /> <img alt="Vue logo" class="logo" src="@/assets/logo.svg" width="125" height="125" />
<div class="wrapper"> <div class="wrapper">
<HelloWorld msg="You did it!" />
<nav> <nav>
<RouterLink to="/">Home</RouterLink> <RouterLink to="/">Home</RouterLink>
<RouterLink to="/about">About</RouterLink> <RouterLink to="/about">About</RouterLink>

View File

@ -28,8 +28,6 @@ a,
} }
#app { #app {
display: grid;
grid-template-columns: 1fr 1fr;
padding: 0 2rem; padding: 0 2rem;
} }
} }

View File

@ -1,20 +1,19 @@
<script> <script>
import { defineComponent } from 'vue'; import { defineComponent } from 'vue'
import Post from '../utils/Post.js';
export default defineComponent({ export default defineComponent({
props: { props: {
post: { type: Post, required: true }, post: { type: null, required: true }
}, },
data() { data() {
return { return {
childPost: {} childPost: {}
}; }
}, },
created() { created() {
this.childPost = this.post; this.childPost = this.post
}, }
}); })
</script> </script>
<template> <template>
<div class="card"> <div class="card">
@ -31,7 +30,7 @@ export default defineComponent({
<style scoped> <style scoped>
.card { .card {
box-sizing: border-box; box-sizing: border-box;
box-shadow: 0 0 10px 0 rgba(0, 0, 0, .24); box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.24);
border-radius: 4px; border-radius: 4px;
padding: 8px; padding: 8px;
cursor: pointer; cursor: pointer;
@ -44,14 +43,13 @@ export default defineComponent({
line-height: 24px; line-height: 24px;
/* margin-bottom: 4px; */ /* margin-bottom: 4px; */
padding-bottom: 4px; padding-bottom: 4px;
border-bottom: 1px solid rgba(0, 0, 0, .24); border-bottom: 1px solid rgba(0, 0, 0, 0.24);
} }
.card .title:hover { .card .title:hover {
color: burlywood; color: burlywood;
} }
.card .content { .card .content {
padding: 4px; padding: 4px;
/* height: 100%; */ /* height: 100%; */

View File

@ -1,21 +1,19 @@
const weekDayNumber = 7
const week_zh_cn = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
const weekDayNumber = 7; const week_en_us = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
const week_zh_cn = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"];
const week_en_us = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"];
class Day { class Day {
constructor(year, month, day, content, isCurrentMonth = false, isCurrentDay = false) { constructor(year, month, day, content, isCurrentMonth = false, isCurrentDay = false) {
this.year = year; this.year = year
this.month = month; this.month = month
this.day = day; this.day = day
this.content = content; this.content = content
this.isCurrentMonth = isCurrentMonth; this.isCurrentMonth = isCurrentMonth
this.isCurrentDay = isCurrentDay this.isCurrentDay = isCurrentDay
} }
} }
const defaultDate = new Date(); const defaultDate = new Date()
const defaultYear = defaultDate.getFullYear() const defaultYear = defaultDate.getFullYear()
const defaultMonth = defaultDate.getMonth() const defaultMonth = defaultDate.getMonth()
const defaultDay = defaultDate.getDate() const defaultDay = defaultDate.getDate()
@ -28,54 +26,48 @@ const defaultDay = defaultDate.getDate()
* @param {number} [day = defaultDay] * @param {number} [day = defaultDay]
* @returns {[Day]} * @returns {[Day]}
*/ */
function initDay(currentDays = new Array(42), year = defaultYear, month = defaultMonth, day = defaultDay) { function initDay(
currentDays = new Array(42),
year = defaultYear,
month = defaultMonth,
day = defaultDay
) {
if (!Array.isArray(currentDays)) { if (!Array.isArray(currentDays)) {
currentDays = new Array(42); currentDays = new Array(42)
} else if (currentDays.length != 42) { } else if (currentDays.length !== 42) {
console.log(currentDays); console.log(currentDays)
throw new Error(currentDays) throw new Error('currentDays:' + currentDays)
} else { } else {
currentDays = [...currentDays]; currentDays = [...currentDays]
} }
const days = currentDays; const days = currentDays
const lastDayOfLastMonth = new Date(year, month, 0); const lastDayOfLastMonth = new Date(year, month, 0)
const firstDayOfMonth = new Date(year, month, 1); const firstDayOfMonth = new Date(year, month, 1)
const lastDayOfMonth = new Date(year, month + 1, 0); const lastDayOfMonth = new Date(year, month + 1, 0)
const currentDaysOfMonth = lastDayOfMonth.getDate(); const currentDaysOfMonth = lastDayOfMonth.getDate()
const daysOfLastMonth = lastDayOfLastMonth.getDate(); const daysOfLastMonth = lastDayOfLastMonth.getDate()
for (let i = 0; i < firstDayOfMonth.getDay(); i++) { for (let i = 0; i < firstDayOfMonth.getDay(); i++) {
const weekDay = firstDayOfMonth.getDay() - 1; const weekDay = firstDayOfMonth.getDay() - 1
days[i] = new Day(year, month - 1, daysOfLastMonth - weekDay + i, week_zh_cn[i]); days[i] = new Day(year, month - 1, daysOfLastMonth - weekDay + i, week_zh_cn[i])
} }
for (let i = 0; i < currentDaysOfMonth; i++) { for (let i = 0; i < currentDaysOfMonth; i++) {
const weekDay = (firstDayOfMonth.getDay() + i) % weekDayNumber; const weekDay = (firstDayOfMonth.getDay() + i) % weekDayNumber
days[firstDayOfMonth.getDay() + i] = new Day(year, month, i + 1, week_zh_cn[weekDay], true); days[firstDayOfMonth.getDay() + i] = new Day(year, month, i + 1, week_zh_cn[weekDay], true)
if (i === day - 1) { if (i === day - 1) {
days[firstDayOfMonth.getDay() + i].isCurrentDay = true; days[firstDayOfMonth.getDay() + i].isCurrentDay = true
} }
} }
for (let i = currentDaysOfMonth + firstDayOfMonth.getDay(); i < days.length; i++) { for (let i = currentDaysOfMonth + firstDayOfMonth.getDay(); i < days.length; i++) {
const extraDay = i - currentDaysOfMonth - firstDayOfMonth.getDay() + 1; const extraDay = i - currentDaysOfMonth - firstDayOfMonth.getDay() + 1
const weekDay = i % weekDayNumber; const weekDay = i % weekDayNumber
days[i] = new Day(year, month + 1, extraDay, week_zh_cn[weekDay]); days[i] = new Day(year, month + 1, extraDay, week_zh_cn[weekDay])
} }
return currentDays; return currentDays
} }
export { week_zh_cn, week_en_us, defaultYear, defaultMonth, defaultDay, initDay }; export { week_zh_cn, week_en_us, defaultYear, defaultMonth, defaultDay, initDay }

View File

@ -14,11 +14,21 @@ const day = ref(defaultDay)
const editMonth = { const editMonth = {
add: () => { add: () => {
month.value >= 11 ? ((month.value = 0), (year.value += 1)) : (month.value += 1) if (month.value >= 11) {
month.value = 0
year.value += 1
} else {
month.value += 1
}
dayArray.value = initDay(dayArray.value, year.value, month.value, day.value) dayArray.value = initDay(dayArray.value, year.value, month.value, day.value)
}, },
sub: () => { sub: () => {
month.value <= 0 ? ((month.value = 11), (year.value -= 1)) : (month.value -= 1) if (month.value <= 0) {
month.value = 11
year.value -= 1
} else {
month.value -= 1
}
dayArray.value = initDay(dayArray.value, year.value, month.value, day.value) dayArray.value = initDay(dayArray.value, year.value, month.value, day.value)
} }
} }
@ -73,8 +83,10 @@ const handleDayClick = (date) => {
justify-content: space-around; justify-content: space-around;
width: 100%; width: 100%;
} }
text-align: center; text-align: center;
} }
#calendar .title { #calendar .title {
> button { > button {
height: 20px; height: 20px;
@ -89,6 +101,7 @@ const handleDayClick = (date) => {
.content { .content {
display: grid; display: grid;
grid-template-columns: repeat(7, 1fr); grid-template-columns: repeat(7, 1fr);
> div { > div {
outline: 1px solid; outline: 1px solid;
display: flex; display: flex;
@ -103,6 +116,7 @@ const handleDayClick = (date) => {
#calendar { #calendar {
width: 280px; width: 280px;
} }
.content { .content {
height: 240px; height: 240px;
} }
@ -112,6 +126,7 @@ const handleDayClick = (date) => {
#calendar { #calendar {
max-width: 350px; max-width: 350px;
} }
.content { .content {
height: 300px; height: 300px;
} }

View File

@ -1,15 +1,8 @@
<script> <script setup>
import { defineComponent } from 'vue'; import { reactive } from 'vue'
const poem = reactive({
export default defineComponent({ title: '雨霖铃·寒蝉凄切',
props: { body: [
poemTitle: {
type: String,
default: '雨霖铃·寒蝉凄切'
},
poemBody: {
type: Array,
default: () => [
'寒蝉凄切,对长亭晚,骤雨初歇。', '寒蝉凄切,对长亭晚,骤雨初歇。',
'都门帐饮无绪,留恋处,兰舟催发。', '都门帐饮无绪,留恋处,兰舟催发。',
'执手相看泪眼,竟无语凝噎。', '执手相看泪眼,竟无语凝噎。',
@ -18,25 +11,23 @@ export default defineComponent({
'今宵酒醒何处?杨柳岸,晓风残月。', '今宵酒醒何处?杨柳岸,晓风残月。',
'此去经年,应是良辰好景虚设。', '此去经年,应是良辰好景虚设。',
'便纵有千种风情,更与何人说?' '便纵有千种风情,更与何人说?'
], ]
} })
},
data() {
return {
}; console.log(poem.body)
},
});
</script> </script>
<template> <template>
<div class="poem"> <div class="poem">
<h2 class="poem-title"> <h2 class="poem_title">{{ poem.title }}</h2>
{{ this.poemTitle }} <ul class="poem_body">
</h2> <li v-for="(line, index) in poem.body" :key="index">
<ul class="poem-body"> <span
<li v-for="{poem, index} in this.poemBody" :key="index"> v-for="(char, charIndex) in line.split('')"
{{ poem }} :key="charIndex"
:style="{ animationDelay: charIndex * 0.1 + 's' }"
>{{ char }}</span
>
</li> </li>
</ul> </ul>
</div> </div>
@ -44,7 +35,7 @@ export default defineComponent({
<style scoped> <style scoped>
* { * {
/* box-sizing: border-box; */ box-sizing: border-box;
font-family: 'Ma Shan Zheng', cursive; font-family: 'Ma Shan Zheng', cursive;
margin: 0; margin: 0;
padding: 0; padding: 0;
@ -60,17 +51,14 @@ ul {
width: 280px; width: 280px;
border-radius: 4px; border-radius: 4px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.4); box-shadow: 0 0 10px rgba(0, 0, 0, 0.4);
}
.poem-title {
text-align: center; text-align: center;
> .poem_title {
white-space: nowrap; white-space: nowrap;
padding-top: 10px; padding-top: 10px;
font-size: 24px; font-size: 24px;
width: 100%; width: 100%;
} }
> .poem_body {
.poem-body {
text-align: center; text-align: center;
white-space: nowrap; white-space: nowrap;
font-size: 16px; font-size: 16px;
@ -79,5 +67,17 @@ ul {
> li { > li {
margin: 5px auto; margin: 5px auto;
} }
> li span {
opacity: 0;
animation: fadeIn 1s forwards;
}
}
}
@keyframes fadeIn {
to {
opacity: 1;
}
} }
</style> </style>

View File

@ -1,23 +0,0 @@
<script>
import { defineComponent } from 'vue';
export default defineComponent({
props: {
},
data() {
return {
};
},
});
</script>
<template>
<div>
PersonInfoHHHHH
</div>
</template>
<style scoped>
</style>

View File

@ -1,5 +1,5 @@
<script> <script>
import { defineComponent } from "vue"; import { defineComponent } from 'vue'
export default defineComponent({ export default defineComponent({
data() { data() {
@ -9,27 +9,27 @@ export default defineComponent({
}, },
methods: { methods: {
testapi() { testapi() {
fetch("http://127.0.0.1:3000/user") fetch('http://127.0.0.1:3000/user')
.then(res => res.json()) .then((res) => res.json())
.then(data => { .then((data) => {
this.test = data; this.test = data
}) })
.catch(err => console.log('Request Failed', err)) .catch((err) => console.log('Request Failed', err))
} }
} }
}); })
</script> </script>
<template> <template>
<button @click="testapi">测试接口调用</button> <button @click="testapi">测试接口调用</button>
<p v-if="this.test != ''"> <p v-if="this.test != ''">
{{ this.test[0].name }}<br> {{ this.test[0].name }}<br />
{{ this.test[0].birth }}<br> {{ this.test[0].birth }}<br />
{{ this.test[0].gender }}<br> {{ this.test[0].gender }}<br />
{{ this.test[0].name }}<br> {{ this.test[0].name }}<br />
{{ this.test[0].password }}<br> {{ this.test[0].password }}<br />
{{ this.test[0].register_date }}<br> {{ this.test[0].register_date }}<br />
{{ this.test[0].status }}<br> {{ this.test[0].status }}<br />
</p> </p>
</template> </template>

View File

@ -1,15 +1,16 @@
<script> <script>
import { defineComponent } from 'vue'; import { defineComponent } from 'vue'
export default defineComponent({ export default defineComponent({
props: { props: {
welcome: { welcome: {
type: String, type: String,
default: '你好', default: '你好'
}, },
url: { url: {
type: String, type: String,
default: 'http://127.0.0.1:3000/login', default: 'http://127.0.0.1:3000/login'
}, }
}, },
data() { data() {
return { return {
@ -20,69 +21,79 @@ export default defineComponent({
accountShow: true, accountShow: true,
passwordShow: true, passwordShow: true,
account: '', account: '',
password: '', password: ''
}; }
}, },
watch: { watch: {
account(val) { account(val) {
val.length > 0 ? (this.showAccountError = false, this.accountShow = false) : if (val.length > 0) {
(this.showAccountError = false, this.accountShow = false); this.showAccountError = false
this.accountShow = false
} else {
this.showAccountError = false
this.accountShow = false
}
}, },
password(val) { password(val) {
val.length > 0 ? (this.showPasswordError = false, this.passwordShow = false) : if (val.length > 0) {
(this.showPasswordError = false, this.passwordShow = false); this.showPasswordError = false
}, this.passwordShow = false
} else {
this.showPasswordError = false
this.passwordShow = false
}
}
}, },
methods: { methods: {
accountFocus() { accountFocus() {
if (this.account.length <= 0) { if (this.account.length <= 0) {
this.accountShow = true; this.accountShow = true
this.accountAbove = true; this.accountAbove = true
this.showAccountError = true; this.showAccountError = true
} }
}, },
accountBlur() { accountBlur() {
if (this.account.length <= 0) { if (this.account.length <= 0) {
this.accountShow = false; this.accountShow = false
this.accountAbove = false; this.accountAbove = false
this.showAccountError = false; this.showAccountError = false
} }
}, },
passwordFocus() { passwordFocus() {
if (this.password.length <= 0) { if (this.password.length <= 0) {
this.passwordShow = true; this.passwordShow = true
this.passwordAbove = true; this.passwordAbove = true
this.showPasswordError = true; this.showPasswordError = true
} }
}, },
passwordBlur() { passwordBlur() {
if (this.password.length <= 0) { if (this.password.length <= 0) {
this.passwordShow = false; this.passwordShow = false
this.passwordAbove = false; this.passwordAbove = false
this.showPasswordError = false; this.showPasswordError = false
} }
}, },
async login() { async login() {
const payload = { const payload = {
account: this.account, account: this.account,
password: this.password password: this.password
}; }
try { try {
console.log(this.url); console.log(this.url)
const response = await fetch(this.url, { const response = await fetch(this.url, {
method: "POST", method: 'POST',
mode: "cors", mode: 'cors',
cache: "default", cache: 'default',
headers: { headers: {
'Content-Type': 'application/json; charset=utf-8' 'Content-Type': 'application/json; charset=utf-8'
}, },
credentials: 'include', credentials: 'include',
body: JSON.stringify(payload) body: JSON.stringify(payload)
}); })
const data = await response.json(); const data = await response.json()
console.log(data); console.log(data)
} catch (err) { } catch (err) {
console.error(err); console.error(err)
} }
} }
} }
@ -109,7 +120,10 @@ export default defineComponent({
/> />
<label <label
class="floating-label" class="floating-label"
:class="{ 'floating-label-above': accountAbove, 'floating-label-error': showAccountError }" :class="{
'floating-label-above': accountAbove,
'floating-label-error': showAccountError
}"
for="account" for="account"
>邮箱/手机号码</label >邮箱/手机号码</label
> >
@ -135,7 +149,10 @@ export default defineComponent({
/> />
<label <label
class="floating-label" class="floating-label"
:class="{ 'floating-label-above': passwordAbove, 'floating-label-error': showPasswordError }" :class="{
'floating-label-above': passwordAbove,
'floating-label-error': showPasswordError
}"
for="password" for="password"
>密码</label >密码</label
> >
@ -147,12 +164,7 @@ export default defineComponent({
<div class="accept-terms"> <div class="accept-terms">
<label for="agreement" class="accept"> <label for="agreement" class="accept">
<span class="agreement-checkbox"> <span class="agreement-checkbox">
<input <input class="accept-checkbox-input" type="checkbox" name="agreement" id="agreement" />
class="accept-checkbox-input"
type="checkbox"
name="agreement"
id="agreement"
/>
<span class="agreement-inner"></span> <span class="agreement-inner"></span>
</span> </span>
<span class="accept-text" <span class="accept-text"
@ -212,7 +224,6 @@ export default defineComponent({
position: relative; position: relative;
border-radius: 4px; border-radius: 4px;
overflow: hidden; overflow: hidden;
transform: all 0.1s ease;
} }
.form-field-error { .form-field-error {
@ -243,11 +254,6 @@ export default defineComponent({
color: red; color: red;
} }
.form-helper {
font-size: 12px;
color: red;
}
.accept-terms { .accept-terms {
height: 25px; height: 25px;
line-height: 20px; line-height: 20px;
@ -306,7 +312,7 @@ export default defineComponent({
} }
.form-action::after { .form-action::after {
content: ""; content: '';
display: block; display: block;
clear: both; clear: both;
} }

View File

@ -1,9 +1,55 @@
<script setup> <script setup></script>
import CustomCalendar from '../components/CustomCalendar.vue'
</script>
<template> <template>
<main> <main>
<CustomCalendar /> <article>
<h1>An Exciting Blog Post</h1>
<p>
Veggies es bonus vobis, proinde vos postulo essum magis kohlrabi welsh onion daikon amaranth
tatsoi tomatillo melon azuki bean garlic.
</p>
<p>
Gumbo beet greens corn soko endive gumbo gourd. Parsley shallot courgette tatsoi pea sprouts
fava bean collard greens dandelion okra wakame tomato. Dandelion cucumber earthnut pea
peanut soko zucchini.
</p>
<p>
Turnip greens yarrow ricebean rutabaga endive cauliflower sea lettuce kohlrabi amaranth
water spinach avocado daikon napa cabbage asparagus winter purslane kale. Celery potato
scallion desert raisin horseradish spinach carrot soko. Lotus root water spinach fennel
kombu maize bamboo shoot green bean swiss chard seakale pumpkin onion chickpea gram corn
pea. Brussels sprout coriander water chestnut gourd swiss chard wakame kohlrabi beetroot
carrot watercress. Corn amaranth salsify bunya nuts nori azuki bean chickweed potato bell
pepper artichoke.
</p>
<p>
Nori grape silver beet broccoli kombu beet greens fava bean potato quandong celery. Bunya
nuts black-eyed pea prairie turnip leek lentil turnip greens parsnip. Sea lettuce lettuce
water chestnut eggplant winter purslane fennel azuki bean earthnut pea sierra leone bologi
leek soko chicory celtuce parsley jícama salsify.
</p>
<p>
Celery quandong swiss chard chicory earthnut pea potato. Salsify taro catsear garlic gram
celery bitterleaf wattle seed collard greens nori. Grape wattle seed kombu beetroot
horseradish carrot squash brussels sprout chard.
</p>
</article>
<aside>
<h2>Photography</h2>
<ul class="photos"></ul>
</aside>
</main> </main>
</template> </template>
<style>
main {
width: 80%;
display: flex;
flex: 3 1;
}
</style>