import { defineStore } from 'pinia';
import app from './app';

const sys = defineStore({
  id: 'sys',
  state: () => ({
    theme: '', // 主题,
    mode: 'light', // 明亮模式、暗黑模式（暂未支持）
    modeAuto: false, // 跟随系统
    fontSize: 1, // 设置默认字号等级(0-4)
	searchTabs: {
		sexLabel: '性别',
		sex2Label: '性别',
		cityLabel: '城市',
		categoryLabel: '分类',
	},
	categoryList: [],
	clerk: {},
	clerkTabIndex: 1,
	user: {},
	userTabIndex: 0,
	homeTabIndex: 0,
	messageTabIndex: 0,
	
	currentClerk: {
		id: -1,
		avatar: 'https://rbtnet.oss-cn-hangzhou.aliyuncs.com/aa361225849eeb86428e1a3d647d6f7b94354e74de212403bb968e6ad85e79b3.jpeg',
	},
	clerkList: [],
	gift: {
		id: -1,
	},
	giftList: [],
	scene: "0", // 小程序场景值
	tradeConfig: {
		brokerageEnabled: false,
		weixinEnabled: false,
		giftEnabled: false,
		qrcode: '',
	},
  }),
  getters: {},
  actions: {
    setTheme(theme = '') {
      if (theme === '') {
        this.theme = app().template?.basic.theme || 'orange';
      } else {
        this.theme = theme;
      }
    },
	setSexLabel(label) {
		this.searchTabs.sexLabel = label;
	},
	setSex2Label(label) {
		this.searchTabs.sex2Label = label;
	},
	setCityLabel(label) {
		this.searchTabs.cityLabel = label;
	},
	setClerkTabIndex(e) {
		this.clerkTabIndex = e;
	},
	setUserTabIndex(e) {
		this.userTabIndex = e;
	},
	setHomeTabIndex(e) {
		this.homeTabIndex = e;
	},
	setMessageTabIndex(e) {
		this.messageTabIndex = e;
	},
	setCategoryLabel(label) {
		this.searchTabs.categoryLabel = label;
	},
	setCategoryList(list) {
		this.categoryList = list;
	},
	setClerk(o) {
		this.clerk = o;
	},
	setUser(o) {
		this.user = o;
	},
	setCurrentClerk(o) {
		this.currentClerk = o;
	},
	setClerkList(list) {
		this.clerkList = list;
	},
	setGift(e) {
		this.gift = e;
	},
	setGiftList(list) {
		this.giftList = list;
	},
	setScene(scene) {
		this.scene = scene;
	},
	setTradeConfig(config) {
		this.tradeConfig = config;
	},
  },
  persist: {
    enabled: true,
    strategies: [
      {
        key: 'sys-store',
      },
    ],
  },
});

export default sys;
