parent
bbeb4d0ffd
commit
eb8384491a
6 changed files with 154 additions and 24 deletions
@ -0,0 +1,42 @@ |
||||
import requset from '@/utils/requset' |
||||
import { ElLoading, ElMessage } from 'element-plus' |
||||
import pinia from '@/store'; |
||||
import userStore from '@/store/module/user'; |
||||
const user = userStore(pinia) |
||||
enum Api { |
||||
get系统配置 = '/api/systemSettings/save', |
||||
|
||||
} |
||||
// 提示批量处理
|
||||
const initOptions = { text: '加载中', success: '成功', error: '失败' } |
||||
function proxrequset(requset, options: any = initOptions) { |
||||
return async (...arg) => { |
||||
if (!options) return requset(...arg) |
||||
|
||||
const loadingInstance = ElLoading.service({ text: options.text }) |
||||
|
||||
try { |
||||
await requset(...arg) |
||||
ElMessage.success(options.success) |
||||
} catch (error) { |
||||
ElMessage.error(options.error) |
||||
} finally { |
||||
loadingInstance.close() |
||||
} |
||||
|
||||
return requset |
||||
} |
||||
} |
||||
|
||||
|
||||
export function getSysSettingApi() { |
||||
return requset.get(Api.get系统配置) |
||||
} |
||||
export const proxGetSysSettingApi = proxrequset(getSysSettingApi) |
||||
|
||||
|
||||
export const userGetInfoService = () => |
||||
requset.get('/api/user/info', { |
||||
headers: { Authorization: `Bearer ${user.token}` }, |
||||
}) |
||||
|
@ -0,0 +1,32 @@ |
||||
import { defineStore } from 'pinia' |
||||
import { reactive } from 'vue'; |
||||
import { getSysSettingApi } from '@/api/configuration'; |
||||
|
||||
|
||||
const useAdminInfoStore = defineStore('adminInfo', () => { |
||||
const info = reactive({ |
||||
address: '', |
||||
copyrightInformation: '', |
||||
id: '', |
||||
loginAddress: '', |
||||
logo: '', |
||||
name: '', |
||||
phone: '', |
||||
promotionalImages: '', |
||||
qqNumber: '', |
||||
qrCode: '', |
||||
recordNumber: '', |
||||
title: '', |
||||
mailbox: '', |
||||
home: '' |
||||
}) |
||||
function upAdminInfo() { |
||||
getSysSettingApi().then(res => { |
||||
if (res.code === 200) Object.assign(info, res.data) |
||||
}) |
||||
} |
||||
upAdminInfo() |
||||
|
||||
return { info } |
||||
}) |
||||
export default useAdminInfoStore |
Loading…
Reference in new issue