refactor🎨: (阅读代码):actions.ts增加注释

master
yetao 2 weeks ago
parent 0ab21852c4
commit ff1555e5ee

@ -1,105 +1,226 @@
// 导入 ConfigLocation 和 FileSystemConfig 类型,这些类型定义了文件系统配置的相关属性
import type { ConfigLocation, FileSystemConfig } from 'common/fileSystemConfig'; import type { ConfigLocation, FileSystemConfig } from 'common/fileSystemConfig';
/**
*
*/
export enum ActionType { export enum ActionType {
// Startscreen // Startscreen
// 打开开始屏幕的操作
OPEN_STARTSCREEN = 'OPEN_STARTSCREEN', OPEN_STARTSCREEN = 'OPEN_STARTSCREEN',
// NewConfig // NewConfig
// 打开新配置界面的操作
OPEN_NEWCONFIG = 'OPEN_NEWCONFIG', OPEN_NEWCONFIG = 'OPEN_NEWCONFIG',
// 设置新配置名称的操作
NEWCONFIG_SETNAME = 'NEWCONFIG_SETNAME', NEWCONFIG_SETNAME = 'NEWCONFIG_SETNAME',
// 设置新配置位置的操作
NEWCONFIG_SETLOCATION = 'NEWCONFIG_SETLOCATION', NEWCONFIG_SETLOCATION = 'NEWCONFIG_SETLOCATION',
// ConfigEditor // ConfigEditor
// 打开配置编辑器的操作
OPEN_CONFIGEDITOR = 'OPEN_CONFIGEDITOR', OPEN_CONFIGEDITOR = 'OPEN_CONFIGEDITOR',
// 打开配置定位器的操作
OPEN_CONFIGLOCATOR = 'OPEN_CONFIGLOCATOR', OPEN_CONFIGLOCATOR = 'OPEN_CONFIGLOCATOR',
// 在配置编辑器中设置新配置的操作
CONFIGEDITOR_SETNEWCONFIG = 'CONFIGEDITOR_SETNEWCONFIG', CONFIGEDITOR_SETNEWCONFIG = 'CONFIGEDITOR_SETNEWCONFIG',
// 在配置编辑器中设置状态消息的操作
CONFIGEDITOR_SETSTATUSMESSAGE = 'CONFIGEDITOR_SETSTATUSMESSAGE', CONFIGEDITOR_SETSTATUSMESSAGE = 'CONFIGEDITOR_SETSTATUSMESSAGE',
} }
export interface ActionTypes { export interface ActionTypes {
// Startscreen // Startscreen
// 打开开始屏幕的操作
OPEN_STARTSCREEN: IActionOpenStartscreen; OPEN_STARTSCREEN: IActionOpenStartscreen;
// NewConfig // NewConfig
// 打开新配置界面的操作
OPEN_NEWCONFIG: IActionOpenNewConfig; OPEN_NEWCONFIG: IActionOpenNewConfig;
// 设置新配置名称的操作
NEWCONFIG_SETNAME: IActionNewConfigSetName; NEWCONFIG_SETNAME: IActionNewConfigSetName;
// 设置新配置位置的操作
NEWCONFIG_SETLOCATION: IActionNewConfigSetLocation; NEWCONFIG_SETLOCATION: IActionNewConfigSetLocation;
// ConfigEditor // ConfigEditor
// 打开配置编辑器的操作
OPEN_CONFIGEDITOR: IActionOpenConfigEditor; OPEN_CONFIGEDITOR: IActionOpenConfigEditor;
// 打开配置定位器的操作
OPEN_CONFIGLOCATOR: IActionOpenConfigLocator; OPEN_CONFIGLOCATOR: IActionOpenConfigLocator;
// 在配置编辑器中设置新配置的操作
CONFIGEDITOR_SETNEWCONFIG: IActionConfigEditorSetNewConfig; CONFIGEDITOR_SETNEWCONFIG: IActionConfigEditorSetNewConfig;
// 在配置编辑器中设置状态消息的操作
CONFIGEDITOR_SETSTATUSMESSAGE: IActionConfigEditorSetStatusMessage; CONFIGEDITOR_SETSTATUSMESSAGE: IActionConfigEditorSetStatusMessage;
} }
// 定义了一个名为 `Action` 的类型别名,它表示 `ActionTypes` 接口中所有可能的操作类型
export type Action = ActionTypes[keyof ActionTypes]; export type Action = ActionTypes[keyof ActionTypes];
/**
* `IAction`
* `type`
*/
interface IAction { interface IAction {
// 操作的类型,是 ActionType 枚举的一个值
type: ActionType; type: ActionType;
} }
/* Startscreen */ /* Startscreen */
/**
* `IActionOpenStartscreen` `IAction`
* `groupBy`
*/
export interface IActionOpenStartscreen extends IAction { export interface IActionOpenStartscreen extends IAction {
// 操作的类型,是 ActionType 枚举的一个值,这里是 OPEN_STARTSCREEN
type: ActionType.OPEN_STARTSCREEN; type: ActionType.OPEN_STARTSCREEN;
// 一个可选的属性,用于指定开始屏幕的分组方式
groupBy?: string; groupBy?: string;
} }
/**
*
* @param groupBy -
* @returns IActionOpenStartscreen
*/
export function openStartScreen(groupBy?: string): IActionOpenStartscreen { export function openStartScreen(groupBy?: string): IActionOpenStartscreen {
return { type: ActionType.OPEN_STARTSCREEN, groupBy }; return { type: ActionType.OPEN_STARTSCREEN, groupBy };
} }
/* NewConfig */ /* NewConfig */
/**
* `IActionOpenNewConfig` `IAction`
* `name`
*/
export interface IActionOpenNewConfig extends IAction { export interface IActionOpenNewConfig extends IAction {
// 操作的类型,是 ActionType 枚举的一个值,这里是 OPEN_NEWCONFIG
type: ActionType.OPEN_NEWCONFIG; type: ActionType.OPEN_NEWCONFIG;
// 新配置的名称,是一个字符串
name: string; name: string;
} }
/**
*
* @param name - 'unnamed'
* @returns IActionOpenNewConfig
*/
export function openNewConfig(name = 'unnamed'): IActionOpenNewConfig { export function openNewConfig(name = 'unnamed'): IActionOpenNewConfig {
return { type: ActionType.OPEN_NEWCONFIG, name }; return { type: ActionType.OPEN_NEWCONFIG, name };
} }
/**
* `IActionNewConfigSetLocation` `IAction`
* `location`
*/
export interface IActionNewConfigSetLocation extends IAction { export interface IActionNewConfigSetLocation extends IAction {
// 操作的类型,是 ActionType 枚举的一个值,这里是 NEWCONFIG_SETLOCATION
type: ActionType.NEWCONFIG_SETLOCATION; type: ActionType.NEWCONFIG_SETLOCATION;
// 新配置的位置,是一个 ConfigLocation 对象
location: ConfigLocation; location: ConfigLocation;
} }
/**
*
* @param location -
* @returns
*/
export function newConfigSetLocation(location: ConfigLocation): IActionNewConfigSetLocation { export function newConfigSetLocation(location: ConfigLocation): IActionNewConfigSetLocation {
return { type: ActionType.NEWCONFIG_SETLOCATION, location }; return { type: ActionType.NEWCONFIG_SETLOCATION, location };
} }
/**
* `IActionNewConfigSetName` `IAction`
* `name`
*/
export interface IActionNewConfigSetName extends IAction { export interface IActionNewConfigSetName extends IAction {
// 操作的类型,是 ActionType 枚举的一个值,这里是 NEWCONFIG_SETNAME
type: ActionType.NEWCONFIG_SETNAME; type: ActionType.NEWCONFIG_SETNAME;
// 新配置的名称,是一个字符串
name: string; name: string;
} }
/**
*
* @param name -
* @returns
*/
export function newConfigSetName(name: string): IActionNewConfigSetName { export function newConfigSetName(name: string): IActionNewConfigSetName {
return { type: ActionType.NEWCONFIG_SETNAME, name }; return { type: ActionType.NEWCONFIG_SETNAME, name };
} }
/* ConfigEditor */ /* ConfigEditor */
/**
* `IActionOpenConfigEditor` `IAction`
* `config`
*/
export interface IActionOpenConfigEditor extends IAction { export interface IActionOpenConfigEditor extends IAction {
// 操作的类型,是 ActionType 枚举的一个值,这里是 OPEN_CONFIGEDITOR
type: ActionType.OPEN_CONFIGEDITOR; type: ActionType.OPEN_CONFIGEDITOR;
// 配置编辑器的配置,是一个 FileSystemConfig 对象
config: FileSystemConfig; config: FileSystemConfig;
} }
/**
*
* @param config -
* @returns
*/
export function openConfigEditor(config: FileSystemConfig): IActionOpenConfigEditor { export function openConfigEditor(config: FileSystemConfig): IActionOpenConfigEditor {
return { type: ActionType.OPEN_CONFIGEDITOR, config }; return { type: ActionType.OPEN_CONFIGEDITOR, config };
} }
/**
* `IActionOpenConfigLocator` `IAction`
* `configs` `name`
* `configs` `name`
*/
export interface IActionOpenConfigLocator extends IAction { export interface IActionOpenConfigLocator extends IAction {
// 操作的类型,是 ActionType 枚举的一个值,这里是 OPEN_CONFIGLOCATOR
type: ActionType.OPEN_CONFIGLOCATOR; type: ActionType.OPEN_CONFIGLOCATOR;
// 一个 FileSystemConfig 对象的数组,表示要在配置定位器中显示的配置
configs: FileSystemConfig[]; configs: FileSystemConfig[];
// 一个字符串,表示要在配置定位器中搜索的配置名称
name: string; name: string;
} }
/**
*
* @param configs -
* @param name -
* @returns
*/
export function openConfigLocator(configs: FileSystemConfig[], name: string): IActionOpenConfigLocator { export function openConfigLocator(configs: FileSystemConfig[], name: string): IActionOpenConfigLocator {
return { type: ActionType.OPEN_CONFIGLOCATOR, configs, name }; return { type: ActionType.OPEN_CONFIGLOCATOR, configs, name };
} }
/**
* `IActionConfigEditorSetNewConfig` `IAction`
* `config`
*/
export interface IActionConfigEditorSetNewConfig extends IAction { export interface IActionConfigEditorSetNewConfig extends IAction {
// 操作的类型,是 ActionType 枚举的一个值,这里是 CONFIGEDITOR_SETNEWCONFIG
type: ActionType.CONFIGEDITOR_SETNEWCONFIG; type: ActionType.CONFIGEDITOR_SETNEWCONFIG;
// 配置编辑器的配置,是一个 FileSystemConfig 对象
config: FileSystemConfig; config: FileSystemConfig;
} }
/**
*
* @param config -
* @returns
*/
export function configEditorSetNewConfig(config: FileSystemConfig): IActionConfigEditorSetNewConfig { export function configEditorSetNewConfig(config: FileSystemConfig): IActionConfigEditorSetNewConfig {
return { type: ActionType.CONFIGEDITOR_SETNEWCONFIG, config }; return { type: ActionType.CONFIGEDITOR_SETNEWCONFIG, config };
} }
/**
* `IActionConfigEditorSetStatusMessage` `IAction`
* `type` `message`
* `type` `message`
*/
export interface IActionConfigEditorSetStatusMessage extends IAction { export interface IActionConfigEditorSetStatusMessage extends IAction {
// 操作的类型,是 ActionType 枚举的一个值,这里是 CONFIGEDITOR_SETSTATUSMESSAGE
type: ActionType.CONFIGEDITOR_SETSTATUSMESSAGE, type: ActionType.CONFIGEDITOR_SETSTATUSMESSAGE,
// 一个可选的字符串,表示要设置的状态消息
message?: string; message?: string;
} }
/**
*
* @param message - undefined
* @returns
*/
export function configEditorSetStatusMessage(message?: string): IActionConfigEditorSetStatusMessage { export function configEditorSetStatusMessage(message?: string): IActionConfigEditorSetStatusMessage {
return { type: ActionType.CONFIGEDITOR_SETSTATUSMESSAGE, message }; return { type: ActionType.CONFIGEDITOR_SETSTATUSMESSAGE, message };
} }

Loading…
Cancel
Save