feat(admin): 添加用户管理相关文件

添加用户管理视图、API和状态管理文件
This commit is contained in:
张翔
2026-03-28 14:37:29 +08:00
commit 08ea5fbe98
1643 changed files with 255646 additions and 0 deletions
@@ -0,0 +1,122 @@
import { Page } from 'playwright';
export class MiniProgramAlmanacPage {
constructor(private page: Page) {}
async navigate() {
await this.page.goto('http://localhost:9527/#/pages/almanac/index');
await this.page.waitForLoadState('networkidle');
}
async getCurrentDate() {
const currentDate = await this.page.locator('.current-date').textContent();
return currentDate || '';
}
async getLunarDate() {
const lunarDate = await this.page.locator('.lunar-date').textContent();
return lunarDate || '';
}
async getGanZhi() {
const ganzhi = await this.page.locator('.ganzhi').textContent();
return ganzhi || '';
}
async getZodiac() {
const zodiac = await this.page.locator('.zodiac').textContent();
return zodiac || '';
}
async getSolarTerm() {
const solarTerm = await this.page.locator('.solar-term').textContent();
return solarTerm || '';
}
async getSuitable() {
const suitable = await this.page.locator('.suitable').textContent();
return suitable || '';
}
async getUnsuitable() {
const unsuitable = await this.page.locator('.unsuitable').textContent();
return unsuitable || '';
}
async getDayInfo() {
const dayInfo = await this.page.locator('.day-info').textContent();
return dayInfo || '';
}
async searchDate(date: string) {
await this.page.fill('.date-search input', date);
await this.page.click('.date-search button');
await this.page.waitForLoadState('networkidle');
}
async navigateToNextDay() {
await this.page.click('.next-day');
}
async navigateToPreviousDay() {
await this.page.click('.previous-day');
}
async isToday() {
const todayIndicator = this.page.locator('.today-indicator');
return await todayIndicator.isVisible();
}
async getAlmanacDetails() {
const details = await this.page.locator('.almanac-details').textContent();
return details || '';
}
async tapDate(date: string) {
await this.page.tap(`[data-date="${date}"]`);
}
async longPressDate(date: string) {
const element = this.page.locator(`[data-date="${date}"]`);
await element.tap();
await this.page.waitForTimeout(500);
}
async swipeLeft() {
await this.page.touchscreen.tap(0, 0);
await this.page.touchscreen.tap(100, 0);
}
async swipeRight() {
await this.page.touchscreen.tap(100, 0);
await this.page.touchscreen.tap(0, 0);
}
async shareAlmanac() {
await this.page.click('.share-button');
}
async bookmarkDate() {
await this.page.click('.bookmark-button');
}
async isBookmarked() {
const bookmarked = this.page.locator('.bookmarked');
return await bookmarked.isVisible();
}
async getLunarCalendar() {
const lunarCalendar = await this.page.locator('.lunar-calendar').textContent();
return lunarCalendar || '';
}
async getFestivals() {
const festivals = await this.page.locator('.festivals').allTextContents();
return festivals;
}
async hasFestival() {
const festivalIndicator = this.page.locator('.festival-indicator');
return await festivalIndicator.isVisible();
}
}
@@ -0,0 +1,97 @@
import { Page } from 'playwright';
export class MiniProgramCalendarPage {
constructor(private page: Page) {}
async navigate() {
await this.page.goto('http://localhost:9527/#/pages/calendar/index');
await this.page.waitForLoadState('networkidle');
}
async getCurrentDate() {
const currentDate = await this.page.locator('.current-date').textContent();
return currentDate || '';
}
async selectDate(date: string) {
await this.page.click(`[data-date="${date}"]`);
}
async getSelectedDate() {
const selectedDate = await this.page.locator('.selected-date').textContent();
return selectedDate || '';
}
async navigateToNextMonth() {
await this.page.click('.next-month');
}
async navigateToPreviousMonth() {
await this.page.click('.previous-month');
}
async getCurrentMonth() {
const currentMonth = await this.page.locator('.current-month').textContent();
return currentMonth || '';
}
async isDateVisible(date: string) {
const dateElement = this.page.locator(`[data-date="${date}"]`);
return await dateElement.isVisible();
}
async isToday(date: string) {
const todayElement = this.page.locator(`[data-date="${date}"].today`);
return await todayElement.isVisible();
}
async isWeekend(date: string) {
const weekendElement = this.page.locator(`[data-date="${date}"].weekend`);
return await weekendElement.isVisible();
}
async getCalendarEvents() {
const events = await this.page.locator('.calendar-event').allTextContents();
return events;
}
async hasEvent(date: string) {
const eventIndicator = this.page.locator(`[data-date="${date}"] .event-indicator`);
return await eventIndicator.isVisible();
}
async tapDate(date: string) {
await this.page.tap(`[data-date="${date}"]`);
}
async longPressDate(date: string) {
const element = this.page.locator(`[data-date="${date}"]`);
await element.tap();
await this.page.waitForTimeout(500);
}
async swipeLeft() {
await this.page.touchscreen.tap(0, 0);
await this.page.touchscreen.tap(100, 0);
}
async swipeRight() {
await this.page.touchscreen.tap(100, 0);
await this.page.touchscreen.tap(0, 0);
}
async getMonthView() {
const monthView = await this.page.locator('.calendar-month').textContent();
return monthView || '';
}
async getWeekDays() {
const weekDays = await this.page.locator('.week-day').allTextContents();
return weekDays;
}
async getDatesInMonth() {
const dates = await this.page.locator('.calendar-date').allTextContents();
return dates;
}
}
@@ -0,0 +1,178 @@
import { Page } from 'playwright';
export class MiniProgramSearchPage {
constructor(private page: Page) {}
async navigate() {
await this.page.goto('http://localhost:9527/#/pages/search/index');
await this.page.waitForLoadState('networkidle');
}
async search(keyword: string) {
await this.page.fill('.search-input input', keyword);
await this.page.click('.search-button');
await this.page.waitForLoadState('networkidle');
}
async clearSearch() {
await this.page.click('.clear-button');
await this.page.waitForLoadState('networkidle');
}
async getSearchResults() {
const results = await this.page.locator('.search-result').allTextContents();
return results;
}
async getResultCount() {
const count = await this.page.locator('.search-result').count();
return count;
}
async hasResults() {
const count = await this.getResultCount();
return count > 0;
}
async noResults() {
const noResults = this.page.locator('.no-results');
return await noResults.isVisible();
}
async tapResult(index: number) {
await this.page.tap(`.search-result:nth-child(${index + 1})`);
}
async longPressResult(index: number) {
const element = this.page.locator(`.search-result:nth-child(${index + 1})`);
await element.tap();
await this.page.waitForTimeout(500);
}
async getResultTitle(index: number) {
const title = await this.page.locator(`.search-result:nth-child(${index + 1}) .result-title`).textContent();
return title || '';
}
async getResultDescription(index: number) {
const description = await this.page.locator(`.search-result:nth-child(${index + 1}) .result-description`).textContent();
return description || '';
}
async getResultDate(index: number) {
const date = await this.page.locator(`.search-result:nth-child(${index + 1}) .result-date`).textContent();
return date || '';
}
async filterByType(type: string) {
await this.page.click(`.filter-type[data-type="${type}"]`);
await this.page.waitForLoadState('networkidle');
}
async filterByDate(startDate: string, endDate: string) {
await this.page.click('.filter-date');
await this.page.fill('.filter-start-date input', startDate);
await this.page.fill('.filter-end-date input', endDate);
await this.page.click('.apply-filter');
await this.page.waitForLoadState('networkidle');
}
async sortBy(sortType: string) {
await this.page.click('.sort-button');
await this.page.click(`.sort-option[data-sort="${sortType}"]`);
await this.page.waitForLoadState('networkidle');
}
async getCurrentSort() {
const currentSort = await this.page.locator('.current-sort').textContent();
return currentSort || '';
}
async getActiveFilters() {
const activeFilters = await this.page.locator('.active-filter').allTextContents();
return activeFilters;
}
async clearFilters() {
await this.page.click('.clear-filters');
await this.page.waitForLoadState('networkidle');
}
async saveSearch(keyword: string) {
await this.search(keyword);
await this.page.click('.save-search-button');
await this.page.waitForLoadState('networkidle');
}
async getSavedSearches() {
const savedSearches = await this.page.locator('.saved-search').allTextContents();
return savedSearches;
}
async deleteSavedSearch(keyword: string) {
await this.page.click(`.saved-search[data-keyword="${keyword}"] .delete-button`);
await this.page.waitForLoadState('networkidle');
}
async getRecentSearches() {
const recentSearches = await this.page.locator('.recent-search').allTextContents();
return recentSearches;
}
async clearRecentSearches() {
await this.page.click('.clear-recent');
await this.page.waitForLoadState('networkidle');
}
async getSearchSuggestions(keyword: string) {
await this.page.fill('.search-input input', keyword);
await this.page.waitForTimeout(500);
const suggestions = await this.page.locator('.search-suggestion').allTextContents();
return suggestions;
}
async selectSuggestion(index: number) {
await this.page.tap(`.search-suggestion:nth-child(${index + 1})`);
await this.page.waitForLoadState('networkidle');
}
async swipeLeft() {
await this.page.touchscreen.tap(0, 0);
await this.page.touchscreen.tap(100, 0);
}
async swipeRight() {
await this.page.touchscreen.tap(100, 0);
await this.page.touchscreen.tap(0, 0);
}
async swipeUp() {
await this.page.touchscreen.tap(0, 100);
await this.page.touchscreen.tap(0, 0);
}
async swipeDown() {
await this.page.touchscreen.tap(0, 0);
await this.page.touchscreen.tap(0, 100);
}
async getSearchHistory() {
const searchHistory = await this.page.locator('.search-history').allTextContents();
return searchHistory;
}
async clearSearchHistory() {
await this.page.click('.clear-search-history');
await this.page.waitForLoadState('networkidle');
}
async getHotSearches() {
const hotSearches = await this.page.locator('.hot-search').allTextContents();
return hotSearches;
}
async tapHotSearch(index: number) {
await this.page.tap(`.hot-search:nth-child(${index + 1})`);
await this.page.waitForLoadState('networkidle');
}
}
@@ -0,0 +1,162 @@
import { Page } from 'playwright';
export class MiniProgramUserPage {
constructor(private page: Page) {}
async navigate() {
await this.page.goto('http://localhost:9527/#/pages/user/index');
await this.page.waitForLoadState('networkidle');
}
async getUsername() {
const username = await this.page.locator('.username').textContent();
return username || '';
}
async getUserAvatar() {
const avatar = await this.page.locator('.user-avatar');
return await avatar.getAttribute('src');
}
async isLoggedIn() {
const loginButton = this.page.locator('.login-button');
return !(await loginButton.isVisible());
}
async login(username: string, password: string) {
await this.page.fill('.login-username input', username);
await this.page.fill('.login-password input', password);
await this.page.click('.login-button');
await this.page.waitForLoadState('networkidle');
}
async logout() {
await this.page.click('.logout-button');
await this.page.waitForLoadState('networkidle');
}
async navigateToProfile() {
await this.page.click('.profile-button');
await this.page.waitForLoadState('networkidle');
}
async navigateToSettings() {
await this.page.click('.settings-button');
await this.page.waitForLoadState('networkidle');
}
async navigateToHistory() {
await this.page.click('.history-button');
await this.page.waitForLoadState('networkidle');
}
async navigateToFavorites() {
await this.page.click('.favorites-button');
await this.page.waitForLoadState('networkidle');
}
async updateProfile(data: { username?: string; email?: string; phone?: string }) {
await this.navigateToProfile();
if (data.username) {
await this.page.fill('.profile-username input', data.username);
}
if (data.email) {
await this.page.fill('.profile-email input', data.email);
}
if (data.phone) {
await this.page.fill('.profile-phone input', data.phone);
}
await this.page.click('.save-button');
await this.page.waitForLoadState('networkidle');
}
async getProfile() {
const profile = {
username: await this.page.locator('.profile-username').textContent() || '',
email: await this.page.locator('.profile-email').textContent() || '',
phone: await this.page.locator('.profile-phone').textContent() || '',
};
return profile;
}
async toggleTheme() {
await this.page.click('.theme-toggle');
await this.page.waitForTimeout(500);
}
async getCurrentTheme() {
const theme = await this.page.locator('.current-theme').textContent();
return theme || '';
}
async getSettings() {
const settings = {
theme: await this.page.locator('.setting-theme').textContent() || '',
language: await this.page.locator('.setting-language').textContent() || '',
notifications: await this.page.locator('.setting-notifications').textContent() || '',
};
return settings;
}
async updateSetting(key: string, value: string) {
await this.navigateToSettings();
await this.page.click(`.setting-${key}`);
await this.page.click(`[data-value="${value}"]`);
await this.page.click('.save-button');
await this.page.waitForLoadState('networkidle');
}
async getHistory() {
const historyItems = await this.page.locator('.history-item').allTextContents();
return historyItems;
}
async clearHistory() {
await this.navigateToHistory();
await this.page.click('.clear-history-button');
await this.page.waitForLoadState('networkidle');
}
async getFavorites() {
const favorites = await this.page.locator('.favorite-item').allTextContents();
return favorites;
}
async removeFavorite(id: string) {
await this.navigateToFavorites();
await this.page.click(`[data-favorite-id="${id}"] .remove-button`);
await this.page.waitForLoadState('networkidle');
}
async tapButton(buttonClass: string) {
await this.page.tap(`.${buttonClass}`);
}
async longPressButton(buttonClass: string) {
const element = this.page.locator(`.${buttonClass}`);
await element.tap();
await this.page.waitForTimeout(500);
}
async swipeUp() {
await this.page.touchscreen.tap(0, 100);
await this.page.touchscreen.tap(0, 0);
}
async swipeDown() {
await this.page.touchscreen.tap(0, 0);
await this.page.touchscreen.tap(0, 100);
}
async getUserInfo() {
const userInfo = await this.page.locator('.user-info').textContent();
return userInfo || '';
}
async getNavigationItems() {
const navItems = await this.page.locator('.nav-item').allTextContents();
return navItems;
}
}
@@ -0,0 +1,4 @@
export { MiniProgramCalendarPage } from './CalendarPage';
export { MiniProgramAlmanacPage } from './AlmanacPage';
export { MiniProgramUserPage } from './UserPage';
export { MiniProgramSearchPage } from './SearchPage';