Merge branch 'master' of https://git.yunzer.cn/yunzerwebsite/yunzerwebsiteallinone
This commit is contained in:
commit
5d7ed43570
16 files changed
+11811
-1008
No files matched your search
@@ -0,0 +1,77 @@
|
||||
import { request } from '@/api/request.js'
|
||||
|
||||
/**
|
||||
* 账号管理(密码库)——记录个人各平台账号。
|
||||
* 与 Web 端密码存储管理同一套数据(一个平台下挂多个账号)。
|
||||
* 服务端自动过滤当前登录用户的记录,无需传 user_id。
|
||||
*/
|
||||
export function fetchPasswordStores(keyword) {
|
||||
return request({
|
||||
url: '/api/passwordStore/list',
|
||||
data: keyword ? { keyword } : {}
|
||||
}).then(data => ({
|
||||
list: (data.list || []).map(normalizeStore),
|
||||
total: data.total || 0
|
||||
}))
|
||||
}
|
||||
|
||||
export function getPasswordStore(id) {
|
||||
return request({
|
||||
url: `/api/passwordStore/detail/${id}`
|
||||
}).then(normalizeStore)
|
||||
}
|
||||
|
||||
export function createPasswordStore(data) {
|
||||
return request({
|
||||
url: '/api/passwordStore/create',
|
||||
method: 'POST',
|
||||
data: pickStore(data)
|
||||
}).then(normalizeStore)
|
||||
}
|
||||
|
||||
export function updatePasswordStore(id, data) {
|
||||
return request({
|
||||
url: `/api/passwordStore/update/${id}`,
|
||||
method: 'POST',
|
||||
data: pickStore(data)
|
||||
}).then(normalizeStore)
|
||||
}
|
||||
|
||||
export function deletePasswordStore(id) {
|
||||
return request({
|
||||
url: `/api/passwordStore/delete/${id}`,
|
||||
method: 'DELETE'
|
||||
}).then(() => true)
|
||||
}
|
||||
|
||||
/** 只取服务端接收的字段 */
|
||||
function pickStore(data) {
|
||||
return {
|
||||
platform: data.platform || '',
|
||||
url: data.url || '',
|
||||
remark: data.remark || '',
|
||||
accounts: (data.accounts || []).map(a => ({
|
||||
username: a.username || '',
|
||||
password: a.password || '',
|
||||
registration_info: a.registration_info || '',
|
||||
remark: a.remark || ''
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
/** 统一账号列表结构,避免后端缺字段导致渲染报错 */
|
||||
function normalizeStore(item) {
|
||||
const store = item || {}
|
||||
return {
|
||||
...store,
|
||||
platform: store.platform || '',
|
||||
url: store.url || '',
|
||||
remark: store.remark || '',
|
||||
accounts: (store.accounts || []).map(a => ({
|
||||
username: a.username || '',
|
||||
password: a.password || '',
|
||||
registration_info: a.registration_info || '',
|
||||
remark: a.remark || ''
|
||||
}))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user