add pinia

This commit is contained in:
dt
2023-09-17 21:44:28 +08:00
parent fce56e43c3
commit 4adb8401d6
3 changed files with 40 additions and 10 deletions

View File

@@ -5,7 +5,7 @@
selected-color="primary" selected-color="primary"
default-expand-all default-expand-all
:nodes="LeftDataBus.root" :nodes="LeftDataBus.root"
v-model:selected="selected" v-model:selected="flowNames1"
node-key="label" node-key="label"
> >
</q-tree> </q-tree>
@@ -18,9 +18,12 @@ import {
setControlPanelE, setControlPanelE,
} from 'components/flowEditor/left/DataBus'; } from 'components/flowEditor/left/DataBus';
import { ref } from 'vue'; import { ref } from 'vue';
import { storeToRefs } from 'pinia';
import { useFlowEditorStore } from 'stores/flowEditor';
// 应该在page中用网络请求获取值并初始化组件 // 应该在page中用网络请求获取值并初始化组件
// 然后在page中执行setControlPane设置databus // 然后在page中执行setControlPane设置databus
const selected = ref('保存をクリックした時'); const store = useFlowEditorStore();
const { flowNames1 } = storeToRefs(store);
setControlPanelE(); setControlPanelE();
</script> </script>

View File

@@ -10,6 +10,8 @@
:key="flowName" :key="flowName"
:label="flowName" :label="flowName"
/> />
<q-breadcrumbs-el :label="flowNames1" />
</q-breadcrumbs> </q-breadcrumbs>
<q-separator vertical class="q-mr-xs" /> <q-separator vertical class="q-mr-xs" />
<q-btn <q-btn
@@ -115,10 +117,11 @@ import FlowChartTest from 'pages/FlowChartTest.vue';
import ControlPanel from 'components/flowEditor/left/ControlPanelC.vue'; import ControlPanel from 'components/flowEditor/left/ControlPanelC.vue';
import ItemSelector from 'components/flowEditor/left/ItemSelector.vue'; import ItemSelector from 'components/flowEditor/left/ItemSelector.vue';
import { computed, ref } from 'vue'; import { computed, ref } from 'vue';
import { storeToRefs } from 'pinia';
import ShowDialog from 'components/ShowDialog.vue'; import ShowDialog from 'components/ShowDialog.vue';
import ActionSelect from 'components/ActionSelect.vue'; import ActionSelect from 'components/ActionSelect.vue';
import { useFlowEditorStore } from 'stores/flowEditor';
const show = ref(false); const show = ref(false);
const addshow = ref(true); const addshow = ref(true);
const appDg = ref(); const appDg = ref();
@@ -127,17 +130,18 @@ interface FlowEditorPageProps {
actName: string; actName: string;
flowNames: string[]; flowNames: string[];
} }
const store = useFlowEditorStore();
const { flowNames1 } = storeToRefs(store);
flowNames1.value = '保存をクリックした時';
const props = withDefaults(defineProps<FlowEditorPageProps>(), { const props = withDefaults(defineProps<FlowEditorPageProps>(), {
actName: '勤怠管理 - 4', actName: '勤怠管理 - 4',
flowNames: () => ['レコードを追加画面', '保存をクリックした時'], flowNames: () => ['レコードを追加画面', '保存をクリックした時'],
}); });
const actName = computed(() => props.actName); const actName = computed(() => props.actName);
const flowNames = computed(() => props.flowNames); const flowNames = computed(() => props.flowNames as Array<string>);
flowNames.value.splice(1, 1, flowNames1.value)
const drawerLeft = ref(false); const drawerLeft = ref(false);
const showDg = () => { const showDg = () => {
show.value = true; show.value = true;
}; };
@@ -161,10 +165,8 @@ const closeDg = (val: string) => {
if (document.getElementsByClassName('action').length > 0) { if (document.getElementsByClassName('action').length > 0) {
addshow.value = false; addshow.value = false;
} }
}; }
}; };
</script> </script>
<style lang="sass"> <style lang="sass">

View File

@@ -0,0 +1,25 @@
import { defineStore } from 'pinia';
export const useFlowEditorStore = defineStore('flowEditor', {
state: () => ({
counter: 0,
flowNames: [],
flowNames1: ''
}),
getters: {
doubleCount(state) {
return state.counter * 2;
}
},
actions: {
increment() {
this.counter++;
},
setDefaultFlow() {
this.counter++
}
}
});