Files
gd-earth/src/stores/Point.js
2022-04-07 22:17:28 +08:00

29 lines
474 B
JavaScript

import { defineStore } from 'pinia'
export const usePointStore = defineStore({
id: 'point',
state: () => ({
index: 0,
length: 10,
rawItems: [],
}),
getters: {
items: (state) => {
const items = state.rawItems
items.length = state.length
return items
}
},
actions: {
addItem(item) {
if (this.index >= this.length) {
return
}
this.rawItems[this.index] = item
this.index++
},
},
})