Skip to content

Commit

Permalink
feat: album
Browse files Browse the repository at this point in the history
  • Loading branch information
JiaWei committed Jul 4, 2024
1 parent af72d57 commit 83f0022
Show file tree
Hide file tree
Showing 72 changed files with 13,561 additions and 4,530 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true

[*.{js,json,yml}]
charset = utf-8
indent_style = space
indent_size = 2
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/.yarn/** linguist-vendored
/.yarn/releases/* binary
/.yarn/plugins/**/* binary
/.pnp.* binary linguist-generated
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ pnpm-lock.yaml

/wallpaper
/userData

library/build
.yarn/install-state.gz
894 changes: 894 additions & 0 deletions .yarn/releases/yarn-4.3.0.cjs

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
nodeLinker: node-modules

supportedArchitectures:
cpu:
- current
- x64
- ia32
- arm64
libc:
- current
- glibc
- musl
os:
- current
- darwin
- linux
- win32

yarnPath: .yarn/releases/yarn-4.3.0.cjs

npmRegistryServer: "https://npmreg.proxy.ustclug.org/"
20 changes: 13 additions & 7 deletions cross/consts.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
import {
MacOSScaleMode,
WallpaperType,
WebScaleMode,
WindowsScaleMode,
} from './enums';
import { MacOSScaleMode, WebScaleMode, WindowsScaleMode } from './enums';
import { Marquee } from './interface';

export const IMAGE_EXT_LIST = ['jpg', 'jpeg', 'png', 'heic', 'webp'];

export const VIDEO_EXT_LIST = ['mp4'];

export const DEFAULT_WEB_SCALE_MODE = WebScaleMode.Cover;

export const DEFAULT_NATIVE_SCALE_MODE = {
export const DEFAULT_NATIVE_SCALE_MODE: Record<string, any> = {
win32: WindowsScaleMode.Fill,
darwin: MacOSScaleMode.Auto,
};

export const DEFAULT_MARQUEE: Partial<Marquee> = {
name: '',
text: '',
textColor: '#FF0000',
backgroundColor: '#000000',
speed: 100,
fontSize: 200,
letterSpacing: 8,
};
23 changes: 17 additions & 6 deletions cross/enums.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export enum ChangeType {
export enum RuleType {
Fixed,
AutoChange,
Album,
Marquee,
}

export enum FormMode {
Expand All @@ -12,12 +13,9 @@ export enum Events {
SelectImage = 'SelectImage',
SelectVideo = 'SelectVideo',
SelectDir = 'SelectDir',
OpenPath = 'OpenPath',

ResetSchedule = 'ResetSchedule',

SaveRules = 'SaveRules',
SaveWeekdays = 'SaveWeekdays',

GetLocale = 'GetLocale',
SettingsChange = 'SettingsChange',
InitSettings = 'InitSettings',
Expand All @@ -26,22 +24,30 @@ export enum Events {

SetStaticWallpaper = 'SetStaticWallpaper',
SetLiveWallpaper = 'SetLiveWallpaper',
SetMarqueeWallpaper = 'SetMarqueeWallpaper',
SetLiveWallpaperMuted = 'SetLiveWallpaperMuted',
SetLiveWallpaperVolume = 'SetLiveWallpaperVolume',
PauseLiveWallpaper = 'PauseLiveWallpaper',
PlayLiveWallpaper = 'PlayLiveWallpaper',

SetDBItem = 'SetDBItem',
GetDBItem = 'GetDBItem',

WallpaperWinReady = 'WallpaperWinReady',
LiveWallpaperLoaded = 'LiveWallpaperLoaded',
StaticWallpaperLoaded = 'StaticWallpaperLoaded',
MarqueeWallpaperLoaded = 'MarqueeWallpaperLoaded',

GetVersion = 'GetVersion',
OpenExternal = 'OpenExternal',
IsPackaged = 'IsPackaged',

Download = 'Download',
OnDownloadUpdated = 'OnDownloadUpdated',

ToAlbumListItem = 'ToAlbumListItem',

UnregisterGlobalShortcut = 'UnregisterGlobalShortcut',
}

export enum Locale {
Expand Down Expand Up @@ -110,3 +116,8 @@ export enum WallpaperWebsiteType {
Api = 'api',
Website = 'website',
}

export enum AlbumType {
Directory,
Files,
}
84 changes: 68 additions & 16 deletions cross/interface.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ModalProps } from 'antd';
import { ColorPickerProps, ModalProps } from 'antd';
import {
ChangeType,
AlbumType,
RuleType,
FormMode,
Locale,
MacOSScaleMode,
Expand All @@ -14,6 +15,7 @@ import {
} from './enums';
import { ITranslation } from './locale/i-translation';
import type { Method } from 'axios';
import MarqueeModal from '@/pages/marquee/components/MarqueeModal';

export interface ModalFormProps<ValueType = any> {
values?: ValueType;
Expand All @@ -24,28 +26,27 @@ export interface ModalFormProps<ValueType = any> {
}

export interface BeanWithId {
id?: string;
id: string;
}

export interface Rule extends BeanWithId {
start: string;
end: string;
wallpaperType: WallpaperType;
type: ChangeType;
path: string;
type: RuleType;
paths: string[];
interval?: number;
weekdayId: Weekday['id'];
remark?: string;
isRandom?: boolean;
screenRandom?: boolean;
direction: WallpaperDirection;
column: number;
albumId: Album['id'];
marqueeId: Marquee['id'];
wallpaperType: WallpaperType;
}

export interface Weekday extends BeanWithId {
days: number[];
id?: string;
}

export interface Settings {
Expand All @@ -58,30 +59,38 @@ export interface Settings {
autoCheckUpdate: boolean;
openAtLogin: boolean;
downloadsDir: string;
pauseWhenBlur: boolean;
pausePlayShortcut: string;
}

export type TranslationFunc = (key: keyof ITranslation) => string;

export interface DBData {
export interface ConfigData {
rules: Rule[];
weekdays: Weekday[];
settings: Settings;
currentIndex: number;
websites: WallpaperWebsite[];
migrations: string[];
albums: Album[];
marquees: Marquee[];
}

export type DBTableKey = 'rules' | 'weekdays' | 'websites';
export type DBTableKey =
| 'rules'
| 'weekdays'
| 'websites'
| 'albums'
| 'marquees';

export interface IDBService {
setItem<Key extends keyof DBData>(
export interface IDBService<DataType> {
setItem<Key extends keyof DataType>(
key: Key,
data: DBData[Key],
data: DataType[Key],
): void | Promise<void>;

getItem<Key extends keyof DBData>(
getItem<Key extends keyof DataType>(
key: Key,
): DBData[Key] | Promise<DBData[Key]>;
): DataType[Key] | Promise<DataType[Key]>;
}

export interface WallpaperWebsiteRequestParam {
Expand Down Expand Up @@ -139,4 +148,47 @@ export interface StaticWallpaperEventArg {
path: string;
rule: Rule;
paths: string[];
album?: Album;
}

export interface LiveWallpaperEventArg {
paths: string[];
rule: Rule;
album?: Album;
}

export interface Marquee extends BeanWithId {
name: string;
text: string;
backgroundColor: ColorPickerProps['value'];
textColor: ColorPickerProps['value'];
fontSize: number;
speed: number;
letterSpacing: number;
}

export interface Album extends BeanWithId {
name: string;
dir: string;
paths: AlbumFileListItem[];
direction: WallpaperDirection;
wallpaperType: WallpaperType;
type: AlbumType;
column?: number;
}

export interface MarqueeEventArg {
rule: Rule;
marquee: Marquee;
}

export interface AlbumFileListItem {
path: string;
thumb: string;
}

export interface ToAlbumFileListItemParams {
files: string[];
width: number;
quality: number;
}
36 changes: 34 additions & 2 deletions cross/locale/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const en: ITranslation = {
close: 'Close',
apply: 'Apply',
sync: 'Sync',
set: 'Set',

monday: 'Mon',
tuesday: 'Tue',
Expand Down Expand Up @@ -55,7 +56,8 @@ export const en: ITranslation = {
'rule.wallpaperType.video': 'Video',
'rule.type': 'Type',
'rule.type.fixed': 'Fixed',
'rule.type.autoChange': 'Auto change',
'rule.type.autoChange': 'Album',
'rule.type.marquee': 'Marquee',
'rule.path': 'Path/Directory',
'rule.screen': 'Screen',
'rule.interval': 'Change interval(seconds)',
Expand All @@ -69,6 +71,8 @@ export const en: ITranslation = {
'rule.direction.vertical': 'Vertical',
'rule.direction.horizontal': 'Horizontal',
'rule.column': 'Column',
'rule.album': 'Album',
'rule.marquee': 'Marquee',

scaleMode: 'Scale Mode',
'scaleMode.default': 'Default',
Expand All @@ -87,9 +91,13 @@ export const en: ITranslation = {
'settings.mute': 'Mute',
'settings.volume': 'Volume',
'settings.downloadsDir': 'Download directory',
'settings.pauseWhenBlur': 'Pause live wallpaper when covered',
'settings.pausePlayShortcut': 'Shortcut of pause/play',

'menu.rules': 'Rules',
'menu.libs': 'Wallpaper libs',
'menu.libs': 'Wallpaper library',
'menu.albums': 'Albums',
'menu.marquees': 'Marquees',

'lib.wallpaperLib': 'Wallpaper lib',
'lib.name': 'Name',
Expand All @@ -116,6 +124,30 @@ export const en: ITranslation = {
'lib.tags.free': 'Free',
'lib.tags.needToLogin': 'Need to login',

album: 'Album',
'album.name': 'Name',
'album.direction': 'Direction',
'album.direction.vertical': 'Vertical',
'album.direction.horizontal': 'Horizontal',
'album.dir': 'Directory',
'album.paths': 'Files',
'album.dirOrFiles': 'Directory/Files',
'album.wallpaperType': 'Wallpaper type',
'album.wallpaperType.image': 'Image',
'album.wallpaperType.video': 'Video',
'album.type': 'Album type',
'album.type.directory': 'Folder',
'album.type.files': 'Files',

marquee: 'Marquee',
'marquee.name': 'Name',
'marquee.text': 'Text',
'marquee.backgroundColor': 'Background color',
'marquee.textColor': 'Text color',
'marquee.fontSize': 'Font size',
'marquee.letterSpacing': 'Letter spacing',
'marquee.speed': 'Speed',

downloadStarted: 'Download started',
downloadExists: 'Download exists',

Expand Down
Loading

0 comments on commit 83f0022

Please sign in to comment.