import type { OfficeContentControl } from '../onlyoffice/types';
|
|
import { acceptHMRUpdate, defineStore } from 'pinia';
|
|
export type RuntimeStatus = 'error' | 'initializing' | 'ready' | 'working';
|
|
export type OperationState = { kind: 'error' | 'success' | 'working'; message: string } | { kind: 'idle'; message: '' };
|
|
export interface AnnotationState {
|
controls: OfficeContentControl[];
|
operation: OperationState;
|
status: RuntimeStatus;
|
}
|
|
function initialState(): AnnotationState {
|
return {
|
status: 'initializing',
|
controls: [],
|
operation: { kind: 'idle', message: '' },
|
};
|
}
|
|
export const useAnnotationStore = defineStore('annotation', {
|
state: initialState,
|
actions: {
|
reset() {
|
this.$state = initialState();
|
},
|
setControls(controls: OfficeContentControl[]) {
|
this.controls = [...controls];
|
},
|
setOperation(operation: OperationState) {
|
this.operation = operation;
|
},
|
setStatus(status: RuntimeStatus) {
|
this.status = status;
|
},
|
},
|
});
|
|
const hot = import.meta.hot;
|
if (hot) {
|
hot.accept(acceptHMRUpdate(useAnnotationStore, hot));
|
}
|