From 381bb46f84c9fccdabe01528e62f7d4763adabee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E5=A4=A9=E4=BD=91?=
<66231260+You-Hw-Y@users.noreply.github.com>
Date: Tue, 26 Dec 2023 01:24:12 -0800
Subject: [PATCH] docs(calendar): [calendar] optimize docs and demos (#1214)
* docs(calendar): [calendar] optimize docs and demos
* docs(calendar): [calendar] optimize docs and demos
---
.../calendar/basic-usage-composition-api.vue | 2 +-
.../demos/pc/app/calendar/basic-usage.spec.ts | 9 ++----
.../demos/pc/app/calendar/basic-usage.vue | 2 +-
.../calendar-mode-composition-api.vue | 2 +-
...der-mode.spec.ts => calendar-mode.spec.ts} | 9 ++----
.../demos/pc/app/calendar/calendar-mode.vue | 2 +-
...ustom-calendar-toolbar-composition-api.vue | 11 ++-----
.../calendar/custom-calendar-toolbar.spec.ts | 13 ++++----
.../app/calendar/custom-calendar-toolbar.vue | 25 +++++-----------
.../custom-day-cell-composition-api.vue | 2 +-
.../demos/pc/app/calendar/custom-day-cell.vue | 2 +-
.../dynamic-add-schedule-composition-api.vue | 2 +-
.../pc/app/calendar/dynamic-add-schedule.vue | 2 +-
.../show-selected-date-composition-api.vue | 2 +-
.../pc/app/calendar/show-selected-date.vue | 2 +-
.../demos/pc/app/calendar/webdoc/calendar.js | 30 ++++++++++++++-----
packages/theme/src/calendar/index.less | 30 +++++++++----------
17 files changed, 68 insertions(+), 79 deletions(-)
rename examples/sites/demos/pc/app/calendar/{calender-mode.spec.ts => calendar-mode.spec.ts} (88%)
diff --git a/examples/sites/demos/pc/app/calendar/basic-usage-composition-api.vue b/examples/sites/demos/pc/app/calendar/basic-usage-composition-api.vue
index 4c4d2d5fc..3c3d8094f 100644
--- a/examples/sites/demos/pc/app/calendar/basic-usage-composition-api.vue
+++ b/examples/sites/demos/pc/app/calendar/basic-usage-composition-api.vue
@@ -2,6 +2,6 @@
-
diff --git a/examples/sites/demos/pc/app/calendar/basic-usage.spec.ts b/examples/sites/demos/pc/app/calendar/basic-usage.spec.ts
index 5e68d9626..d1c8ba9c6 100644
--- a/examples/sites/demos/pc/app/calendar/basic-usage.spec.ts
+++ b/examples/sites/demos/pc/app/calendar/basic-usage.spec.ts
@@ -4,8 +4,8 @@ test('基本用法', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('calendar#basic-usage')
const pcDemo = page.locator('.pc-demo')
- const nowDate = new Date().getDate()
const nowMonth = new Date().getMonth() + 1
+ const today = page.locator('.today')
const selectedDay = page.getByRole('cell', { name: '14' }).locator('div').first()
const selectedMonth = page.getByRole('cell', { name: '7 月' }).locator('div').first()
// 校验日期,查看页面显示是否是月
@@ -16,12 +16,7 @@ test('基本用法', async ({ page }) => {
await expect(selectedDay).toHaveClass(/selected/)
// 校验今天按钮,选中的样式有selected today
await pcDemo.getByRole('button', { name: '今天' }).click()
- await expect(
- pcDemo
- .getByRole('cell', { name: `${nowDate}` })
- .locator('div')
- .first()
- ).toHaveClass(/selected/)
+ await expect(today).toHaveClass(/selected/)
// 校验年里的月份代码逻辑一致
await pcDemo.getByRole('listitem').filter({ hasText: '年' }).nth(2).click()
diff --git a/examples/sites/demos/pc/app/calendar/basic-usage.vue b/examples/sites/demos/pc/app/calendar/basic-usage.vue
index 8a7f36adb..e0946e2b8 100644
--- a/examples/sites/demos/pc/app/calendar/basic-usage.vue
+++ b/examples/sites/demos/pc/app/calendar/basic-usage.vue
@@ -2,7 +2,7 @@
-
diff --git a/examples/sites/demos/pc/app/calendar/calender-mode.spec.ts b/examples/sites/demos/pc/app/calendar/calendar-mode.spec.ts
similarity index 88%
rename from examples/sites/demos/pc/app/calendar/calender-mode.spec.ts
rename to examples/sites/demos/pc/app/calendar/calendar-mode.spec.ts
index e066f1561..6ac16cf53 100644
--- a/examples/sites/demos/pc/app/calendar/calender-mode.spec.ts
+++ b/examples/sites/demos/pc/app/calendar/calendar-mode.spec.ts
@@ -4,8 +4,8 @@ test('显示模式', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('calendar#calendar-mode')
const pcDemo = page.locator('.pc-demo')
- const nowDate = new Date().getDate()
const nowMonth = new Date().getMonth() + 1
+ const today = page.locator('.today')
const selectedDay = page.getByRole('cell', { name: '14' }).locator('div').first()
const selectedMonth = page.getByRole('cell', { name: '7 月' }).locator('div').first()
// 校验日期,查看页面显示是否是月
@@ -16,12 +16,7 @@ test('显示模式', async ({ page }) => {
await expect(selectedDay).toHaveClass(/selected/)
// 校验今天按钮,选中的样式有selected today
await pcDemo.getByRole('button', { name: '今天' }).click()
- await expect(
- pcDemo
- .getByRole('cell', { name: `${nowDate}` })
- .locator('div')
- .first()
- ).toHaveClass(/selected/)
+ await expect(today).toHaveClass(/selected/)
// 校验年里的月份代码逻辑一致
await pcDemo.getByRole('listitem').filter({ hasText: '年' }).nth(2).click()
diff --git a/examples/sites/demos/pc/app/calendar/calendar-mode.vue b/examples/sites/demos/pc/app/calendar/calendar-mode.vue
index db2becf03..d9c697553 100644
--- a/examples/sites/demos/pc/app/calendar/calendar-mode.vue
+++ b/examples/sites/demos/pc/app/calendar/calendar-mode.vue
@@ -2,7 +2,7 @@
-
diff --git a/examples/sites/demos/pc/app/calendar/custom-calendar-toolbar.spec.ts b/examples/sites/demos/pc/app/calendar/custom-calendar-toolbar.spec.ts
index 25c6d1f8e..47230377e 100644
--- a/examples/sites/demos/pc/app/calendar/custom-calendar-toolbar.spec.ts
+++ b/examples/sites/demos/pc/app/calendar/custom-calendar-toolbar.spec.ts
@@ -4,16 +4,15 @@ test('自定义工具栏', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('calendar#custom-calendar-toolbar')
const pcDemo = page.locator('.pc-demo')
- const year = new Date().getFullYear()
- const month = new Date().getMonth() + 1
- const day = new Date().getDate()
- const nowDate = year + '-' + month + '-' + day
- const selectedDay = page.getByRole('cell', { name: '14' }).locator('div').first()
- const time = pcDemo.getByText('时间:')
+ const selectedDay = page.getByRole('cell', { name: '10' }).locator('div').first()
+ const time = page.locator('.today')
+
// 校验选中功能
await selectedDay.click()
+ await page.waitForTimeout(200)
await expect(selectedDay).toHaveClass(/selected/)
// 校验插槽日期按钮是否生效
await pcDemo.getByRole('button', { name: '今天' }).click()
- await expect(time).toHaveText('时间:' + nowDate)
+ await page.waitForTimeout(200)
+ await expect(time).toHaveClass(/selected/)
})
diff --git a/examples/sites/demos/pc/app/calendar/custom-calendar-toolbar.vue b/examples/sites/demos/pc/app/calendar/custom-calendar-toolbar.vue
index 09e180d30..4bdb87d67 100644
--- a/examples/sites/demos/pc/app/calendar/custom-calendar-toolbar.vue
+++ b/examples/sites/demos/pc/app/calendar/custom-calendar-toolbar.vue
@@ -1,15 +1,12 @@
-
-
时间:{{ todayValue }}
-
-
- 今天
-
-
-
+
+
+ 今天
+
+
-
diff --git a/examples/sites/demos/pc/app/calendar/show-selected-date.vue b/examples/sites/demos/pc/app/calendar/show-selected-date.vue
index 9cb1001a0..eff34192c 100644
--- a/examples/sites/demos/pc/app/calendar/show-selected-date.vue
+++ b/examples/sites/demos/pc/app/calendar/show-selected-date.vue
@@ -2,7 +2,7 @@
-