mirror of
https://github.com/marktext/marktext.git
synced 2025-05-16 08:50:42 +08:00
39 lines
800 B
JavaScript
39 lines
800 B
JavaScript
import resource from './resource'
|
|
|
|
const state = {
|
|
aiLoading: false,
|
|
aiList: []
|
|
}
|
|
|
|
const mutations = {
|
|
SET_AI_LIST (state, { data, type }) {
|
|
console.log(type)
|
|
if (type === 'search') {
|
|
state.aiList = data
|
|
} else {
|
|
state.aiList = [...state.aiList, ...data]
|
|
}
|
|
},
|
|
SET_AI_STATUS (state, bool) {
|
|
state.aiLoading = bool
|
|
}
|
|
}
|
|
|
|
const actions = {
|
|
AI_SEARCH ({ commit }, { params, type }) {
|
|
commit('SET_AI_STATUS', true)
|
|
return resource.sogou(params)
|
|
.then(({ data, total }) => {
|
|
commit('SET_AI_LIST', { data, type })
|
|
commit('SET_AI_STATUS', false)
|
|
return { data, total }
|
|
})
|
|
.catch(err => {
|
|
console.log(err)
|
|
commit('SET_AI_STATUS', false)
|
|
})
|
|
}
|
|
}
|
|
|
|
export default { state, mutations, actions }
|