bugfix: pinia instance not created internally and thus missing from app if not explicitly included

This commit is contained in:
Braks
2021-07-09 22:18:10 +02:00
parent 6242b8e400
commit c8150a252f
3 changed files with 10 additions and 16 deletions

View File

@@ -1,15 +1,18 @@
<template>
<div id="app">
<h1>Revue Flow</h1>
<Basic style="height: 75vh; background: #1a192b" />
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue-demi';
import Basic from './Basic';
export default defineComponent({
name: 'App',
components: {
Basic
},
data() {
return {

View File

@@ -1,8 +1,6 @@
import { createApp } from 'vue-demi';
import App from './App.vue';
import { createPinia } from 'pinia';
const app = createApp(App);
app.config.performance = true;
app.use(createPinia());
app.mount('#app');

View File

@@ -1,28 +1,21 @@
import { createPinia, defineStore, StoreDefinition } from 'pinia';
import { setActivePinia, createPinia, defineStore, StoreDefinition } from 'pinia';
import isEqual from 'fast-deep-equal';
import { Edge, Node, NodeDiffUpdate, ReactFlowState, RevueFlowActionsTree, XYPosition } from '../types';
import {
getConnectedEdges,
getNodesInside,
getRectOfNodes,
isEdge,
isNode,
parseEdge,
parseNode
} from '../utils/graph';
import { getConnectedEdges, getNodesInside, getRectOfNodes, isEdge, isNode, parseEdge, parseNode } from '../utils/graph';
import { clampPosition, getDimensions } from '../utils';
import { getHandleBounds } from '../components/Nodes/utils';
import { provide } from 'vue-demi';
type NextElements = {
nextNodes: Node[];
nextEdges: Edge[];
};
const pinia = createPinia();
setActivePinia(pinia);
export default function configureStore(
preloadedState: ReactFlowState
): StoreDefinition<'revue-flow', ReactFlowState, any, RevueFlowActionsTree> {
provide(Symbol('pinia'), createPinia());
return defineStore({
id: 'revue-flow',
state: () => preloadedState,
@@ -199,8 +192,8 @@ export default function configureStore(
const selectedElementsChanged = !isEqual(nextSelectedElements, this.selectedElements);
const selectedElementsUpdate = selectedElementsChanged
? {
selectedElements: nextSelectedElements.length > 0 ? nextSelectedElements : null
}
selectedElements: nextSelectedElements.length > 0 ? nextSelectedElements : null
}
: {};
this.userSelectionRect = nextUserSelectRect;