UNPKG

general-assistant

Version:

General Assistant components

67 lines (66 loc) 4.24 kB
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime"; import { useTranslation } from 'react-i18next'; import { useStore } from 'zustand'; import StoreContext from '../_store/StoreContext'; import MyIconRender from '../IconRender'; import classNames from 'classnames'; import { useContext } from 'react'; const iconclass1 = ' DS-GA-w-8 DS-GA-h-8 '; const iconclass2 = ' DS-GA-bg-transparent '; export default function IconColumn({ logo, foldleft, edit, name, user, setting, iconx, foldright }) { const { t } = useTranslation(); const dataStore = useContext(StoreContext); const { loadAreaLeft, showAreaLeft, setShowAreaLeft, isAreaLeftNewTopic, loadAreaRight, showAreaRight, setShowAreaRight, _getTemCreate, GlobalCtxs, getAiName, getAiAvatar, getUserName, getUserAvatar, } = useStore(dataStore, (state) => ({ loadAreaLeft: state.loadAreaLeft, showAreaLeft: state.showAreaLeft, setShowAreaLeft: state.setShowAreaLeft, isAreaLeftNewTopic: state.isAreaLeftNewTopic, loadAreaRight: state.loadAreaRight, showAreaRight: state.showAreaRight, setShowAreaRight: state.setShowAreaRight, _getTemCreate: state._getTemCreate, GlobalCtxs: state.GlobalCtxs, getAiName: state.getAiName, getAiAvatar: state.getAiAvatar, getUserName: state.getUserName, getUserAvatar: state.getUserAvatar, })); function getInfo(obj, name) { return Object.assign({ Render: true }, obj, { name: obj.showName ? name : '', onClick() { typeof obj.onClick === 'function' && obj.onClick({ ctx: GlobalCtxs }); }, }); } return (_jsxs(_Fragment, { children: [loadAreaLeft && foldleft && (_jsx(MyIconRender, { def: 'icon-back', Tem: Object.assign({ className: classNames(iconclass1, iconclass2, showAreaLeft ? ' DS-GA-rotate-0' : ' DS-GA-rotate-180'), title: `←${t('fold')}`, posi: 'right', }, foldleft, { onClick() { const _newshow = !showAreaLeft; setShowAreaLeft(_newshow); typeof foldleft.onClick === 'function' && foldleft.onClick({ data: _newshow, ctx: GlobalCtxs }); }, }) })), loadAreaLeft && !showAreaLeft && isAreaLeftNewTopic && edit && (_jsx(MyIconRender, { Tem: Object.assign({}, _getTemCreate({ className: classNames(iconclass1, iconclass2), title: t('uiCreateChat') }), { name: '' }, edit, { onClick() { typeof edit.onClick === 'function' && edit.onClick({ ctx: GlobalCtxs }); }, }), def: 'icon-edit' })), logo && _jsx(MyIconRender, { Tem: getInfo(logo, getAiName()), def: getAiAvatar() }), name && _jsx("div", { className: 'DS-GA-w-full DS-GA-text-lg DS-GA-text-text-deep-7', children: name }), user && _jsx(MyIconRender, { Tem: getInfo(user, getUserName()), def: getUserAvatar() }), setting && (_jsx(MyIconRender, { Tem: Object.assign({ className: classNames(iconclass1, iconclass2), title: t('set') }, setting, { onClick() { typeof setting.onClick === 'function' && setting.onClick({ ctx: GlobalCtxs }); }, }), def: 'icon-set' })), Array.isArray(iconx) && iconx.map((item, index) => (_jsx(MyIconRender, { Tem: Object.assign({}, item, { onClick() { typeof item.onClick === 'function' && item.onClick({ ctx: GlobalCtxs }); }, }), def: null }, index))), loadAreaRight && foldright && (_jsx(MyIconRender, { def: 'icon-rightfold', Tem: Object.assign({ className: classNames(iconclass1, iconclass2), title: `${t('fold')}→` }, foldright, { onClick() { const _newshow = !showAreaRight; setShowAreaRight(_newshow); typeof foldright.onClick === 'function' && foldright.onClick({ data: _newshow, ctx: GlobalCtxs }); }, }) }))] })); }