Parcourir la source

清理多余的监听以及垃圾代码

chendeben il y a 1 an
Parent
commit
758d6a7296

+ 0 - 302
entry/src/main/ets/common/AppTheme.ets

@@ -1,302 +0,0 @@
-import { CustomColors, CustomTheme } from '@kit.ArkUI';
-
-// 默认主题色(浅色)
-export class DefaultColors implements CustomColors {
-  brand: ResourceColor = '#ff0a59f7';
-  warning: ResourceColor = '#ffe84026';
-  alert: ResourceColor = '#ffed6f21';
-  confirm: ResourceColor = '#ff64bb5c';
-  fontPrimary: ResourceColor = '#e5000000'; // 黑色
-  fontSecondary: ResourceColor = '#99000000';
-  fontTertiary: ResourceColor = '#66000000';
-  fontFourth: ResourceColor = '#33000000';
-  fontEmphasize: ResourceColor = '#ff0a59f7';
-  fontOnPrimary: ResourceColor = '#ffffffff'; // 白色
-  fontOnSecondary: ResourceColor = '#99ffffff';
-  fontOnTertiary: ResourceColor = '#66ffffff';
-  fontOnFourth: ResourceColor = '#33ffffff';
-  iconPrimary: ResourceColor = '#e5000000';
-  iconSecondary: ResourceColor = '#99000000';
-  iconTertiary: ResourceColor = '#66000000';
-  iconFourth: ResourceColor = '#33000000';
-  iconEmphasize: ResourceColor = '#ff0a59f7';
-  iconSubEmphasize: ResourceColor = '#660a59f7';
-  iconOnPrimary: ResourceColor = '#ffffffff';
-  iconOnSecondary: ResourceColor = '#99ffffff';
-  iconOnTertiary: ResourceColor = '#66ffffff';
-  iconOnFourth: ResourceColor = '#33ffffff';
-  backgroundPrimary: ResourceColor = '#ffffffff';
-  backgroundSecondary: ResourceColor = '#fff1f3f5';
-  backgroundTertiary: ResourceColor = '#ffe5e5ea';
-  backgroundFourth: ResourceColor = '#ffd1d1d6';
-  backgroundEmphasize: ResourceColor = '#ff0a59f7';
-  compForegroundPrimary: ResourceColor = '#ff000000';
-  compBackgroundPrimary: ResourceColor = '#ffffffff';
-  compBackgroundPrimaryTran: ResourceColor = '#ffffffff';
-  compBackgroundPrimaryContrary: ResourceColor = '#ffffffff';
-  compBackgroundGray: ResourceColor = '#fff1f3f5';
-  compBackgroundSecondary: ResourceColor = '#19000000';
-  compBackgroundTertiary: ResourceColor = '#0c000000';
-  compBackgroundEmphasize: ResourceColor = '#ff0a59f7';
-  compBackgroundNeutral: ResourceColor = '#ff000000';
-  compEmphasizeSecondary: ResourceColor = '#330a59f7';
-  compEmphasizeTertiary: ResourceColor = '#190a59f7';
-  compDivider: ResourceColor = '#33000000';
-  compCommonContrary: ResourceColor = '#ffffffff';
-  compBackgroundFocus: ResourceColor = '#fff1f3f5';
-  compFocusedPrimary: ResourceColor = '#e5000000';
-  compFocusedSecondary: ResourceColor = '#99000000';
-  compFocusedTertiary: ResourceColor = '#66000000';
-  interactiveHover: ResourceColor = '#0c000000';
-  interactivePressed: ResourceColor = '#19000000';
-  interactiveFocus: ResourceColor = '#ff0a59f7';
-  interactiveActive: ResourceColor = '#ff0a59f7';
-  interactiveSelect: ResourceColor = '#33000000';
-  interactiveClick: ResourceColor = '#19000000';
-}
-
-// 暮色主题(深色)
-export class TwilightColors implements CustomColors {
-  brand: ResourceColor = '#ff317af7';
-  warning: ResourceColor = '#ffd94838';
-  alert: ResourceColor = '#ffdb6b42';
-  confirm: ResourceColor = '#ff5ba854';
-  fontPrimary: ResourceColor = '#e5ffffff'; // 白色
-  fontSecondary: ResourceColor = '#99ffffff';
-  fontTertiary: ResourceColor = '#66ffffff';
-  fontFourth: ResourceColor = '#33ffffff';
-  fontEmphasize: ResourceColor = '#ff317af7';
-  fontOnPrimary: ResourceColor = '#ffffffff'; // 白色
-  fontOnSecondary: ResourceColor = '#e5000000'; // 深色按钮反色
-  fontOnTertiary: ResourceColor = '#e5000000';
-  fontOnFourth: ResourceColor = '#e5000000';
-  iconPrimary: ResourceColor = '#e5ffffff';
-  iconSecondary: ResourceColor = '#99ffffff';
-  iconTertiary: ResourceColor = '#66ffffff';
-  iconFourth: ResourceColor = '#33ffffff';
-  iconEmphasize: ResourceColor = '#ff317af7';
-  iconSubEmphasize: ResourceColor = '#66317af7';
-  iconOnPrimary: ResourceColor = '#ffffffff';
-  iconOnSecondary: ResourceColor = '#e5000000';
-  iconOnTertiary: ResourceColor = '#e5000000';
-  iconOnFourth: ResourceColor = '#e5000000';
-  backgroundPrimary: ResourceColor = '#ffe5e5e5';
-  backgroundSecondary: ResourceColor = '#ff191a1c';
-  backgroundTertiary: ResourceColor = '#ff202224';
-  backgroundFourth: ResourceColor = '#ff2e3033';
-  backgroundEmphasize: ResourceColor = '#ff317af7';
-  compForegroundPrimary: ResourceColor = '#ffe5e5e5';
-  compBackgroundPrimary: ResourceColor = '#23272e'; // 深色卡片
-  compBackgroundPrimaryTran: ResourceColor = '#33ffffff';
-  compBackgroundPrimaryContrary: ResourceColor = '#ffe5e5e5';
-  compBackgroundGray: ResourceColor = '#ffe5e5ea';
-  compBackgroundSecondary: ResourceColor = '#19ffffff';
-  compBackgroundTertiary: ResourceColor = '#0cffffff';
-  compBackgroundEmphasize: ResourceColor = '#ff317af7';
-  compBackgroundNeutral: ResourceColor = '#23272e';
-  compEmphasizeSecondary: ResourceColor = '#33317af7';
-  compEmphasizeTertiary: ResourceColor = '#19317af7';
-  compDivider: ResourceColor = '#33ffffff';
-  compCommonContrary: ResourceColor = '#ff000000';
-  compBackgroundFocus: ResourceColor = '#ff000000';
-  compFocusedPrimary: ResourceColor = '#e5ffffff';
-  compFocusedSecondary: ResourceColor = '#99ffffff';
-  compFocusedTertiary: ResourceColor = '#66ffffff';
-  interactiveHover: ResourceColor = '#0cffffff';
-  interactivePressed: ResourceColor = '#19ffffff';
-  interactiveFocus: ResourceColor = '#ff317af7';
-  interactiveActive: ResourceColor = '#ff317af7';
-  interactiveSelect: ResourceColor = '#33ffffff';
-  interactiveClick: ResourceColor = '#19ffffff';
-}
-
-// 森林主题(浅色)
-export class ForestColors implements CustomColors {
-  brand: ResourceColor = '#ff64bb5c';
-  warning: ResourceColor = '#ffd94838';
-  alert: ResourceColor = '#ffdb6b42';
-  confirm: ResourceColor = '#ff317af7';
-  fontPrimary: ResourceColor = '#e5000000'; // 黑色
-  fontSecondary: ResourceColor = '#99000000';
-  fontTertiary: ResourceColor = '#66000000';
-  fontFourth: ResourceColor = '#33000000';
-  fontEmphasize: ResourceColor = '#ff64bb5c';
-  fontOnPrimary: ResourceColor = '#ffffffff'; // 白色
-  fontOnSecondary: ResourceColor = '#99ffffff';
-  fontOnTertiary: ResourceColor = '#66ffffff';
-  fontOnFourth: ResourceColor = '#33ffffff';
-  iconPrimary: ResourceColor = '#e5000000';
-  iconSecondary: ResourceColor = '#99000000';
-  iconTertiary: ResourceColor = '#66000000';
-  iconFourth: ResourceColor = '#33000000';
-  iconEmphasize: ResourceColor = '#ff64bb5c';
-  iconSubEmphasize: ResourceColor = '#6664bb5c';
-  iconOnPrimary: ResourceColor = '#ffffffff';
-  iconOnSecondary: ResourceColor = '#99ffffff';
-  iconOnTertiary: ResourceColor = '#66ffffff';
-  iconOnFourth: ResourceColor = '#33ffffff';
-  backgroundPrimary: ResourceColor = '#ffffffff';
-  backgroundSecondary: ResourceColor = '#fff1f3f5';
-  backgroundTertiary: ResourceColor = '#ffe5e5ea';
-  backgroundFourth: ResourceColor = '#ffd1d1d6';
-  backgroundEmphasize: ResourceColor = '#ff64bb5c';
-  compForegroundPrimary: ResourceColor = '#ff000000';
-  compBackgroundPrimary: ResourceColor = '#ffffffff';
-  compBackgroundPrimaryTran: ResourceColor = '#ffffffff';
-  compBackgroundPrimaryContrary: ResourceColor = '#ffffffff';
-  compBackgroundGray: ResourceColor = '#fff1f3f5';
-  compBackgroundSecondary: ResourceColor = '#19000000';
-  compBackgroundTertiary: ResourceColor = '#0c000000';
-  compBackgroundEmphasize: ResourceColor = '#ff64bb5c';
-  compBackgroundNeutral: ResourceColor = '#ff000000';
-  compEmphasizeSecondary: ResourceColor = '#3364bb5c';
-  compEmphasizeTertiary: ResourceColor = '#1964bb5c';
-  compDivider: ResourceColor = '#33000000';
-  compCommonContrary: ResourceColor = '#ffffffff';
-  compBackgroundFocus: ResourceColor = '#fff1f3f5';
-  compFocusedPrimary: ResourceColor = '#e5000000';
-  compFocusedSecondary: ResourceColor = '#99000000';
-  compFocusedTertiary: ResourceColor = '#66000000';
-  interactiveHover: ResourceColor = '#0c000000';
-  interactivePressed: ResourceColor = '#19000000';
-  interactiveFocus: ResourceColor = '#ff64bb5c';
-  interactiveActive: ResourceColor = '#ff64bb5c';
-  interactiveSelect: ResourceColor = '#33000000';
-  interactiveClick: ResourceColor = '#19000000';
-}
-
-// 珊瑚主题(浅色)
-export class CoralColors implements CustomColors {
-  brand: ResourceColor = '#ffed6f21';
-  warning: ResourceColor = '#ffe84026';
-  alert: ResourceColor = '#ff0a59f7';
-  confirm: ResourceColor = '#ff64bb5c';
-  fontPrimary: ResourceColor = '#e5000000'; // 黑色
-  fontSecondary: ResourceColor = '#99000000';
-  fontTertiary: ResourceColor = '#66000000';
-  fontFourth: ResourceColor = '#33000000';
-  fontEmphasize: ResourceColor = '#ffed6f21';
-  fontOnPrimary: ResourceColor = '#ffffffff'; // 白色
-  fontOnSecondary: ResourceColor = '#99ffffff';
-  fontOnTertiary: ResourceColor = '#66ffffff';
-  fontOnFourth: ResourceColor = '#33ffffff';
-  iconPrimary: ResourceColor = '#e5000000';
-  iconSecondary: ResourceColor = '#99000000';
-  iconTertiary: ResourceColor = '#66000000';
-  iconFourth: ResourceColor = '#33000000';
-  iconEmphasize: ResourceColor = '#ffed6f21';
-  iconSubEmphasize: ResourceColor = '#66ed6f21';
-  iconOnPrimary: ResourceColor = '#ffffffff';
-  iconOnSecondary: ResourceColor = '#99ffffff';
-  iconOnTertiary: ResourceColor = '#66ffffff';
-  iconOnFourth: ResourceColor = '#33ffffff';
-  backgroundPrimary: ResourceColor = '#ffffffff';
-  backgroundSecondary: ResourceColor = '#fff1f3f5';
-  backgroundTertiary: ResourceColor = '#ffe5e5ea';
-  backgroundFourth: ResourceColor = '#ffd1d1d6';
-  backgroundEmphasize: ResourceColor = '#ffed6f21';
-  compForegroundPrimary: ResourceColor = '#ff000000';
-  compBackgroundPrimary: ResourceColor = '#ffffffff';
-  compBackgroundPrimaryTran: ResourceColor = '#ffffffff';
-  compBackgroundPrimaryContrary: ResourceColor = '#ffffffff';
-  compBackgroundGray: ResourceColor = '#fff1f3f5';
-  compBackgroundSecondary: ResourceColor = '#19000000';
-  compBackgroundTertiary: ResourceColor = '#0c000000';
-  compBackgroundEmphasize: ResourceColor = '#ffed6f21';
-  compBackgroundNeutral: ResourceColor = '#ff000000';
-  compEmphasizeSecondary: ResourceColor = '#33ed6f21';
-  compEmphasizeTertiary: ResourceColor = '#19ed6f21';
-  compDivider: ResourceColor = '#33000000';
-  compCommonContrary: ResourceColor = '#ffffffff';
-  compBackgroundFocus: ResourceColor = '#fff1f3f5';
-  compFocusedPrimary: ResourceColor = '#e5000000';
-  compFocusedSecondary: ResourceColor = '#99000000';
-  compFocusedTertiary: ResourceColor = '#66000000';
-  interactiveHover: ResourceColor = '#0c000000';
-  interactivePressed: ResourceColor = '#19000000';
-  interactiveFocus: ResourceColor = '#ffed6f21';
-  interactiveActive: ResourceColor = '#ffed6f21';
-  interactiveSelect: ResourceColor = '#33000000';
-  interactiveClick: ResourceColor = '#19000000';
-}
-
-// 极夜主题(深色)
-export class MidnightColors implements CustomColors {
-  brand: ResourceColor = '#ff5ba854';
-  warning: ResourceColor = '#ffd94838';
-  alert: ResourceColor = '#ffdb6b42';
-  confirm: ResourceColor = '#ff317af7';
-  fontPrimary: ResourceColor = '#e5ffffff'; // 白色
-  fontSecondary: ResourceColor = '#99ffffff';
-  fontTertiary: ResourceColor = '#66ffffff';
-  fontFourth: ResourceColor = '#33ffffff';
-  fontEmphasize: ResourceColor = '#ff5ba854';
-  fontOnPrimary: ResourceColor = '#ffffffff'; // 白色
-  fontOnSecondary: ResourceColor = '#e5000000'; // 深色按钮反色
-  fontOnTertiary: ResourceColor = '#e5000000';
-  fontOnFourth: ResourceColor = '#e5000000';
-  iconPrimary: ResourceColor = '#e5ffffff';
-  iconSecondary: ResourceColor = '#99ffffff';
-  iconTertiary: ResourceColor = '#66ffffff';
-  iconFourth: ResourceColor = '#33ffffff';
-  iconEmphasize: ResourceColor = '#ff5ba854';
-  iconSubEmphasize: ResourceColor = '#665ba854';
-  iconOnPrimary: ResourceColor = '#ffffffff';
-  iconOnSecondary: ResourceColor = '#e5000000';
-  iconOnTertiary: ResourceColor = '#e5000000';
-  iconOnFourth: ResourceColor = '#e5000000';
-  backgroundPrimary: ResourceColor = '#ffe5e5e5';
-  backgroundSecondary: ResourceColor = '#ff191a1c';
-  backgroundTertiary: ResourceColor = '#ff202224';
-  backgroundFourth: ResourceColor = '#ff2e3033';
-  backgroundEmphasize: ResourceColor = '#ff5ba854';
-  compForegroundPrimary: ResourceColor = '#ffe5e5e5';
-  compBackgroundPrimary: ResourceColor = '#23272e'; // 深色卡片
-  compBackgroundPrimaryTran: ResourceColor = '#33ffffff';
-  compBackgroundPrimaryContrary: ResourceColor = '#ffe5e5e5';
-  compBackgroundGray: ResourceColor = '#ffe5e5ea';
-  compBackgroundSecondary: ResourceColor = '#19ffffff';
-  compBackgroundTertiary: ResourceColor = '#0cffffff';
-  compBackgroundEmphasize: ResourceColor = '#ff5ba854';
-  compBackgroundNeutral: ResourceColor = '#23272e';
-  compEmphasizeSecondary: ResourceColor = '#335ba854';
-  compEmphasizeTertiary: ResourceColor = '#195ba854';
-  compDivider: ResourceColor = '#33ffffff';
-  compCommonContrary: ResourceColor = '#ff000000';
-  compBackgroundFocus: ResourceColor = '#ff000000';
-  compFocusedPrimary: ResourceColor = '#e5ffffff';
-  compFocusedSecondary: ResourceColor = '#99ffffff';
-  compFocusedTertiary: ResourceColor = '#66ffffff';
-  interactiveHover: ResourceColor = '#0cffffff';
-  interactivePressed: ResourceColor = '#19ffffff';
-  interactiveFocus: ResourceColor = '#ff5ba854';
-  interactiveActive: ResourceColor = '#ff5ba854';
-  interactiveSelect: ResourceColor = '#33ffffff';
-  interactiveClick: ResourceColor = '#19ffffff';
-}
-
-export class DefaultTheme implements CustomTheme {
-  public colors: DefaultColors = new DefaultColors();
-}
-export class TwilightTheme implements CustomTheme {
-  public colors: TwilightColors = new TwilightColors();
-}
-export class ForestTheme implements CustomTheme {
-  public colors: ForestColors = new ForestColors();
-}
-export class CoralTheme implements CustomTheme {
-  public colors: CoralColors = new CoralColors();
-}
-export class MidnightTheme implements CustomTheme {
-  public colors: MidnightColors = new MidnightColors();
-}
-
-export const ThemeList: CustomTheme[] = [
-  new DefaultTheme(),
-  new TwilightTheme(),
-  new ForestTheme(),
-  new CoralTheme(),
-  new MidnightTheme()
-];
-
-export const myTheme:CustomTheme=new MidnightTheme();

+ 0 - 118
entry/src/main/ets/common/widget/ObjectUtils.ets

@@ -1,118 +0,0 @@
-import { WidgetPersonalConfig, UserPreferences } from './WidgetConfigManager';
-import { ThemeInfo } from './ThemeSyncService';
-
-/**
- * 对象工具类
- * 提供ArkTS兼容的对象操作方法
- */
-export class ObjectUtils {
-  /**
-   * 克隆WidgetPersonalConfig对象
-   */
-  static cloneWidgetConfig(config: WidgetPersonalConfig): WidgetPersonalConfig {
-    return {
-      showProgress: config.showProgress,
-      showCover: config.showCover,
-      showAlbum: config.showAlbum,
-      showTime: config.showTime,
-      theme: config.theme,
-      backgroundColor: config.backgroundColor,
-      textColor: config.textColor,
-      accentColor: config.accentColor,
-      buttonSize: config.buttonSize,
-      fontSize: config.fontSize,
-      borderRadius: config.borderRadius,
-      autoUpdate: config.autoUpdate,
-      updateInterval: config.updateInterval,
-      clickBehavior: config.clickBehavior,
-      enableAnimations: config.enableAnimations,
-      enableHapticFeedback: config.enableHapticFeedback,
-      enableShadow: config.enableShadow
-    };
-  }
-
-  /**
-   * 克隆UserPreferences对象
-   */
-  static cloneUserPreferences(prefs: UserPreferences): UserPreferences {
-    return {
-      defaultTheme: prefs.defaultTheme,
-      defaultSize: prefs.defaultSize,
-      syncWithMainApp: prefs.syncWithMainApp,
-      syncThemeColor: prefs.syncThemeColor,
-      enableCache: prefs.enableCache,
-      cacheExpiry: prefs.cacheExpiry,
-      showSongInfo: prefs.showSongInfo,
-      showArtistInfo: prefs.showArtistInfo,
-      showAlbumCover: prefs.showAlbumCover
-    };
-  }
-
-  /**
-   * 克隆ThemeInfo对象
-   */
-  static cloneThemeInfo(theme: ThemeInfo): ThemeInfo {
-    return {
-      theme: theme.theme,
-      primaryColor: theme.primaryColor,
-      backgroundColor: theme.backgroundColor,
-      textColor: theme.textColor,
-      accentColor: theme.accentColor,
-      isDarkMode: theme.isDarkMode
-    };
-  }
-
-  /**
-   * 合并UserPreferences对象
-   */
-  static mergeUserPreferences(target: UserPreferences, source: Partial<UserPreferences>): UserPreferences {
-    const result = ObjectUtils.cloneUserPreferences(target);
-    
-    if (source.defaultTheme !== undefined) result.defaultTheme = source.defaultTheme;
-    if (source.defaultSize !== undefined) result.defaultSize = source.defaultSize;
-    if (source.syncWithMainApp !== undefined) result.syncWithMainApp = source.syncWithMainApp;
-    if (source.syncThemeColor !== undefined) result.syncThemeColor = source.syncThemeColor;
-    if (source.enableCache !== undefined) result.enableCache = source.enableCache;
-    if (source.cacheExpiry !== undefined) result.cacheExpiry = source.cacheExpiry;
-    if (source.showSongInfo !== undefined) result.showSongInfo = source.showSongInfo;
-    if (source.showArtistInfo !== undefined) result.showArtistInfo = source.showArtistInfo;
-    if (source.showAlbumCover !== undefined) result.showAlbumCover = source.showAlbumCover;
-    
-    return result;
-  }
-
-  /**
-   * 合并ThemeInfo对象
-   */
-  static mergeThemeInfo(target: ThemeInfo, source: Partial<ThemeInfo>): ThemeInfo {
-    const result = ObjectUtils.cloneThemeInfo(target);
-    
-    if (source.theme !== undefined) result.theme = source.theme;
-    if (source.primaryColor !== undefined) result.primaryColor = source.primaryColor;
-    if (source.backgroundColor !== undefined) result.backgroundColor = source.backgroundColor;
-    if (source.textColor !== undefined) result.textColor = source.textColor;
-    if (source.accentColor !== undefined) result.accentColor = source.accentColor;
-    if (source.isDarkMode !== undefined) result.isDarkMode = source.isDarkMode;
-    
-    return result;
-  }
-
-  /**
-   * 通用对象克隆方法
-   */
-  static assign<T>(obj: T): T {
-    if (obj === null || typeof obj !== 'object') {
-      return obj;
-    }
-
-    const cloned: Record<string, Object> = {};
-    const keys = Object.keys(obj);
-    for (let i = 0; i < keys.length; i++) {
-      const key = keys[i];
-      const objRecord = obj as Record<string, Object>;
-      cloned[key] = objRecord[key];
-    }
-    
-    return cloned as T;
-  }
-}

+ 0 - 376
entry/src/main/ets/common/widget/ThemeSyncService.ets

@@ -1,376 +0,0 @@
-import { hilog } from '@kit.PerformanceAnalysisKit';
-import { WidgetTheme, WidgetSize } from './WidgetTypes';
-import { WidgetConfigManager, WidgetPersonalConfig } from './WidgetConfigManager';
-import commonEventManager from '@ohos.commonEventManager';
-import { ObjectUtils } from './ObjectUtils';
-
-const TAG = 'ThemeSyncService';
-
-/**
- * 主题信息接口
- */
-export interface ThemeInfo {
-  theme: WidgetTheme;
-  primaryColor: string;
-  backgroundColor: string;
-  textColor: string;
-  accentColor: string;
-  isDarkMode: boolean;
-}
-
-/**
- * 主题变化事件接口
- */
-export interface ThemeChangeEvent {
-  type: 'theme_changed';
-  themeInfo: ThemeInfo;
-  timestamp: number;
-}
-
-/**
- * 主题变化事件数据接口
- */
-export interface ThemeChangeEventData {
-  theme: WidgetTheme;
-  colors: ThemeColors;
-}
-
-/**
- * 主题颜色接口
- */
-export interface ThemeColors {
-  backgroundColor: string;
-  textColor: string;
-  accentColor: string;
-}
-
-/**
- * 主题同步服务
- * 负责与主应用的主题色彩同步
- * 需求: 5.4, 6.3
- */
-export class ThemeSyncService {
-  private static instance: ThemeSyncService;
-  private configManager: WidgetConfigManager;
-  private currentTheme: ThemeInfo | null = null;
-  private themeChangeListeners: Set<ThemeChangeListener> = new Set();
-  private isListening: boolean = false;
-
-  /**
-   * 获取单例实例
-   */
-  public static getInstance(): ThemeSyncService {
-    if (!ThemeSyncService.instance) {
-      ThemeSyncService.instance = new ThemeSyncService();
-    }
-    return ThemeSyncService.instance;
-  }
-
-  private constructor() {
-    this.configManager = WidgetConfigManager.getInstance();
-    hilog.info(0x0000, TAG, 'ThemeSyncService initialized');
-  }
-
-  /**
-   * 启动主题同步监听
-   */
-  public async startThemeSync(): Promise<void> {
-    if (this.isListening) {
-      hilog.warn(0x0000, TAG, 'Theme sync already started');
-      return;
-    }
-
-    try {
-      // 订阅主应用主题变化事件
-      await this.subscribeToThemeChanges();
-      
-      // 获取当前主题
-      await this.loadCurrentTheme();
-      
-      this.isListening = true;
-      hilog.info(0x0000, TAG, 'Theme sync started successfully');
-    } catch (error) {
-      hilog.error(0x0000, TAG, `Failed to start theme sync: ${error}`);
-    }
-  }
-
-  /**
-   * 停止主题同步监听
-   */
-  public async stopThemeSync(): Promise<void> {
-    if (!this.isListening) {
-      return;
-    }
-
-    try {
-      // 取消订阅主题变化事件
-      await this.unsubscribeFromThemeChanges();
-      
-      this.isListening = false;
-      hilog.info(0x0000, TAG, 'Theme sync stopped');
-    } catch (error) {
-      hilog.error(0x0000, TAG, `Failed to stop theme sync: ${error}`);
-    }
-  }
-
-  /**
-   * 获取当前主题信息
-   */
-  public getCurrentTheme(): ThemeInfo | null {
-    return this.currentTheme;
-  }
-
-  /**
-   * 手动同步主题
-   */
-  public async syncTheme(): Promise<void> {
-    try {
-      const themeInfo = await this.fetchThemeFromMainApp();
-      if (themeInfo) {
-        await this.applyThemeToAllWidgets(themeInfo);
-        hilog.info(0x0000, TAG, 'Theme synced manually');
-      }
-    } catch (error) {
-      hilog.error(0x0000, TAG, `Failed to sync theme manually: ${error}`);
-    }
-  }
-
-  /**
-   * 注册主题变化监听器
-   * @param listener 监听器
-   */
-  public addThemeChangeListener(listener: ThemeChangeListener): void {
-    this.themeChangeListeners.add(listener);
-    hilog.info(0x0000, TAG, 'Theme change listener added');
-  }
-
-  /**
-   * 移除主题变化监听器
-   * @param listener 监听器
-   */
-  public removeThemeChangeListener(listener: ThemeChangeListener): void {
-    this.themeChangeListeners.delete(listener);
-    hilog.info(0x0000, TAG, 'Theme change listener removed');
-  }
-
-  /**
-   * 应用主题到指定卡片
-   * @param formId 卡片ID
-   * @param themeInfo 主题信息
-   */
-  public async applyThemeToWidget(formId: string, themeInfo: ThemeInfo): Promise<void> {
-    try {
-      // 获取当前配置
-      const currentConfig = await this.configManager.getWidgetConfig(formId, WidgetSize.MEDIUM);
-      
-      // 应用主题色彩
-      const updatedConfig: WidgetPersonalConfig = ObjectUtils.cloneWidgetConfig(currentConfig);
-      updatedConfig.theme = themeInfo.theme;
-      updatedConfig.backgroundColor = themeInfo.backgroundColor;
-      updatedConfig.textColor = themeInfo.textColor;
-      updatedConfig.accentColor = themeInfo.accentColor;
-      
-      // 保存更新后的配置
-      await this.configManager.saveWidgetConfig(formId, WidgetSize.MEDIUM, updatedConfig);
-      
-      hilog.info(0x0000, TAG, `Theme applied to widget: ${formId}`);
-    } catch (error) {
-      hilog.error(0x0000, TAG, `Failed to apply theme to widget ${formId}: ${error}`);
-    }
-  }
-
-  /**
-   * 获取系统主题信息
-   */
-  public async getSystemTheme(): Promise<ThemeInfo> {
-    try {
-      // 从系统获取主题信息
-      const isDarkMode = await this.isSystemDarkMode();
-      
-      return {
-        theme: isDarkMode ? WidgetTheme.DARK : WidgetTheme.LIGHT,
-        primaryColor: isDarkMode ? '#FFFFFF' : '#000000',
-        backgroundColor: isDarkMode ? '#1C1C1E' : '#FFFFFF',
-        textColor: isDarkMode ? '#FFFFFF' : '#000000',
-        accentColor: '#FF007DFF',
-        isDarkMode: isDarkMode
-      };
-    } catch (error) {
-      hilog.error(0x0000, TAG, `Failed to get system theme: ${error}`);
-      return this.getDefaultTheme();
-    }
-  }
-
-  /**
-   * 创建自定义主题
-   * @param customColors 自定义颜色
-   */
-  public createCustomTheme(customColors: Partial<ThemeInfo>): ThemeInfo {
-    const defaultTheme = this.getDefaultTheme();
-    
-    const customTheme: ThemeInfo = ObjectUtils.mergeThemeInfo(defaultTheme, customColors);
-    customTheme.theme = WidgetTheme.LIGHT; // 自定义主题默认为浅色
-    return customTheme;
-  }
-
-  /**
-   * 订阅主题变化事件
-   */
-  private async subscribeToThemeChanges(): Promise<void> {
-    try {
-      const subscribeInfo: commonEventManager.CommonEventSubscribeInfo = {
-        events: ['usual.event.THEME_CHANGED', 'usual.event.DARK_MODE_CHANGED']
-      };
-      
-      const subscriber = await commonEventManager.createSubscriber(subscribeInfo);
-      await commonEventManager.subscribe(subscriber, (err, data) => {
-        if (err) {
-          hilog.error(0x0000, TAG, `Theme change subscription error: ${err}`);
-          return;
-        }
-        
-        this.handleThemeChangeEvent(data);
-      });
-      
-      hilog.info(0x0000, TAG, 'Subscribed to theme change events');
-    } catch (error) {
-      hilog.error(0x0000, TAG, `Failed to subscribe to theme changes: ${error}`);
-    }
-  }
-
-  /**
-   * 取消订阅主题变化事件
-   */
-  private async unsubscribeFromThemeChanges(): Promise<void> {
-    try {
-      // 这里应该取消订阅,但由于API限制,暂时留空
-      hilog.info(0x0000, TAG, 'Unsubscribed from theme change events');
-    } catch (error) {
-      hilog.error(0x0000, TAG, `Failed to unsubscribe from theme changes: ${error}`);
-    }
-  }
-
-  /**
-   * 处理主题变化事件
-   */
-  private async handleThemeChangeEvent(eventData: commonEventManager.CommonEventData): Promise<void> {
-    try {
-      hilog.info(0x0000, TAG, 'Theme change event received');
-      
-      // 重新加载主题
-      await this.loadCurrentTheme();
-      
-      // 通知监听器
-      if (this.currentTheme) {
-        this.notifyThemeChangeListeners(this.currentTheme);
-      }
-    } catch (error) {
-      hilog.error(0x0000, TAG, `Failed to handle theme change event: ${error}`);
-    }
-  }
-
-  /**
-   * 加载当前主题
-   */
-  private async loadCurrentTheme(): Promise<void> {
-    try {
-      const themeInfo = await this.fetchThemeFromMainApp();
-      if (themeInfo) {
-        this.currentTheme = themeInfo;
-        hilog.info(0x0000, TAG, 'Current theme loaded');
-      }
-    } catch (error) {
-      hilog.error(0x0000, TAG, `Failed to load current theme: ${error}`);
-      this.currentTheme = this.getDefaultTheme();
-    }
-  }
-
-  /**
-   * 从主应用获取主题信息
-   */
-  private async fetchThemeFromMainApp(): Promise<ThemeInfo | null> {
-    try {
-      // 这里应该从主应用的主题管理器获取主题信息
-      // 暂时返回系统主题
-      return await this.getSystemTheme();
-    } catch (error) {
-      hilog.error(0x0000, TAG, `Failed to fetch theme from main app: ${error}`);
-      return null;
-    }
-  }
-
-  /**
-   * 应用主题到所有卡片
-   */
-  private async applyThemeToAllWidgets(themeInfo: ThemeInfo): Promise<void> {
-    try {
-      await this.configManager.updateAllWidgetConfigs((config) => {
-        const updatedConfig = ObjectUtils.cloneWidgetConfig(config);
-        updatedConfig.theme = themeInfo.theme;
-        updatedConfig.backgroundColor = themeInfo.backgroundColor;
-        updatedConfig.textColor = themeInfo.textColor;
-        updatedConfig.accentColor = themeInfo.accentColor;
-        return updatedConfig;
-      });
-      
-      hilog.info(0x0000, TAG, 'Theme applied to all widgets');
-    } catch (error) {
-      hilog.error(0x0000, TAG, `Failed to apply theme to all widgets: ${error}`);
-    }
-  }
-
-  /**
-   * 通知主题变化监听器
-   */
-  private notifyThemeChangeListeners(themeInfo: ThemeInfo): void {
-    const event: ThemeChangeEvent = {
-      type: 'theme_changed',
-      themeInfo: themeInfo,
-      timestamp: Date.now()
-    };
-    
-    const listeners = Array.from(this.themeChangeListeners);
-    for (let i = 0; i < listeners.length; i++) {
-      try {
-        listeners[i].onThemeChanged(event);
-      } catch (error) {
-        hilog.error(0x0000, TAG, `Error notifying theme change listener: ${error}`);
-      }
-    }
-  }
-
-  /**
-   * 检查系统是否为深色模式
-   */
-  private async isSystemDarkMode(): Promise<boolean> {
-    try {
-      // 这里应该检查系统的深色模式设置
-      // 暂时返回false(浅色模式)
-      return false;
-    } catch (error) {
-      hilog.error(0x0000, TAG, `Failed to check system dark mode: ${error}`);
-      return false;
-    }
-  }
-
-  /**
-   * 获取默认主题
-   */
-  private getDefaultTheme(): ThemeInfo {
-    return {
-      theme: WidgetTheme.LIGHT,
-      primaryColor: '#000000',
-      backgroundColor: '#FFFFFF',
-      textColor: '#E6000000',
-      accentColor: '#FF007DFF',
-      isDarkMode: false
-    };
-  }
-}
-
-/**
- * 主题变化监听器接口
- */
-export interface ThemeChangeListener {
-  onThemeChanged(event: ThemeChangeEvent): void;
-}

+ 0 - 404
entry/src/main/ets/common/widget/UserPreferencesService.ets

@@ -1,404 +0,0 @@
-import preferences from '@ohos.data.preferences';
-import { hilog } from '@kit.PerformanceAnalysisKit';
-import { WidgetSize, WidgetTheme } from './WidgetTypes';
-import { UserPreferences } from './WidgetConfigManager';
-import { ObjectUtils } from './ObjectUtils';
-
-const TAG = 'Heanup UserPreferencesService';
-
-/**
- * 用户偏好设置错误类
- */
-class UserPreferencesError extends Error {
-  constructor(message: string) {
-    super(message);
-    this.name = 'UserPreferencesError';
-  }
-}
-const USER_PREFERENCES_NAME = 'user_widget_preferences';
-
-/**
- * 偏好设置变化事件接口
- */
-export interface PreferencesChangeEvent {
-  type: 'preferences_changed';
-  changedKeys: string[];
-  newPreferences: UserPreferences;
-  timestamp: number;
-}
-
-/**
- * 用户偏好设置服务
- * 负责用户偏好设置的存储和管理
- * 需求: 5.4, 6.3
- */
-export class UserPreferencesService {
-  private static instance: UserPreferencesService;
-  private preferencesStore: preferences.Preferences | null = null;
-  private currentPreferences: UserPreferences | null = null;
-  private changeListeners: Set<PreferencesChangeListener> = new Set();
-
-  /**
-   * 获取单例实例
-   */
-  public static getInstance(): UserPreferencesService {
-    if (!UserPreferencesService.instance) {
-      UserPreferencesService.instance = new UserPreferencesService();
-    }
-    return UserPreferencesService.instance;
-  }
-
-  private constructor() {
-    this.initPreferences();
-    hilog.info(0x0000, TAG, 'UserPreferencesService initialized');
-  }
-
-  /**
-   * 初始化偏好设置存储
-   */
-  private async initPreferences(): Promise<void> {
-    try {
-      this.preferencesStore = await preferences.getPreferences(getContext(), USER_PREFERENCES_NAME);
-      await this.loadPreferences();
-      hilog.info(0x0000, TAG, 'User preferences initialized successfully');
-    } catch (error) {
-      hilog.error(0x0000, TAG, `Failed to initialize user preferences: ${error}`);
-    }
-  }
-
-  /**
-   * 获取用户偏好设置
-   */
-  public async getPreferences(): Promise<UserPreferences> {
-    if (this.currentPreferences) {
-      return this.currentPreferences;
-    }
-
-    await this.loadPreferences();
-    return this.currentPreferences || this.getDefaultPreferences();
-  }
-
-  /**
-   * 更新用户偏好设置
-   * @param updates 要更新的偏好设置
-   */
-  public async updatePreferences(updates: Partial<UserPreferences>): Promise<void> {
-    try {
-      const currentPrefs = await this.getPreferences();
-      const newPreferences: UserPreferences = ObjectUtils.mergeUserPreferences(currentPrefs, updates);
-
-      await this.savePreferences(newPreferences);
-
-      // 通知变化监听器
-      const changedKeys = Object.keys(updates);
-      this.notifyPreferencesChange(changedKeys, newPreferences);
-
-      hilog.info(0x0000, TAG, `User preferences updated: ${changedKeys.join(', ')}`);
-    } catch (error) {
-      hilog.error(0x0000, TAG, `Failed to update user preferences: ${error}`);
-    }
-  }
-
-  /**
-   * 重置用户偏好设置为默认值
-   */
-  public async resetPreferences(): Promise<void> {
-    try {
-      const defaultPrefs = this.getDefaultPreferences();
-      await this.savePreferences(defaultPrefs);
-
-      // 通知所有设置都已更改
-      const allKeys = Object.keys(defaultPrefs);
-      this.notifyPreferencesChange(allKeys, defaultPrefs);
-
-      hilog.info(0x0000, TAG, 'User preferences reset to default');
-    } catch (error) {
-      hilog.error(0x0000, TAG, `Failed to reset user preferences: ${error}`);
-    }
-  }
-
-  /**
-   * 获取特定偏好设置值
-   * @param key 设置键
-   * @returns 设置值
-   */
-  public async getPreference(key: string): Promise<Object> {
-    const preferences = await this.getPreferences();
-    const prefsObj = preferences as Object as Record<string, Object>;
-    return prefsObj[key];
-  }
-
-  /**
-   * 设置特定偏好设置值
-   * @param key 设置键
-   * @param value 设置值
-   */
-  public async setPreference(key: string, value: Object): Promise<void> {
-    const updates: Partial<UserPreferences> = {};
-    const updatesRecord = updates as Record<string, Object>;
-    updatesRecord[key] = value;
-    await this.updatePreferences(updates);
-  }
-
-  /**
-   * 导出用户偏好设置
-   * @returns 偏好设置的JSON字符串
-   */
-  public async exportPreferences(): Promise<string> {
-    try {
-      const preferences = await this.getPreferences();
-      return JSON.stringify(preferences, null, 2);
-    } catch (error) {
-      hilog.error(0x0000, TAG, `Failed to export preferences: ${error}`);
-      throw new UserPreferencesError(`Failed to export preferences: ${error}`);
-    }
-  }
-
-  /**
-   * 导入用户偏好设置
-   * @param preferencesJson 偏好设置的JSON字符串
-   */
-  public async importPreferences(preferencesJson: string): Promise<void> {
-    try {
-      const importedPrefs = JSON.parse(preferencesJson) as UserPreferences;
-
-      // 验证导入的数据
-      const validatedPrefs = this.validatePreferences(importedPrefs);
-
-      await this.savePreferences(validatedPrefs);
-
-      // 通知所有设置都已更改
-      const allKeys = Object.keys(validatedPrefs);
-      this.notifyPreferencesChange(allKeys, validatedPrefs);
-
-      hilog.info(0x0000, TAG, 'User preferences imported successfully');
-    } catch (error) {
-      hilog.error(0x0000, TAG, `Failed to import preferences: ${error}`);
-      throw new UserPreferencesError(`Failed to import preferences: ${error}`);
-    }
-  }
-
-  /**
-   * 注册偏好设置变化监听器
-   * @param listener 监听器
-   */
-  public addPreferencesChangeListener(listener: PreferencesChangeListener): void {
-    this.changeListeners.add(listener);
-    hilog.info(0x0000, TAG, 'Preferences change listener added');
-  }
-
-  /**
-   * 移除偏好设置变化监听器
-   * @param listener 监听器
-   */
-  public removePreferencesChangeListener(listener: PreferencesChangeListener): void {
-    this.changeListeners.delete(listener);
-    hilog.info(0x0000, TAG, 'Preferences change listener removed');
-  }
-
-  /**
-   * 检查偏好设置是否为默认值
-   */
-  public async isDefaultPreferences(): Promise<boolean> {
-    try {
-      const currentPrefs = await this.getPreferences();
-      const defaultPrefs = this.getDefaultPreferences();
-
-      return JSON.stringify(currentPrefs) === JSON.stringify(defaultPrefs);
-    } catch (error) {
-      hilog.error(0x0000, TAG, `Failed to check if preferences are default: ${error}`);
-      return false;
-    }
-  }
-
-  /**
-   * 获取偏好设置统计信息
-   */
-  public async getPreferencesStats(): Promise<PreferencesStats> {
-    try {
-      const preferences = await this.getPreferences();
-      const isDefault = await this.isDefaultPreferences();
-
-      return {
-        isDefault: isDefault,
-        syncEnabled: preferences.syncWithMainApp,
-        themeMode: preferences.defaultTheme,
-        cacheEnabled: preferences.enableCache,
-        privacyLevel: this.calculatePrivacyLevel(preferences),
-        lastModified: Date.now() // 实际应该存储真实的修改时间
-      };
-    } catch (error) {
-      hilog.error(0x0000, TAG, `Failed to get preferences stats: ${error}`);
-      throw new UserPreferencesError(`Failed to get preferences stats: ${error}`);
-    }
-  }
-
-  /**
-   * 加载偏好设置
-   */
-  private async loadPreferences(): Promise<void> {
-    try {
-      if (!this.preferencesStore) {
-        await this.initPreferences();
-      }
-
-      const prefsStr = await this.preferencesStore?.get('user_preferences', '') as string;
-      if (prefsStr) {
-        this.currentPreferences = JSON.parse(prefsStr) as UserPreferences;
-      } else {
-        this.currentPreferences = this.getDefaultPreferences();
-        await this.savePreferences(this.currentPreferences);
-      }
-    } catch (error) {
-      hilog.error(0x0000, TAG, `Failed to load preferences: ${error}`);
-      this.currentPreferences = this.getDefaultPreferences();
-    }
-  }
-
-  /**
-   * 保存偏好设置
-   */
-  private async savePreferences(preferences: UserPreferences): Promise<void> {
-    try {
-      if (!this.preferencesStore) {
-        await this.initPreferences();
-      }
-
-      await this.preferencesStore?.put('user_preferences', JSON.stringify(preferences));
-      await this.preferencesStore?.flush();
-
-      this.currentPreferences = preferences;
-    } catch (error) {
-      hilog.error(0x0000, TAG, `Failed to save preferences: ${error}`);
-      throw new UserPreferencesError(`Failed to save preferences: ${error}`);
-    }
-  }
-
-  /**
-   * 获取默认偏好设置
-   */
-  private getDefaultPreferences(): UserPreferences {
-    return {
-      // 全局偏好
-      defaultTheme: WidgetTheme.AUTO,
-      defaultSize: WidgetSize.MEDIUM,
-
-      // 同步设置
-      syncWithMainApp: true,
-      syncThemeColor: true,
-
-      // 性能设置
-      enableCache: true,
-      cacheExpiry: 30000,
-
-      // 隐私设置
-      showSongInfo: true,
-      showArtistInfo: true,
-      showAlbumCover: true
-    };
-  }
-
-  /**
-   * 验证偏好设置数据
-   */
-  private validatePreferences(preferences: Object): UserPreferences {
-    const defaultPrefs = this.getDefaultPreferences();
-
-    // 类型保护:确保 preferences 是一个对象
-    if (typeof preferences !== 'object' || preferences === null) {
-      return defaultPrefs;
-    }
-
-    const prefsObj = preferences as Record<string, Object>;
-
-    // 确保所有必需的字段都存在且类型正确
-    return {
-      defaultTheme: this.validateTheme(prefsObj.defaultTheme) || defaultPrefs.defaultTheme,
-      defaultSize: this.validateSize(prefsObj.defaultSize) || defaultPrefs.defaultSize,
-      syncWithMainApp: typeof prefsObj.syncWithMainApp === 'boolean' ? prefsObj.syncWithMainApp : defaultPrefs.syncWithMainApp,
-      syncThemeColor: typeof prefsObj.syncThemeColor === 'boolean' ? prefsObj.syncThemeColor : defaultPrefs.syncThemeColor,
-      enableCache: typeof prefsObj.enableCache === 'boolean' ? prefsObj.enableCache : defaultPrefs.enableCache,
-      cacheExpiry: typeof prefsObj.cacheExpiry === 'number' && prefsObj.cacheExpiry > 0 ? prefsObj.cacheExpiry : defaultPrefs.cacheExpiry,
-      showSongInfo: typeof prefsObj.showSongInfo === 'boolean' ? prefsObj.showSongInfo : defaultPrefs.showSongInfo,
-      showArtistInfo: typeof prefsObj.showArtistInfo === 'boolean' ? prefsObj.showArtistInfo : defaultPrefs.showArtistInfo,
-      showAlbumCover: typeof prefsObj.showAlbumCover === 'boolean' ? prefsObj.showAlbumCover : defaultPrefs.showAlbumCover
-    };
-  }
-
-  /**
-   * 验证主题值
-   */
-  private validateTheme(theme: Object): WidgetTheme | null {
-    const themeValues = [WidgetTheme.AUTO, WidgetTheme.LIGHT, WidgetTheme.DARK];
-    if (themeValues.includes(theme as WidgetTheme)) {
-      return theme as WidgetTheme;
-    }
-    return null;
-  }
-
-  /**
-   * 验证尺寸值
-   */
-  private validateSize(size: Object): WidgetSize | null {
-    const sizeValues = [WidgetSize.SMALL, WidgetSize.MEDIUM, WidgetSize.LARGE];
-    if (sizeValues.includes(size as WidgetSize)) {
-      return size as WidgetSize;
-    }
-    return null;
-  }
-
-  /**
-   * 计算隐私级别
-   */
-  private calculatePrivacyLevel(preferences: UserPreferences): 'high' | 'medium' | 'low' {
-    let privacyScore = 0;
-
-    if (!preferences.showSongInfo) privacyScore++;
-    if (!preferences.showArtistInfo) privacyScore++;
-    if (!preferences.showAlbumCover) privacyScore++;
-
-    if (privacyScore >= 2) return 'high';
-    if (privacyScore === 1) return 'medium';
-    return 'low';
-  }
-
-  /**
-   * 通知偏好设置变化
-   */
-  private notifyPreferencesChange(changedKeys: string[], newPreferences: UserPreferences): void {
-    const event: PreferencesChangeEvent = {
-      type: 'preferences_changed',
-      changedKeys: changedKeys,
-      newPreferences: newPreferences,
-      timestamp: Date.now()
-    };
-
-    const listeners = Array.from(this.changeListeners);
-    for (let i = 0; i < listeners.length; i++) {
-      try {
-        listeners[i].onPreferencesChanged(event);
-      } catch (error) {
-        hilog.error(0x0000, TAG, `Error notifying preferences change listener: ${error}`);
-      }
-    }
-  }
-}
-
-/**
- * 偏好设置变化监听器接口
- */
-export interface PreferencesChangeListener {
-  onPreferencesChanged(event: PreferencesChangeEvent): void;
-}
-
-/**
- * 偏好设置统计信息接口
- */
-export interface PreferencesStats {
-  isDefault: boolean;
-  syncEnabled: boolean;
-  themeMode: WidgetTheme;
-  cacheEnabled: boolean;
-  privacyLevel: 'high' | 'medium' | 'low';
-  lastModified: number;
-}

+ 0 - 445
entry/src/main/ets/common/widget/WidgetConfigManager.ets

@@ -1,445 +0,0 @@
-import preferences from '@ohos.data.preferences';
-import { hilog } from '@kit.PerformanceAnalysisKit';
-import { WidgetSize, WidgetTheme, WidgetConfig } from './WidgetTypes';
-import { ObjectUtils } from './ObjectUtils';
-
-const TAG = 'WidgetConfigManager';
-const CONFIG_PREFERENCES_NAME = 'widget_config_prefs';
-
-/**
- * 卡片个性化配置接口
- */
-export interface WidgetPersonalConfig {
-  // 显示配置
-  showProgress: boolean;
-  showCover: boolean;
-  showAlbum: boolean;
-  showTime: boolean;
-  
-  // 主题配置
-  theme: WidgetTheme;
-  backgroundColor: string;
-  textColor: string;
-  accentColor: string;
-  
-  // 布局配置
-  buttonSize: 'small' | 'medium' | 'large';
-  fontSize: 'small' | 'medium' | 'large';
-  borderRadius: number;
-  
-  // 行为配置
-  autoUpdate: boolean;
-  updateInterval: number;
-  clickBehavior: 'play_pause' | 'open_app' | 'open_player';
-  
-  // 高级配置
-  enableAnimations: boolean;
-  enableHapticFeedback: boolean;
-  enableShadow: boolean;
-}
-
-/**
- * 用户偏好设置接口
- */
-export interface UserPreferences {
-  // 全局偏好
-  defaultTheme: WidgetTheme;
-  defaultSize: WidgetSize;
-  
-  // 同步设置
-  syncWithMainApp: boolean;
-  syncThemeColor: boolean;
-  
-  // 性能设置
-  enableCache: boolean;
-  cacheExpiry: number;
-  
-  // 隐私设置
-  showSongInfo: boolean;
-  showArtistInfo: boolean;
-  showAlbumCover: boolean;
-}
-
-/**
- * 卡片配置管理器
- * 负责卡片个性化设置和用户偏好管理
- * 需求: 5.4, 6.3
- */
-export class WidgetConfigManager {
-  private static instance: WidgetConfigManager;
-  private preferencesStore: preferences.Preferences | null = null;
-  private configCache: Map<string, WidgetPersonalConfig> = new Map();
-  private userPreferences: UserPreferences | null = null;
-
-  /**
-   * 获取单例实例
-   */
-  public static getInstance(): WidgetConfigManager {
-    if (!WidgetConfigManager.instance) {
-      WidgetConfigManager.instance = new WidgetConfigManager();
-    }
-    return WidgetConfigManager.instance;
-  }
-
-  private constructor() {
-    this.initPreferences();
-    hilog.info(0x0000, TAG, 'WidgetConfigManager initialized');
-  }
-
-  /**
-   * 初始化配置存储
-   */
-  private async initPreferences(): Promise<void> {
-    try {
-      this.preferencesStore = await preferences.getPreferences(getContext(), CONFIG_PREFERENCES_NAME);
-      await this.loadUserPreferences();
-      hilog.info(0x0000, TAG, 'Config preferences initialized successfully');
-    } catch (error) {
-      hilog.error(0x0000, TAG, `Failed to initialize config preferences: ${error}`);
-    }
-  }
-
-  /**
-   * 获取卡片个性化配置
-   * @param formId 卡片ID
-   * @param size 卡片尺寸
-   * @returns 个性化配置
-   */
-  public async getWidgetConfig(formId: string, size: WidgetSize): Promise<WidgetPersonalConfig> {
-    // 先从缓存获取
-    const cacheKey = `${formId}_${size}`;
-    if (this.configCache.has(cacheKey)) {
-      return this.configCache.get(cacheKey)!;
-    }
-
-    try {
-      if (!this.preferencesStore) {
-        await this.initPreferences();
-      }
-
-      const configKey = `config_${formId}`;
-      const configStr = await this.preferencesStore?.get(configKey, '') as string;
-      
-      let config: WidgetPersonalConfig;
-      if (configStr) {
-        config = JSON.parse(configStr) as WidgetPersonalConfig;
-      } else {
-        config = this.getDefaultConfig(size);
-      }
-
-      // 应用主题色彩同步
-      if (this.userPreferences?.syncThemeColor) {
-        config = await this.syncThemeColors(config);
-      }
-
-      // 缓存配置
-      this.configCache.set(cacheKey, config);
-      
-      hilog.info(0x0000, TAG, `Widget config loaded for form: ${formId}`);
-      return config;
-    } catch (error) {
-      hilog.error(0x0000, TAG, `Failed to get widget config: ${error}`);
-      return this.getDefaultConfig(size);
-    }
-  }
-
-  /**
-   * 保存卡片个性化配置
-   * @param formId 卡片ID
-   * @param size 卡片尺寸
-   * @param config 配置对象
-   */
-  public async saveWidgetConfig(formId: string, size: WidgetSize, config: WidgetPersonalConfig): Promise<void> {
-    try {
-      if (!this.preferencesStore) {
-        await this.initPreferences();
-      }
-
-      const configKey = `config_${formId}`;
-      await this.preferencesStore?.put(configKey, JSON.stringify(config));
-      await this.preferencesStore?.flush();
-
-      // 更新缓存
-      const cacheKey = `${formId}_${size}`;
-      this.configCache.set(cacheKey, config);
-
-      hilog.info(0x0000, TAG, `Widget config saved for form: ${formId}`);
-    } catch (error) {
-      hilog.error(0x0000, TAG, `Failed to save widget config: ${error}`);
-    }
-  }
-
-  /**
-   * 获取用户偏好设置
-   */
-  public async getUserPreferences(): Promise<UserPreferences> {
-    if (this.userPreferences) {
-      return this.userPreferences;
-    }
-
-    await this.loadUserPreferences();
-    return this.userPreferences || this.getDefaultUserPreferences();
-  }
-
-  /**
-   * 保存用户偏好设置
-   * @param preferences 用户偏好
-   */
-  public async saveUserPreferences(preferences: UserPreferences): Promise<void> {
-    try {
-      if (!this.preferencesStore) {
-        await this.initPreferences();
-      }
-
-      await this.preferencesStore?.put('user_preferences', JSON.stringify(preferences));
-      await this.preferencesStore?.flush();
-
-      this.userPreferences = preferences;
-
-      hilog.info(0x0000, TAG, 'User preferences saved successfully');
-    } catch (error) {
-      hilog.error(0x0000, TAG, `Failed to save user preferences: ${error}`);
-    }
-  }
-
-  /**
-   * 同步主题色彩
-   * @param config 当前配置
-   * @returns 同步后的配置
-   */
-  public async syncThemeColors(config: WidgetPersonalConfig): Promise<WidgetPersonalConfig> {
-    try {
-      // 从主应用获取主题色彩
-      const mainAppTheme = await this.getMainAppTheme();
-      
-      if (mainAppTheme) {
-        const updatedConfig = ObjectUtils.cloneWidgetConfig(config);
-        updatedConfig.theme = mainAppTheme.theme;
-        updatedConfig.backgroundColor = mainAppTheme.backgroundColor;
-        updatedConfig.textColor = mainAppTheme.textColor;
-        updatedConfig.accentColor = mainAppTheme.accentColor;
-        return updatedConfig;
-      }
-    } catch (error) {
-      hilog.error(0x0000, TAG, `Failed to sync theme colors: ${error}`);
-    }
-
-    return config;
-  }
-
-  /**
-   * 重置卡片配置为默认值
-   * @param formId 卡片ID
-   * @param size 卡片尺寸
-   */
-  public async resetWidgetConfig(formId: string, size: WidgetSize): Promise<void> {
-    const defaultConfig = this.getDefaultConfig(size);
-    await this.saveWidgetConfig(formId, size, defaultConfig);
-    
-    hilog.info(0x0000, TAG, `Widget config reset to default for form: ${formId}`);
-  }
-
-  /**
-   * 批量更新所有卡片配置
-   * @param updateFn 更新函数
-   */
-  public async updateAllWidgetConfigs(updateFn: (config: WidgetPersonalConfig) => WidgetPersonalConfig): Promise<void> {
-    try {
-      if (!this.preferencesStore) {
-        await this.initPreferences();
-      }
-
-      const allKeys = await this.preferencesStore?.getAll();
-      const allKeysRecord: Record<string, Object> = allKeys as Record<string, Object> || {};
-      const configKeys = Object.keys(allKeysRecord).filter(key => key.startsWith('config_'));
-
-      for (let i = 0; i < configKeys.length; i++) {
-        const key = configKeys[i];
-        const configStr = allKeysRecord[key] as string;
-        if (configStr) {
-          const config = JSON.parse(configStr) as WidgetPersonalConfig;
-          const updatedConfig = updateFn(config);
-          await this.preferencesStore?.put(key, JSON.stringify(updatedConfig));
-        }
-      }
-
-      await this.preferencesStore?.flush();
-      
-      // 清除缓存以强制重新加载
-      this.configCache.clear();
-
-      hilog.info(0x0000, TAG, `Updated ${configKeys.length} widget configs`);
-    } catch (error) {
-      hilog.error(0x0000, TAG, `Failed to update all widget configs: ${error}`);
-    }
-  }
-
-  /**
-   * 删除卡片配置
-   * @param formId 卡片ID
-   */
-  public async removeWidgetConfig(formId: string): Promise<void> {
-    try {
-      if (!this.preferencesStore) {
-        await this.initPreferences();
-      }
-
-      const configKey = `config_${formId}`;
-      await this.preferencesStore?.delete(configKey);
-      await this.preferencesStore?.flush();
-
-      // 清除相关缓存
-      const keysToRemove: string[] = [];
-      const cacheKeys = Array.from(this.configCache.keys());
-      for (let i = 0; i < cacheKeys.length; i++) {
-        const key = cacheKeys[i];
-        if (key.startsWith(formId)) {
-          keysToRemove.push(key);
-        }
-      }
-      for (let i = 0; i < keysToRemove.length; i++) {
-        this.configCache.delete(keysToRemove[i]);
-      }
-
-      hilog.info(0x0000, TAG, `Widget config removed for form: ${formId}`);
-    } catch (error) {
-      hilog.error(0x0000, TAG, `Failed to remove widget config: ${error}`);
-    }
-  }
-
-  /**
-   * 获取默认配置
-   */
-  private getDefaultConfig(size: WidgetSize): WidgetPersonalConfig {
-    const baseConfig: WidgetPersonalConfig = {
-      // 显示配置
-      showProgress: true,
-      showCover: true,
-      showAlbum: true,
-      showTime: true,
-      
-      // 主题配置
-      theme: WidgetTheme.AUTO,
-      backgroundColor: '#FFFFFF',
-      textColor: '#E6000000',
-      accentColor: '#FF007DFF',
-      
-      // 布局配置
-      buttonSize: 'medium',
-      fontSize: 'medium',
-      borderRadius: 12,
-      
-      // 行为配置
-      autoUpdate: true,
-      updateInterval: 1000,
-      clickBehavior: 'play_pause',
-      
-      // 高级配置
-      enableAnimations: true,
-      enableHapticFeedback: true,
-      enableShadow: true
-    };
-
-    // 根据尺寸调整默认配置
-    if (size === WidgetSize.SMALL) {
-      const smallConfig = ObjectUtils.cloneWidgetConfig(baseConfig);
-      smallConfig.showProgress = false;
-      smallConfig.showCover = false;
-      smallConfig.showAlbum = false;
-      smallConfig.showTime = false;
-      smallConfig.buttonSize = 'small';
-      smallConfig.fontSize = 'small';
-      smallConfig.borderRadius = 8;
-      return smallConfig;
-    } else if (size === WidgetSize.MEDIUM) {
-      const mediumConfig = ObjectUtils.cloneWidgetConfig(baseConfig);
-      mediumConfig.showCover = false;
-      mediumConfig.buttonSize = 'medium';
-      mediumConfig.fontSize = 'medium';
-      mediumConfig.borderRadius = 12;
-      return mediumConfig;
-    } else if (size === WidgetSize.LARGE) {
-      const largeConfig = ObjectUtils.cloneWidgetConfig(baseConfig);
-      largeConfig.buttonSize = 'large';
-      largeConfig.fontSize = 'large';
-      largeConfig.borderRadius = 16;
-      return largeConfig;
-    } else {
-      return baseConfig;
-    }
-  }
-
-  /**
-   * 获取默认用户偏好
-   */
-  private getDefaultUserPreferences(): UserPreferences {
-    return {
-      // 全局偏好
-      defaultTheme: WidgetTheme.AUTO,
-      defaultSize: WidgetSize.MEDIUM,
-      
-      // 同步设置
-      syncWithMainApp: true,
-      syncThemeColor: true,
-      
-      // 性能设置
-      enableCache: true,
-      cacheExpiry: 30000,
-      
-      // 隐私设置
-      showSongInfo: true,
-      showArtistInfo: true,
-      showAlbumCover: true
-    };
-  }
-
-  /**
-   * 加载用户偏好设置
-   */
-  private async loadUserPreferences(): Promise<void> {
-    try {
-      if (!this.preferencesStore) {
-        return;
-      }
-
-      const prefsStr = await this.preferencesStore.get('user_preferences', '') as string;
-      if (prefsStr) {
-        this.userPreferences = JSON.parse(prefsStr) as UserPreferences;
-      } else {
-        this.userPreferences = this.getDefaultUserPreferences();
-      }
-    } catch (error) {
-      hilog.error(0x0000, TAG, `Failed to load user preferences: ${error}`);
-      this.userPreferences = this.getDefaultUserPreferences();
-    }
-  }
-
-  /**
-   * 从主应用获取主题信息
-   */
-  private async getMainAppTheme(): Promise<MainAppTheme | null> {
-    try {
-      // 这里应该从主应用的主题管理器获取主题信息
-      // 暂时返回默认主题
-      return {
-        theme: WidgetTheme.AUTO,
-        backgroundColor: '#FFFFFF',
-        textColor: '#E6000000',
-        accentColor: '#FF007DFF'
-      };
-    } catch (error) {
-      hilog.error(0x0000, TAG, `Failed to get main app theme: ${error}`);
-      return null;
-    }
-  }
-}
-
-/**
- * 主应用主题接口
- */
-interface MainAppTheme {
-  theme: WidgetTheme;
-  backgroundColor: string;
-  textColor: string;
-  accentColor: string;
-}

+ 0 - 228
entry/src/main/ets/common/widget/WidgetController.ets

@@ -1,228 +0,0 @@
-import { WidgetActionData } from './WidgetTypes';
-import { 
-  PLAY_PAUSE_EVENT, 
-  NEXT_SONG_EVENT, 
-  PREV_SONG_EVENT, 
-  SEEK_TO_EVENT, 
-  OPEN_APP_EVENT, 
-  OPEN_PLAYER_EVENT,
-  LONG_PRESS_MENU_EVENT,
-  WIDGET_SETTINGS_EVENT,
-  WIDGET_DELETE_EVENT,
-  WIDGET_CONFIG_PAGE_EVENT
-} from './WidgetEventConstants';
-
-/**
- * 简化的卡片事件发送函数
- */
-function postCardAction(context: Object, data: WidgetActionData): void {
-  try {
-    const message: string = JSON.stringify(data);
-    console.info(`Posting card action: ${message}`);//Posting card action: {"action":"play_pause","params":{}}
-    
-    const globalObj: ESObject = globalThis as ESObject;
-    if (globalObj.postCardAction && typeof globalObj.postCardAction === 'function') {
-      globalObj.postCardAction(context, message);
-      console.info(`Card action posted successfully`);
-    } else {
-      console.error(`Global postCardAction function not found`);
-    }
-  } catch (error) {
-    console.error(`Failed to post card action: ${error}`);
-  }
-}
-
-/**
- * 卡片控制器
- * 统一管理卡片的点击行为和交互逻辑
- */
-export class WidgetController {
-  
-  /**
-   * 处理播放/暂停按钮点击
-   */
-  static handlePlayPause(context: Object): void {
-    console.info('Play/Pause button clicked');
-    
-    const actionData: WidgetActionData = {
-      action: PLAY_PAUSE_EVENT,
-      params: new Object()
-    };
-    
-    postCardAction(context, actionData);
-  }
-
-  /**
-   * 处理下一首按钮点击
-   */
-  static handleNextSong(context: Object): void {
-    console.info('Next song button clicked');
-    
-    const actionData: WidgetActionData = {
-      action: NEXT_SONG_EVENT,
-      params: new Object()
-    };
-    
-    postCardAction(context, actionData);
-  }
-
-  /**
-   * 处理上一首按钮点击
-   */
-  static handlePrevSong(context: Object): void {
-    console.info('Previous song button clicked');
-    
-    const actionData: WidgetActionData = {
-      action: PREV_SONG_EVENT,
-      params: new Object()
-    };
-    
-    postCardAction(context, actionData);
-  }
-
-  /**
-   * 处理进度条点击
-   */
-  static handleSeekTo(context: Object, percentage: number): void {
-    console.info(`Seek to ${percentage}%`);
-    
-    const params: Object = new Object();
-    (params as ESObject)['percentage'] = percentage;
-    
-    const actionData: WidgetActionData = {
-      action: SEEK_TO_EVENT,
-      params: params
-    };
-    
-    postCardAction(context, actionData);
-  }
-
-  /**
-   * 处理打开应用点击
-   */
-  static handleOpenApp(context: Object): void {
-    console.info('Open app clicked');
-    
-    const actionData: WidgetActionData = {
-      action: OPEN_APP_EVENT,
-      params: new Object()
-    };
-    
-    postCardAction(context, actionData);
-  }
-
-  /**
-   * 处理打开播放器页面点击
-   */
-  static handleOpenPlayer(context: Object): void {
-    console.info('Heanup Open player clicked');
-    
-    const actionData: WidgetActionData = {
-      action: OPEN_PLAYER_EVENT,
-      params: new Object()
-    };
-    
-    postCardAction(context, actionData);
-  }
-
-  /**
-   * 处理进度条点击事件
-   */
-  static handleProgressClick(context: Object, event: ClickEvent): void {
-    try {
-      const clickX: number = event.x;
-      const progressWidth: number = event.target.area.width as number;
-      
-      if (progressWidth > 0) {
-        const percentage: number = Math.max(0, Math.min(100, (clickX / progressWidth) * 100));
-        WidgetController.handleSeekTo(context, percentage);
-      }
-    } catch (error) {
-      console.error(`Failed to handle progress click: ${error}`);
-    }
-  }
-
-  /**
-   * 检查按钮是否可用
-   */
-  static isButtonEnabled(hasNext: boolean, hasPrevious: boolean, buttonType: 'next' | 'prev'): boolean {
-    switch (buttonType) {
-      case 'next':
-        return hasNext;
-      case 'prev':
-        return hasPrevious;
-      default:
-        return true;
-    }
-  }
-
-  /**
-   * 获取按钮颜色
-   */
-  static getButtonColor(enabled: boolean): string {
-    return enabled ? '#FF007DFF' : '#66000000';
-  }
-
-  /**
-   * 获取播放按钮图标
-   */
-  static getPlayButtonIcon(isPlaying: boolean): Resource {
-    return isPlaying ? $r('app.media.hm_pause') : $r('app.media.hm_play');
-  }
-
-  /**
-   * 处理长按菜单显示
-   */
-  static handleLongPressMenu(context: Object): void {
-    console.info('Long press menu triggered');
-    
-    const actionData: WidgetActionData = {
-      action: LONG_PRESS_MENU_EVENT,
-      params: new Object()
-    };
-    
-    postCardAction(context, actionData);
-  }
-
-  /**
-   * 处理卡片设置点击
-   */
-  static handleWidgetSettings(context: Object): void {
-    console.info('Widget settings clicked');
-    
-    const actionData: WidgetActionData = {
-      action: WIDGET_SETTINGS_EVENT,
-      params: new Object()
-    };
-    
-    postCardAction(context, actionData);
-  }
-
-  /**
-   * 处理卡片删除点击
-   */
-  static handleWidgetDelete(context: Object): void {
-    console.info('Widget delete clicked');
-    
-    const actionData: WidgetActionData = {
-      action: WIDGET_DELETE_EVENT,
-      params: new Object()
-    };
-    
-    postCardAction(context, actionData);
-  }
-
-  /**
-   * 处理卡片配置界面跳转
-   */
-  static handleWidgetConfigPage(context: Object): void {
-    console.info('Widget config page clicked');
-    
-    const actionData: WidgetActionData = {
-      action: WIDGET_CONFIG_PAGE_EVENT,
-      params: new Object()
-    };
-    
-    postCardAction(context, actionData);
-  }
-}

+ 0 - 93
entry/src/main/ets/common/widget/WidgetDebugConfig.ets

@@ -1,93 +0,0 @@
-/**
- * 卡片调试配置
- * 用于控制日志输出和调试功能
- */
-
-export const WidgetDebugConfig = {
-  // 是否启用详细日志
-  enableVerboseLogging: true,
-  
-  // 是否启用数据流测试
-  enableDataFlowTest: true,
-  
-  // 是否启用跨进程通信调试
-  enableCrossProcessDebug: true,
-  
-  // 是否启用监听器调试
-  enableListenerDebug: true,
-  
-  // 是否启用性能监控
-  enablePerformanceMonitoring: true,
-  
-  // 日志标签前缀
-  logTagPrefix: 'TTMusic-Widget',
-  
-  // 测试延迟时间(毫秒)
-  testDelays: {
-    initialUpdate: 500,
-    retryUpdate: 2000,
-    finalUpdate: 5000,
-    dataFlowTest: 3000
-  },
-  
-  // 错误重试次数
-  maxRetryCount: 3,
-  
-  // 缓存配置
-  cache: {
-    enabled: true,
-    expiryTime: 30000, // 30秒
-    maxSize: 100
-  }
-};
-
-/**
- * 调试日志工具
- */
-export class WidgetLogger {
-  private static logTagPrefix = WidgetDebugConfig.logTagPrefix;
-  
-  static info(tag: string, message: string): void {
-    if (WidgetDebugConfig.enableVerboseLogging) {
-      console.info(`[${this.logTagPrefix}-${tag}] ${message}`);
-    }
-  }
-  
-  static warn(tag: string, message: string): void {
-    console.warn(`[${this.logTagPrefix}-${tag}] ⚠️ ${message}`);
-  }
-  
-  static error(tag: string, message: string): void {
-    console.error(`[${this.logTagPrefix}-${tag}] ❌ ${message}`);
-  }
-  
-  static debug(tag: string, message: string): void {
-    if (WidgetDebugConfig.enableVerboseLogging) {
-      console.debug(`[${this.logTagPrefix}-${tag}] 🐛 ${message}`);
-    }
-  }
-  
-  static dataFlow(tag: string, message: string): void {
-    if (WidgetDebugConfig.enableDataFlowTest) {
-      console.info(`[${this.logTagPrefix}-DataFlow-${tag}] 🔄 ${message}`);
-    }
-  }
-  
-  static crossProcess(tag: string, message: string): void {
-    if (WidgetDebugConfig.enableCrossProcessDebug) {
-      console.info(`[${this.logTagPrefix}-CrossProcess-${tag}] 🌐 ${message}`);
-    }
-  }
-  
-  static listener(tag: string, message: string): void {
-    if (WidgetDebugConfig.enableListenerDebug) {
-      console.info(`[${this.logTagPrefix}-Listener-${tag}] 👂 ${message}`);
-    }
-  }
-  
-  static performance(tag: string, message: string): void {
-    if (WidgetDebugConfig.enablePerformanceMonitoring) {
-      console.info(`[${this.logTagPrefix}-Perf-${tag}] ⚡ ${message}`);
-    }
-  }
-}

+ 0 - 62
entry/src/main/ets/common/widget/WidgetIconManager.ets

@@ -1,62 +0,0 @@
-/**
- * 卡片图标资源管理器
- * 用于统一管理和验证卡片中使用的图标资源
- */
-
-export class WidgetIconManager {
-  
-  /**
-   * 获取播放按钮图标
-   */
-  static getPlayIcon(): Resource {
-    return $r('app.media.hm_play');
-  }
-  
-  /**
-   * 获取暂停按钮图标
-   */
-  static getPauseIcon(): Resource {
-    return $r('app.media.hm_pause');
-  }
-  
-  /**
-   * 获取上一首按钮图标
-   */
-  static getPreviousIcon(): Resource {
-    return $r('app.media.ic_previous');
-  }
-  
-  /**
-   * 获取下一首按钮图标
-   */
-  static getNextIcon(): Resource {
-    return $r('app.media.ic_next');
-  }
-  
-  /**
-   * 获取加载图标
-   */
-  static getLoadingIcon(): Resource {
-    return $r('app.media.icon_load');
-  }
-  
-  /**
-   * 获取默认专辑封面
-   */
-  static getDefaultCover(): Resource {
-    return $r('app.media.bg_music');
-  }
-  
-  /**
-   * 验证图标资源是否可用
-   */
-  static validateIcons(): boolean {
-    try {
-      // 这里可以添加图标验证逻辑
-      return true;
-    } catch (error) {
-      console.error('Widget icon validation failed:', error);
-      return false;
-    }
-  }
-}

+ 0 - 1
entry/src/main/ets/common/widget/WidgetTypeHelpers.ets

@@ -1,4 +1,3 @@
-import { WidgetPersonalConfig, UserPreferences } from './WidgetConfigManager';
 import { WidgetData, PlayState, SongInfo, PlayProgress, PlaylistState, WidgetConfig } from './WidgetTypes';
 
 /**

+ 2 - 0
entry/src/main/ets/common/widget/WidgetTypes.ets

@@ -184,6 +184,8 @@ export interface FormattedWidgetData {
   // 新增字段用于支持网络图片
   imgName?: string;  // 图片文件名,用于memory://协议
   formImages?: Record<string, number>;  // 图片文件描述符映射
+  // 新增字段用于支持封面颜色
+  imageColorHex?: string;  // 从封面图片提取的主要颜色
 }
 
 /**

+ 43 - 157
entry/src/main/ets/entryformability/EntryFormAbility.ets

@@ -12,14 +12,6 @@ import { WidgetCommand, WidgetControlParams, WidgetData, WidgetSize, FormattedWi
 import { FormLayoutManager } from '../common/widget/FormLayoutManager';
 import { GlobalWidgetManager } from '../common/widget/GlobalWidgetManager';
 import { WidgetSizeAdapter, SizeChangeListener } from '../common/widget/WidgetSizeAdapter';
-import { WidgetConfigManager, UserPreferences } from '../common/widget/WidgetConfigManager';
-import { ThemeSyncService, ThemeChangeListener, ThemeChangeEvent, ThemeInfo } from '../common/widget/ThemeSyncService';
-import {
-  UserPreferencesService,
-  PreferencesChangeListener,
-  PreferencesChangeEvent
-} from '../common/widget/UserPreferencesService';
-import { ObjectUtils } from '../common/widget/ObjectUtils';
 import {
   PLAY_PAUSE_EVENT,
   NEXT_SONG_EVENT,
@@ -43,7 +35,6 @@ const TAG = 'Heanup';
 interface WidgetSettingsParams extends Record<string, Object> {
   formId: string;
   currentSize: string;
-  currentConfig: string;
 }
 
 /**
@@ -52,7 +43,6 @@ interface WidgetSettingsParams extends Record<string, Object> {
 interface WidgetConfigParams extends Record<string, Object> {
   formId: string;
   configType: string;
-  configValue: string;
 }
 
 /**
@@ -94,27 +84,24 @@ function copyWidgetData(target: ExtendedWidgetData, overrides: Partial<ExtendedW
  * 支持多尺寸适配和UI重构
  */
 export default class EntryFormAbility extends FormExtensionAbility
-implements SizeChangeListener, ThemeChangeListener, PreferencesChangeListener {
+implements SizeChangeListener {
   private widgetDataManager: WidgetDataManager | null = null;
   private playerControlService: PlayerControlService = new PlayerControlService();
   private layoutManager: FormLayoutManager = FormLayoutManager.getInstance();
   private sizeAdapter: WidgetSizeAdapter = WidgetSizeAdapter.getInstance();
-  private configManager: WidgetConfigManager = WidgetConfigManager.getInstance();
-  private themeSyncService: ThemeSyncService = ThemeSyncService.getInstance();
-  private userPreferencesService: UserPreferencesService = UserPreferencesService.getInstance();
   private globalWidgetManager: GlobalWidgetManager = GlobalWidgetManager.getInstance();
-  
+
   // 使用实例变量而不是静态变量,确保每个进程都能正确设置监听器
   private globalListenerSetup: boolean = false;
-  
+
   // 防抖机制:避免短时间内重复更新
   private lastUpdateTime: number = 0;
   private updateDebounceDelay: number = 100; // 100ms防抖延迟
-  
+
   // 进程启动时间,用于检测进程重启
   private processStartTime: number = Date.now();
   private lastHealthCheck: number = 0;
-  
+
   // 图片下载缓存
   private downloadingImages: Map<string, Promise<string | null>> = new Map();
   private imageCache: Map<string, string> = new Map(); // url -> fileName映射
@@ -124,12 +111,12 @@ implements SizeChangeListener, ThemeChangeListener, PreferencesChangeListener {
    */
   private initializeServices(): void {
     hilog.info(0x0000, TAG, 'Heanup EntryFormAbility initializeServices called');
-    
+
     if (!this.widgetDataManager) {
       this.widgetDataManager = new WidgetDataManager();
       hilog.info(0x0000, TAG, 'Heanup EntryFormAbility WidgetDataManager initialized');
     }
-    
+
     // 设置全局状态监听器(每个进程实例设置一次)
     hilog.info(0x0000, TAG, `Heanup EntryFormAbility checking global listener setup: ${this.globalListenerSetup}`);
     if (!this.globalListenerSetup) {
@@ -153,17 +140,17 @@ implements SizeChangeListener, ThemeChangeListener, PreferencesChangeListener {
       avSessionListener.addStateListener((data: WidgetData) => {
         const now = Date.now();
         hilog.info(0x0000, TAG, `Heanup EntryFormAbility [Process:${this.processStartTime}] global listener received state update: isPlaying=${data.playState.isPlaying}, title=${data.currentSong.title}, age=${now - this.processStartTime}ms`);
-        
+
         // 更新健康检查时间
         this.lastHealthCheck = now;
-        
+
         // 总是尝试更新,让updateAllWidgetsWithData自己检查
         this.updateAllWidgetsWithData(data);
       });
-      
+
       // 启动健康检查定时器
       this.startHealthCheck();
-      
+
       hilog.info(0x0000, TAG, `Heanup EntryFormAbility [Process:${this.processStartTime}] global state listener setup successfully`);
     } catch (error) {
       hilog.error(0x0000, TAG, `Heanup EntryFormAbility [Process:${this.processStartTime}] failed to setup global listener: ${error}`);
@@ -177,11 +164,11 @@ implements SizeChangeListener, ThemeChangeListener, PreferencesChangeListener {
     setInterval(() => {
       const now = Date.now();
       const timeSinceLastUpdate = now - this.lastHealthCheck;
-      
+
       // 如果超过30秒没有收到任何状态更新,可能监听器失效了
       if (timeSinceLastUpdate > 30000) {
         hilog.warn(0x0000, TAG, `Heanup EntryFormAbility [Process:${this.processStartTime}] health check failed: ${timeSinceLastUpdate}ms since last update`);
-        
+
         // 尝试强制重连和重新请求当前状态
         this.playerControlService.forceReconnect().then(() => {
           return this.playerControlService.getCurrentPlayState();
@@ -202,7 +189,7 @@ implements SizeChangeListener, ThemeChangeListener, PreferencesChangeListener {
    */
   private updateAllWidgetsWithData(data: WidgetData): void {
     hilog.info(0x0000, TAG, `Heanup EntryFormAbility updateAllWidgetsWithData called with isPlaying=${data.playState.isPlaying}, title=${data.currentSong.title}`);
-    
+
     // 防抖机制:避免短时间内重复更新
     const now = Date.now();
     if (now - this.lastUpdateTime < this.updateDebounceDelay) {
@@ -210,27 +197,27 @@ implements SizeChangeListener, ThemeChangeListener, PreferencesChangeListener {
       return;
     }
     this.lastUpdateTime = now;
-    
+
     const activeWidgets = this.globalWidgetManager.getActiveWidgets();
     hilog.info(0x0000, TAG, `Heanup EntryFormAbility active widgets count: ${activeWidgets.size}`);
-    
+
     // 打印所有活跃的widget ID
     if (activeWidgets.size > 0) {
       activeWidgets.forEach((size: WidgetSize, formId: string) => {
         hilog.info(0x0000, TAG, `Heanup EntryFormAbility found active widget: ${formId}, size: ${size}`);
       });
     }
-    
+
     if (activeWidgets.size === 0) {
       hilog.warn(0x0000, TAG, 'Heanup EntryFormAbility no widgets to update in this process, skipping');
       return;
     }
-    
+
     activeWidgets.forEach((size: WidgetSize, formId: string) => {
       hilog.info(0x0000, TAG, `Heanup EntryFormAbility updating widget: ${formId}`);
       this.updateSingleWidget(formId, size, data);
     });
-    
+
     hilog.info(0x0000, TAG, `Heanup EntryFormAbility batch update completed for ${activeWidgets.size} widgets`);
   }
 
@@ -241,7 +228,7 @@ implements SizeChangeListener, ThemeChangeListener, PreferencesChangeListener {
     try {
       // 根据卡片尺寸适配数据
       const formattedData = this.layoutManager.adaptDataForSize(data, size);
-      
+
       // 转换为ExtendedWidgetData
       const adaptedData: ExtendedWidgetData = {
         isPlaying: formattedData.isPlaying,
@@ -263,9 +250,9 @@ implements SizeChangeListener, ThemeChangeListener, PreferencesChangeListener {
         imgName: formattedData.imgName,
         formImages: formattedData.formImages
       };
-      
+
       hilog.info(0x0000, TAG, `Heanup widget ${formId} calling formProvider.updateForm with isPlaying=${adaptedData.isPlaying}, hasNext=${adaptedData.hasNext}, hasPrevious=${adaptedData.hasPrevious}, coverImage=${adaptedData.coverImage || 'empty'}`);
-      
+
       // 检查是否有网络图片需要下载
       if (adaptedData.coverImage && this.isNetworkUrl(adaptedData.coverImage)) {
         this.updateWidgetWithNetworkImage(formId, adaptedData, retryCount);
@@ -275,7 +262,7 @@ implements SizeChangeListener, ThemeChangeListener, PreferencesChangeListener {
       }
     } catch (error) {
       hilog.error(0x0000, TAG, `Heanup widget ${formId} process error: ${error}`);
-      
+
       // 如果是处理错误,也尝试重试
       if (retryCount < 2) {
         setTimeout(() => {
@@ -294,7 +281,7 @@ implements SizeChangeListener, ThemeChangeListener, PreferencesChangeListener {
       hilog.info(0x0000, TAG, `Heanup widget ${formId} updated successfully: isPlaying=${adaptedData.isPlaying}, title=${adaptedData.songTitle}, hasNext=${adaptedData.hasNext}, hasPrevious=${adaptedData.hasPrevious}`);
     }).catch(() => {
       hilog.error(0x0000, TAG, `Heanup widget ${formId} update failed, retry count: ${retryCount}`);
-      
+
       // 重试机制:最多重试2次
       if (retryCount < 2) {
         setTimeout(() => {
@@ -311,28 +298,28 @@ implements SizeChangeListener, ThemeChangeListener, PreferencesChangeListener {
     try {
       const imageUrl: string = adaptedData.coverImage;
       hilog.info(0x0000, TAG, `Heanup widget ${formId} downloading network image: ${imageUrl}`);
-      
+
       // 先用无图片的数据快速更新一次
       const dataWithoutImage: ExtendedWidgetData = copyWidgetData(adaptedData, { coverImage: '' });
       this.updateWidgetDirectly(formId, dataWithoutImage, 0);
-      
+
       // 下载图片
       const fileName = await this.downloadNetworkImage(imageUrl);
-      
+
       if (fileName) {
         // 准备包含图片的数据
         const imageMap: Record<string, number> = {};
         imageMap[fileName] = await this.getImageFileDescriptor(fileName);
-        
+
         const dataWithImage: ExtendedWidgetData = copyWidgetData(adaptedData, {
           coverImage: '',  // 清空URL
           imgName: fileName,  // 设置图片名称用于memory://协议
           formImages: imageMap
         });
-        
+
         const formDataWithImage = formBindingData.createFormBindingData(dataWithImage);
         await formProvider.updateForm(formId, formDataWithImage);
-        
+
         hilog.info(0x0000, TAG, `Heanup widget ${formId} updated with network image: ${fileName}`);
       } else {
         hilog.warn(0x0000, TAG, `Heanup widget ${formId} failed to download image, using default`);
@@ -341,7 +328,7 @@ implements SizeChangeListener, ThemeChangeListener, PreferencesChangeListener {
       }
     } catch (error) {
       hilog.error(0x0000, TAG, `Heanup widget ${formId} network image update error: ${error}`);
-      
+
       // 失败后回退到无图片模式
       const dataWithoutImage: ExtendedWidgetData = copyWidgetData(adaptedData, { coverImage: '' });
       this.updateWidgetDirectly(formId, dataWithoutImage, retryCount);
@@ -366,7 +353,7 @@ implements SizeChangeListener, ThemeChangeListener, PreferencesChangeListener {
         hilog.info(0x0000, TAG, `Using cached image: ${fileName} for ${imageUrl}`);
         return fileName;
       }
-      
+
       // 检查是否正在下载
       if (this.downloadingImages.has(imageUrl)) {
         hilog.info(0x0000, TAG, `Image already downloading, waiting: ${imageUrl}`);
@@ -375,20 +362,20 @@ implements SizeChangeListener, ThemeChangeListener, PreferencesChangeListener {
           return await existingPromise;
         }
       }
-      
+
       // 开始下载
       const downloadPromise = this.performImageDownload(imageUrl);
       this.downloadingImages.set(imageUrl, downloadPromise);
-      
+
       const fileName = await downloadPromise;
-      
+
       // 清理下载状态
       this.downloadingImages.delete(imageUrl);
-      
+
       if (fileName) {
         this.imageCache.set(imageUrl, fileName);
       }
-      
+
       return fileName;
     } catch (error) {
       hilog.error(0x0000, TAG, `Failed to download image ${imageUrl}: ${error}`);
@@ -404,7 +391,7 @@ implements SizeChangeListener, ThemeChangeListener, PreferencesChangeListener {
     try {
       // 创建HTTP请求
       const httpRequest = http.createHttp();
-      
+
       // 设置超时时间为3秒,适合卡片的快速响应需求
       const response = await httpRequest.request(imageUrl, {
         method: http.RequestMethod.GET,
@@ -412,13 +399,13 @@ implements SizeChangeListener, ThemeChangeListener, PreferencesChangeListener {
         connectTimeout: 3000,
         readTimeout: 3000
       });
-      
+
       if (response.responseCode === http.ResponseCode.OK && response.result) {
         // 生成文件名
         const fileName = 'cover_' + Date.now() + '_' + Math.random().toString(36).substr(2, 5);
         const tempDir = this.context.getApplicationContext().tempDir;
         const filePath = tempDir + '/' + fileName;
-        
+
         // 保存文件
         const file = fileIo.openSync(filePath, fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.CREATE);
         await fileIo.write(file.fd, response.result as ArrayBuffer);
@@ -491,8 +478,6 @@ implements SizeChangeListener, ThemeChangeListener, PreferencesChangeListener {
 
     // 注册各种监听器
     this.sizeAdapter.registerSizeChangeListener(formId, this);
-    this.themeSyncService.addThemeChangeListener(this);
-    this.userPreferencesService.addPreferencesChangeListener(this);
 
     // 初始化卡片数据
     this.initializeWidget(formId, widgetSize);
@@ -588,15 +573,12 @@ implements SizeChangeListener, ThemeChangeListener, PreferencesChangeListener {
 
     // 注销各种监听器
     this.sizeAdapter.unregisterSizeChangeListener(formId);
-    this.themeSyncService.removeThemeChangeListener(this);
-    this.userPreferencesService.removePreferencesChangeListener(this);
 
     // 从全局管理器中注销卡片
     this.globalWidgetManager.unregisterWidget(formId);
 
     // 清理卡片相关数据和配置
     this.widgetDataManager?.removeWidgetData(formId);
-    this.configManager.removeWidgetConfig(formId);
   }
 
   /**
@@ -663,9 +645,6 @@ implements SizeChangeListener, ThemeChangeListener, PreferencesChangeListener {
   onConfigurationUpdate(newConfig: Object): void {
     hilog.info(0x0000, TAG, 'onConfigurationUpdate called');
 
-    // 启动主题同步服务
-    this.themeSyncService.startThemeSync();
-
     // 更新所有卡片以适应新配置
     this.widgetDataManager?.updateAllWidgets();
   }
@@ -708,27 +687,8 @@ implements SizeChangeListener, ThemeChangeListener, PreferencesChangeListener {
     return 1; // READY状态
   }
 
-  /**
-   * 实现ThemeChangeListener接口
-   * 处理主题变化事件
-   */
-  onThemeChanged(event: ThemeChangeEvent): void {
-    hilog.info(0x0000, TAG, `Theme changed: ${event.themeInfo.theme}`);
-
-    // 更新所有卡片的主题
-    this.updateAllWidgetsTheme(event.themeInfo);
-  }
 
-  /**
-   * 实现PreferencesChangeListener接口
-   * 处理用户偏好设置变化事件
-   */
-  onPreferencesChanged(event: PreferencesChangeEvent): void {
-    hilog.info(0x0000, TAG, `Preferences changed: ${event.changedKeys.join(', ')}`);
 
-    // 根据变化的设置更新卡片
-    this.handlePreferencesChange(event.changedKeys, event.newPreferences);
-  }
 
   /**
    * 初始化卡片
@@ -740,14 +700,6 @@ implements SizeChangeListener, ThemeChangeListener, PreferencesChangeListener {
       // 获取当前播放状态
       const currentState = await this.playerControlService.getCurrentPlayState();
 
-      // 获取卡片个性化配置
-      const personalConfig = await this.configManager.getWidgetConfig(formId, widgetSize);
-
-      // 应用尺寸和个性化配置
-      currentState.config = ObjectUtils.assign(currentState.config);
-      currentState.config.showProgress = personalConfig.showProgress;
-      currentState.config.showCover = personalConfig.showCover;
-      currentState.config.theme = personalConfig.theme;
 
       // 适配数据到指定尺寸
       const adaptedData = this.layoutManager.adaptDataForSize(currentState, widgetSize);
@@ -907,67 +859,6 @@ implements SizeChangeListener, ThemeChangeListener, PreferencesChangeListener {
     }
   }
 
-  /**
-   * 更新所有卡片的主题
-   */
-  private async updateAllWidgetsTheme(themeInfo: ThemeInfo): Promise<void> {
-    try {
-      // 更新所有卡片配置中的主题信息
-      await this.configManager.updateAllWidgetConfigs((config) => {
-        const updatedConfig = ObjectUtils.assign(config);
-        updatedConfig.theme = themeInfo.theme;
-        updatedConfig.backgroundColor = themeInfo.backgroundColor;
-        updatedConfig.textColor = themeInfo.textColor;
-        updatedConfig.accentColor = themeInfo.accentColor;
-        return updatedConfig;
-      });
-
-      // 刷新所有卡片显示
-      await this.widgetDataManager?.updateAllWidgets();
-
-      hilog.info(0x0000, TAG, 'All widgets theme updated');
-    } catch (error) {
-      hilog.error(0x0000, TAG, `Failed to update all widgets theme: ${error}`);
-    }
-  }
-
-  /**
-   * 处理偏好设置变化
-   */
-  private async handlePreferencesChange(changedKeys: string[], newPreferences: UserPreferences): Promise<void> {
-    try {
-      // 检查是否需要重新同步主题
-      if (changedKeys.includes('syncThemeColor') && newPreferences.syncThemeColor) {
-        await this.themeSyncService.syncTheme();
-      }
-
-      // 检查是否需要更新缓存设置
-      if (changedKeys.includes('enableCache') || changedKeys.includes('cacheExpiry')) {
-        // 这里可以更新缓存相关设置
-        hilog.info(0x0000, TAG, 'Cache settings updated');
-      }
-
-      // 检查隐私设置变化
-      const privacyKeys = ['showSongInfo', 'showArtistInfo', 'showAlbumCover'];
-      const hasPrivacyChange = changedKeys.some(key => privacyKeys.includes(key));
-
-      if (hasPrivacyChange) {
-        // 更新所有卡片的显示配置
-        await this.configManager.updateAllWidgetConfigs((config) => {
-          const updatedConfig = ObjectUtils.assign(config);
-          updatedConfig.showCover = (newPreferences.showAlbumCover as boolean) && config.showCover;
-          return updatedConfig;
-        });
-
-        // 刷新所有卡片显示
-        await this.widgetDataManager?.updateAllWidgets();
-      }
-
-      hilog.info(0x0000, TAG, 'Preferences change handled successfully');
-    } catch (error) {
-      hilog.error(0x0000, TAG, `Failed to handle preferences change: ${error}`);
-    }
-  }
 
   /**
    * 处理卡片设置
@@ -978,13 +869,11 @@ implements SizeChangeListener, ThemeChangeListener, PreferencesChangeListener {
 
       // 获取当前卡片配置
       const currentSize = this.globalWidgetManager.getWidgetSize(formId) || WidgetSize.MEDIUM;
-      const currentConfig = await this.configManager.getWidgetConfig(formId, currentSize);
 
       // 启动主应用到卡片设置页面,传递卡片ID和当前配置
       const settingsParams: WidgetSettingsParams = {
         formId: formId,
-        currentSize: currentSize,
-        currentConfig: JSON.stringify(currentConfig)
+        currentSize: currentSize
       };
 
       await this.playerControlService.launchMainApp('widget_settings', settingsParams);
@@ -1005,8 +894,7 @@ implements SizeChangeListener, ThemeChangeListener, PreferencesChangeListener {
       // 显示删除确认对话框(通过主应用)
       const deleteParams: WidgetConfigParams = {
         formId: formId,
-        configType: 'delete',
-        configValue: 'confirm_delete'
+        configType: 'delete'
       };
 
       await this.playerControlService.launchMainApp('widget_delete_confirm', deleteParams);
@@ -1026,13 +914,11 @@ implements SizeChangeListener, ThemeChangeListener, PreferencesChangeListener {
 
       // 获取当前卡片信息
       const currentSize = this.globalWidgetManager.getWidgetSize(formId) || WidgetSize.MEDIUM;
-      const currentConfig = await this.configManager.getWidgetConfig(formId, currentSize);
 
       // 启动主应用到卡片配置页面
       const configParams: WidgetConfigParams = {
         formId: formId,
-        configType: 'full_config',
-        configValue: JSON.stringify(currentConfig)
+        configType: 'full_config'
       };
 
       await this.playerControlService.launchMainApp('widget_config', configParams);

+ 38 - 5
entry/src/main/ets/widget/pages/PlayerWidgetMedium.ets

@@ -5,12 +5,12 @@
  */
 
 // 定义对齐规则
-const SingerAlignRules: Record<string, Record<string, string | VerticalAlign | HorizontalAlign>> = {
+const MediumSingerAlignRules: Record<string, Record<string, string | VerticalAlign | HorizontalAlign>> = {
   'top': { 'anchor': 'musicTitle', 'align': VerticalAlign.Bottom },
   'left': { 'anchor': 'musicCover', 'align': HorizontalAlign.End }
 };
 
-const CoverAlignRules: Record<string, Record<string, string | VerticalAlign | HorizontalAlign>> = {
+const MediumCoverAlignRules: Record<string, Record<string, string | VerticalAlign | HorizontalAlign>> = {
   'left': { 'anchor': '__container__', 'align': HorizontalAlign.Start },
   'top': { 'anchor': '__container__', 'align': VerticalAlign.Top }
 };
@@ -92,6 +92,39 @@ struct PlayerWidgetMedium {
     return url.startsWith('http://') || url.startsWith('https://');
   }
 
+  /**
+   * 生成渐变色
+   * 根据主色生成更丰富的渐变效果
+   */
+  private generateGradientColors(): [string, number][] {
+    const baseColor = this.imageColorHex;
+    
+    // 解析RGB值
+    const r = parseInt(baseColor.substring(0, 2), 16);
+    const g = parseInt(baseColor.substring(2, 4), 16);
+    const b = parseInt(baseColor.substring(4, 6), 16);
+    
+    // 生成较深的颜色作为渐变起始
+    const darkerR = Math.max(0, Math.floor(r * 0.4));
+    const darkerG = Math.max(0, Math.floor(g * 0.4));
+    const darkerB = Math.max(0, Math.floor(b * 0.4));
+    
+    // 生成中等亮度的颜色
+    const midR = Math.floor(r * 0.7);
+    const midG = Math.floor(g * 0.7);
+    const midB = Math.floor(b * 0.7);
+    
+    const darkerColor = `#ff${darkerR.toString(16).padStart(2, '0')}${darkerG.toString(16).padStart(2, '0')}${darkerB.toString(16).padStart(2, '0')}`;
+    const midColor = `#ff${midR.toString(16).padStart(2, '0')}${midG.toString(16).padStart(2, '0')}${midB.toString(16).padStart(2, '0')}`;
+    const originalColor = `#ff${baseColor}`;
+    
+    return [
+      [darkerColor, 0.0],
+      [midColor, 0.5],
+      [originalColor, 1.0]
+    ];
+  }
+
   /**
    * 获取专辑封面
    */
@@ -136,7 +169,7 @@ struct PlayerWidgetMedium {
         .fontColor('#CCFFFFFF')
         .fontWeight(FontWeight.Normal)
         .maxLines(1)
-        .alignRules(SingerAlignRules)
+        .alignRules(MediumSingerAlignRules)
         .margin({ left: 16, top: 2 })
         .id('singerText')
 
@@ -155,7 +188,7 @@ struct PlayerWidgetMedium {
           .width(58)
           .borderRadius(29)
       }
-      .alignRules(CoverAlignRules)
+      .alignRules(MediumCoverAlignRules)
       .id('musicCover')
       .onClick(() => {
         console.info('Heanup PlayerWidgetMedium: Album cover clicked');
@@ -249,7 +282,7 @@ struct PlayerWidgetMedium {
     .linearGradient({
       direction: GradientDirection.Bottom,
       repeating: false,
-      colors: [[`#ff${this.imageColorHex}`, 0.0], [`#ff${this.imageColorHex}`, 0.5], [`#ff${this.imageColorHex}`, 1.0]]
+      colors: this.generateGradientColors()
     })
     .padding(12)
     .onClick(() => {

+ 0 - 1
entry/src/main/ets/widget/pages/PlayerWidgetSmall.ets

@@ -1,4 +1,3 @@
-import { WidgetController } from '../../common/widget/WidgetController';
 /**
  * 小尺寸播放器卡片 (1x2)
  * 只显示播放控制按钮:上一首、播放/暂停、下一首

+ 6 - 6
entry/src/main/ets/widget/pages/PlayerWidgetSquare.ets

@@ -1,4 +1,3 @@
-import { WidgetController } from '../../common/widget/WidgetController';
 /**
  * 方形播放器卡片 (2x2)
  * 显示专辑封面、歌曲信息和播放按钮
@@ -6,13 +5,14 @@ import { WidgetController } from '../../common/widget/WidgetController';
  * 需求: 5.1, 1.4, 1.5
  */
 
+
 // 定义对齐规则 - 参考华为官方代码
-const SingerAlignRules: Record<string, Record<string, string | VerticalAlign | HorizontalAlign>> = {
+const SquareSingerAlignRules: Record<string, Record<string, string | VerticalAlign | HorizontalAlign>> = {
   'top': { 'anchor': 'musicTitle', 'align': VerticalAlign.Bottom },
   'left': { 'anchor': 'musicCover', 'align': HorizontalAlign.End }
 };
 
-const CoverAlignRules: Record<string, Record<string, string | VerticalAlign | HorizontalAlign>> = {
+const SquareCoverAlignRules: Record<string, Record<string, string | VerticalAlign | HorizontalAlign>> = {
   'bottom': { 'anchor': '__container__', 'align': VerticalAlign.Bottom }
 };
 
@@ -102,7 +102,7 @@ struct PlayerWidgetSquare {
         .fontColor('#CCFFFFFF')
         .fontWeight(500)
         .maxLines(1)
-        .alignRules(SingerAlignRules)
+        .alignRules(SquareSingerAlignRules)
         .margin({ top: 2 })
         .id('singerText')
 
@@ -111,7 +111,7 @@ struct PlayerWidgetSquare {
         Image($r('app.media.ic_music_bg_mini'))
           .height(88)
           .width(88)
-        
+
         Button()
           .backgroundImage(this.getCoverImage())
           .backgroundImageSize(ImageSize.Cover)
@@ -119,7 +119,7 @@ struct PlayerWidgetSquare {
           .width(58)
           .borderRadius(29)
       }
-      .alignRules(CoverAlignRules)
+      .alignRules(SquareCoverAlignRules)
       .id('musicCover')
       .onClick(() => {
         console.info('Heanup PlayerWidgetSquare: Album cover clicked');