| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- import { acceptHMRUpdate, defineStore } from 'pinia';
- interface ContentsPosition {
- [key: string]: any;
- /**
- * 定位方式
- */
- position: 'static' | 'fixed' | 'absolute' | 'relative' | 'sticky';
- /**
- * 顶部位置
- */
- top: string;
- /**
- * 左侧位置
- */
- left: string;
- /**
- * 宽
- */
- width: string;
- /**
- * 左边距
- */
- paddingLeft: string;
- }
- /**
- * @zh_CN 用户信息相关
- */
- export const useContentsPositionStore = defineStore('contents-position', {
- actions: {
- setPosition(position: 'static' | 'fixed' | 'absolute' | 'relative' | 'sticky') {
- this.position = position;
- },
- setTop(top: string) {
- this.top = top;
- },
- setLeft(left: string) {
- this.left = left;
- },
- setWidth(width: string) {
- this.width = width;
- },
- setPaddingLeft(paddingLeft: string) {
- this.paddingLeft = paddingLeft;
- },
- },
- state: (): ContentsPosition => ({
- position: 'static',
- top: 'unset',
- left: 'unset',
- width: '100%',
- paddingLeft: '0',
- }),
- });
- // 解决热更新问题
- const hot = import.meta.hot;
- if (hot) {
- hot.accept(acceptHMRUpdate(useContentsPositionStore, hot));
- }
|