29 lines
474 B
JavaScript
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++
|
|
},
|
|
},
|
|
})
|