systemConfig.ts 663 B

12345678910111213141516171819202122232425262728
  1. import { defineStore } from 'pinia';
  2. import { ConfigStates } from './interface';
  3. import { request } from '../utils/service';
  4. export const urlPrefix = '/api/init/settings/';
  5. /**
  6. * 系统配置数据
  7. * @methods getSystemConfig 获取系统配置数据
  8. */
  9. export const SystemConfigStore = defineStore('SystemConfig', {
  10. state: (): ConfigStates => ({
  11. systemConfig: {},
  12. }),
  13. actions: {
  14. async getSystemConfigs() {
  15. request({
  16. url: urlPrefix,
  17. method: 'get',
  18. }).then((ret: { data: [] }) => {
  19. // 转换数据格式并保存到pinia
  20. this.systemConfig = JSON.parse(JSON.stringify(ret.data));
  21. });
  22. },
  23. },
  24. persist: {
  25. enabled: true,
  26. },
  27. });