perf: 开放邮件功能给所有人

dev/supplier-email-drawer
LiaoYijun 9 months ago
parent 5977ec2351
commit b734016aa7

@ -7,6 +7,7 @@ import { API_HOST, BUILD_VERSION } from '@/config'
export const PERM_MERGE_CONVERSATION = 'merge-conversation' export const PERM_MERGE_CONVERSATION = 'merge-conversation'
export const PERM_ASSIGN_NEW_CONVERSATION = 'assign-new-conversation' export const PERM_ASSIGN_NEW_CONVERSATION = 'assign-new-conversation'
export const PERM_USE_EMAL = 'use-email' export const PERM_USE_EMAL = 'use-email'
export const PERM_USE_WHATSAPP = 'use-whatsapp'
export const PERM_IMPORT_EMAIL = 'import-email' export const PERM_IMPORT_EMAIL = 'import-email'
const useAuthStore = create(devtools((set, get) => ({ const useAuthStore = create(devtools((set, get) => ({
@ -30,7 +31,7 @@ const useAuthStore = create(devtools((set, get) => ({
const { loginUser } = get() const { loginUser } = get()
if (perm === PERM_USE_EMAL) { if (perm === PERM_USE_EMAL) {
return ['501', '466', '599', '495', '143', '370', '639', '513', '654', '404', '383', '227'].includes(loginUser.userId) return true//['501', '466', '599', '495', '143', '370', '639', '513', '654', '404', '383', '227'].includes(loginUser.userId)
} }
// 导入邮件消息,需要配置才能使用 // 导入邮件消息,需要配置才能使用

@ -1,9 +1,7 @@
import ErrorBoundary from '@/components/ErrorBoundary' import ErrorBoundary from '@/components/ErrorBoundary'
import useAuthStore from '@/stores/AuthStore' import useAuthStore from '@/stores/AuthStore'
import { useThemeContext } from '@/stores/ThemeContext' import { useThemeContext } from '@/stores/ThemeContext'
import { Conditional } from '@/components/Conditional'
import useConversationStore from '@/stores/ConversationStore' import useConversationStore from '@/stores/ConversationStore'
import { PERM_USE_EMAL } from '@/stores/AuthStore'
import { import {
App as AntApp, App as AntApp,
ConfigProvider, ConfigProvider,
@ -13,7 +11,7 @@ import {
FloatButton, FloatButton,
theme, theme,
} from 'antd' } from 'antd'
import { BugOutlined, MailOutlined } from '@ant-design/icons' import { BugOutlined } from '@ant-design/icons'
import zhLocale from 'antd/locale/zh_CN' import zhLocale from 'antd/locale/zh_CN'
import 'dayjs/locale/zh-cn' import 'dayjs/locale/zh-cn'
import { useEffect } from 'react' import { useEffect } from 'react'
@ -38,8 +36,8 @@ function AuthApp() {
const [messageApi, contextHolder] = message.useMessage() const [messageApi, contextHolder] = message.useMessage()
const { colorPrimary, borderRadius } = useThemeContext() const { colorPrimary, borderRadius } = useThemeContext()
const [loginUser, sendNotify, isPermitted] = useAuthStore((state) => [ const [loginUser, sendNotify] = useAuthStore((state) => [
state.loginUser, state.sendNotify, state.isPermitted state.loginUser, state.sendNotify
]) ])
const href = useHref() const href = useHref()
@ -64,10 +62,7 @@ function AuthApp() {
connectWebsocket(loginUser.userId) connectWebsocket(loginUser.userId)
fetchInitialData(loginUser) fetchInitialData(loginUser)
let _fetchEmailWorker; _fetchEmailWorker = startEmailInterval(loginUser.userId)
if (isPermitted(PERM_USE_EMAL)) {
_fetchEmailWorker = startEmailInterval(loginUser.userId)
}
} }
return () => { return () => {
disconnectWebsocket() disconnectWebsocket()
@ -136,10 +131,7 @@ function AuthApp() {
insetInlineEnd: 94, insetInlineEnd: 94,
}} }}
> >
<Conditional <EmailFetch />
condition={isPermitted(PERM_USE_EMAL)}
whenTrue={<EmailFetch />}
/>
<FloatButton icon={<BugOutlined />} tooltip={<div>上传日志给研发部</div>} onClick={() => uploadLog()} /> <FloatButton icon={<BugOutlined />} tooltip={<div>上传日志给研发部</div>} onClick={() => uploadLog()} />
<FloatButton.BackTop /> <FloatButton.BackTop />
</FloatButton.Group> </FloatButton.Group>

@ -10,7 +10,7 @@ import useStyleStore from '@/stores/StyleStore';
import { isEmpty } from '@/utils/commons'; import { isEmpty } from '@/utils/commons';
import { DEFAULT_CHANNEL } from '@/config'; import { DEFAULT_CHANNEL } from '@/config';
import { WABAccounts, WABAccountsMapped } from '@/channel/bubbleMsgUtils'; import { WABAccounts, WABAccountsMapped } from '@/channel/bubbleMsgUtils';
import useAuthStore, { PERM_USE_EMAL} from '@/stores/AuthStore'; import useAuthStore from '@/stores/AuthStore';
/** /**
* @ignore * @ignore
@ -73,7 +73,7 @@ const ReplyWrapper = () => {
const replyTypes = [ const replyTypes = [
// { key: 'waba', label: mobile ? '' : (<WABASwitcher />), icon: <WABIcon />, children: <InputComposer channel={'waba'} /> }, // { key: 'waba', label: mobile ? '' : (<WABASwitcher />), icon: <WABIcon />, children: <InputComposer channel={'waba'} /> },
{ key: 'waba', label: mobile ? '' : `商业号(${WABAccountsMapped[whatsAppBusiness]?.verifiedName || '-'})`, icon: <WABIcon />, children: <InputComposer currentActive={activeChannel==='waba'} channel={'waba'} /> }, { key: 'waba', label: mobile ? '' : `商业号(${WABAccountsMapped[whatsAppBusiness]?.verifiedName || '-'})`, icon: <WABIcon />, children: <InputComposer currentActive={activeChannel==='waba'} channel={'waba'} /> },
{ key: 'email', label: mobile ? '' : '邮件', icon: <MailOutlined className='text-indigo-500' />, children: isPermitted(PERM_USE_EMAL) ? <EmailComposer currentActive={activeChannel==='email'} /> : <div className='p-2 py-4 text-center text-whatsapp bg-gray-200 rounded rounded-b-none border-gray-300 border-solid border border-b-0 border-x-0'>敬请期待</div> }, { key: 'email', label: mobile ? '' : '邮件', icon: <MailOutlined className='text-indigo-500' />, children: <EmailComposer currentActive={activeChannel==='email'} />},
// { key: 'whatsapp', label: mobile ? '' : 'WhatsApp', icon: <WhatsAppOutlined className='text-whatsapp' />, children: <InputComposer channel={'whatsapp'} /> }, // { key: 'whatsapp', label: mobile ? '' : 'WhatsApp', icon: <WhatsAppOutlined className='text-whatsapp' />, children: <InputComposer channel={'whatsapp'} /> },
{ key: 'wa', label: mobile ? '' : 'WhatsApp', icon: <WhatsAppOutlined className='text-whatsapp' />, children: <div className='p-2 py-4 text-center text-whatsapp bg-gray-200 rounded rounded-b-none border-gray-300 border-solid border border-b-0 border-x-0'>正在开发敬请期待</div> }, { key: 'wa', label: mobile ? '' : 'WhatsApp', icon: <WhatsAppOutlined className='text-whatsapp' />, children: <div className='p-2 py-4 text-center text-whatsapp bg-gray-200 rounded rounded-b-none border-gray-300 border-solid border border-b-0 border-x-0'>正在开发敬请期待</div> },
// TODO: WA // TODO: WA

Loading…
Cancel
Save