feat: 增加密码管理模块
This commit is contained in:
94
src/store/password.ts
Normal file
94
src/store/password.ts
Normal file
@@ -0,0 +1,94 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import type { IHandleApi } from 'vue3-common/types'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { IPassword } from '@/types/password.ts'
|
||||
|
||||
export const usePasswordStore = defineStore('password', {
|
||||
state: () => ({
|
||||
passwordList: [] as IPassword[],
|
||||
queryInfo: {
|
||||
category: '',
|
||||
owner: '哥哥'
|
||||
},
|
||||
passwordApiType: 'ADD' as IHandleApi,
|
||||
categoryList: [] as string[],
|
||||
currentPassword: {
|
||||
title: '',
|
||||
website: '',
|
||||
username: '',
|
||||
password: '',
|
||||
category: '',
|
||||
owner: '',
|
||||
remark: ''
|
||||
} as IPassword,
|
||||
isScrollEnd: false,
|
||||
isRefresh: false
|
||||
}),
|
||||
actions: {
|
||||
async queryPasswordList() {
|
||||
const password: IPassword = {
|
||||
id: 1,
|
||||
category: '生活',
|
||||
owner: '哥哥',
|
||||
password: '123123',
|
||||
remark: '12',
|
||||
title: '支付宝',
|
||||
username: '13814079242',
|
||||
website: ''
|
||||
}
|
||||
const password2: IPassword = {
|
||||
id: 2,
|
||||
category: '生活',
|
||||
owner: '哥哥',
|
||||
password: '123123',
|
||||
remark: '12',
|
||||
title: '支付宝',
|
||||
username: '13814079242',
|
||||
website: ''
|
||||
}
|
||||
|
||||
this.passwordList = []
|
||||
this.passwordList.push(password)
|
||||
this.passwordList.push(password2)
|
||||
// this.productList = await queryProductListApi(this.queryInfo)
|
||||
},
|
||||
async queryPasswordCategory() {
|
||||
// this.categoryList = await queryProductCategoryApi()
|
||||
this.categoryList = ['生活', '工作']
|
||||
},
|
||||
async handlePasswordApi(password: IPassword) {
|
||||
switch (this.passwordApiType) {
|
||||
case 'ADD':
|
||||
// await addProductApi(product)
|
||||
ElMessage.success('新增密码记录成功')
|
||||
break
|
||||
case 'UPDATE':
|
||||
// await updateProductApi(product.id as number, product)
|
||||
ElMessage.success('更新密码记录成功')
|
||||
break
|
||||
case 'DELETE':
|
||||
// await deleteProductApi(product.id as number)
|
||||
ElMessage.success('删除密码记录成功')
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
await this.refreshInfo()
|
||||
},
|
||||
async refreshInfo() {
|
||||
await this.queryPasswordList()
|
||||
this.isRefresh = !this.isRefresh
|
||||
},
|
||||
getEmptyPassword(): IPassword {
|
||||
return {
|
||||
category: '',
|
||||
owner: '',
|
||||
password: '',
|
||||
remark: '',
|
||||
title: '',
|
||||
username: '',
|
||||
website: ''
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user