Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
下载app软件和通知
I5bijibnecffe2906d811
diff --git a/src/app/config/appDownloadConfig.ts b/src/app/config/appDownloadConfig.tsnew file mode 100644index 00000000..95eebae0--- /dev/null+++ b/src/app/config/appDownloadConfig.ts@@ -0,0 +1,59 @@+/**+ * 应用下载配置文件+ * 管理不同平台的下载链接、二维码等信息+ */++export interface AppDownloadConfig {+ platform: string;+ appName: string;+ downloadUrl: string;+ qrCodeUrl?: string;+ description: string;+ tips: string[];+}++export const APP_DOWNLOAD_CONFIGS: Record<string, AppDownloadConfig> = {+ xhs: {+ platform: "小红书",+ appName: "小红书App",+ downloadUrl: "https://apps.apple.com/cn/app/id123456789", // 这里配置实际的下载链接+ qrCodeUrl: "", // 这里配置实际的二维码图片URL+ description: "小红书相关操作需要在移动端App中进行,请下载并安装小红书App后继续操作。",+ tips: [+ "安装完成后,请在App中登录您的账号",+ "确保账号已通过实名认证",+ "在App中完成相关任务操作"+ ]+ },+ douyin: {+ platform: "抖音",+ appName: "抖音App",+ downloadUrl: "https://apps.apple.com/cn/app/douyin/id123456789",+ qrCodeUrl: "",+ description: "抖音相关操作需要在移动端App中进行,请下载并安装抖音App后继续操作。",+ tips: [+ "安装完成后,请在App中登录您的账号",+ "确保账号已通过实名认证",+ "在App中完成相关任务操作"+ ]+ },+ // 可以继续添加其他平台的配置+};++/**+ * 获取平台下载配置+ * @param platformKey 平台标识符,如 'xhs', 'douyin'+ * @returns 下载配置信息+ */+export const getAppDownloadConfig = (platformKey: string): AppDownloadConfig | null => {+ return APP_DOWNLOAD_CONFIGS[platformKey] || null;+};++/**+ * 检查任务是否需要App操作+ * @param accountTypes 账号类型数组+ * @returns 需要App操作的平台列表+ */+export const getTasksRequiringApp = (accountTypes: string[]): string[] => {+ return accountTypes.filter(type => APP_DOWNLOAD_CONFIGS[type]);+};diff --git a/src/components/common/DownloadAppModal.tsx b/src/components/common/DownloadAppModal.tsxnew file mode 100644index 00000000..b1423175--- /dev/null+++ b/src/components/common/DownloadAppModal.tsx@@ -0,0 +1,155 @@+import React from 'react';+import { Modal, Button, Space, Typography } from 'antd';+import { DownloadOutlined, MobileOutlined, QrcodeOutlined } from '@ant-design/icons';+import { useTransClient } from '@/app/i18n/client';++const { Text, Paragraph } = Typography;++interface DownloadAppModalProps {+ visible: boolean;+ onClose: () => void;+ platform?: string; // 平台名称,如"小红书"+ appName?: string; // app名称+ downloadUrl?: string; // 下载链接+ qrCodeUrl?: string; // 二维码图片URL+}++/**+ * 下载App提示弹窗组件+ * 用于提示用户下载对应的移动端应用+ */+const DownloadAppModal: React.FC<DownloadAppModalProps> = ({+ visible,+ onClose,+ platform = "小红书",+ appName = "小红书App",+ downloadUrl,+ qrCodeUrl+}) => {+ const { t } = useTransClient("common");++ const handleDownload = () => {+ if (downloadUrl) {+ window.open(downloadUrl, '_blank');+ }+ };++ const handleCopyLink = () => {+ if (downloadUrl) {+ navigator.clipboard.writeText(downloadUrl).then(() => {+ // 可以添加复制成功的提示+ });+ }+ };++ return (+ <Modal+ title={+ <Space>+ <MobileOutlined style={{ color: '#1890ff' }} />+ <span>下载{appName}</span>+ </Space>+ }+ open={visible}+ onCancel={onClose}+ footer={[+ <Button key="close" onClick={onClose}>+ 关闭+ </Button>,+ downloadUrl && (+ <Button+ key="download"+ type="primary"+ icon={<DownloadOutlined />}+ onClick={handleDownload}+ >+ 立即下载+ </Button>+ )+ ]}+ width={500}+ centered+ destroyOnClose+ >+ <div style={{ textAlign: 'center', padding: '20px 0' }}>+ <div style={{ marginBottom: '24px' }}>+ <MobileOutlined style={{ fontSize: '48px', color: '#1890ff' }} />+ </div>++ <Typography.Title level={4} style={{ marginBottom: '16px' }}>+ 请在{platform}App中操作+ </Typography.Title>++ <Paragraph style={{ color: '#666', marginBottom: '24px' }}>+ 为了更好的用户体验和功能完整性,{platform}相关操作需要在移动端App中进行。+ 请下载并安装{appName}后继续操作。+ </Paragraph>++ {qrCodeUrl && (+ <div style={{ marginBottom: '24px' }}>+ <div style={{ marginBottom: '8px' }}>+ <QrcodeOutlined style={{ marginRight: '4px' }} />+ <Text strong>扫描二维码下载</Text>+ </div>+ <img+ src={qrCodeUrl}+ alt="下载二维码"+ style={{+ width: '120px',+ height: '120px',+ border: '1px solid #e8e8e8',+ borderRadius: '8px'+ }}+ />+ </div>+ )}++ {downloadUrl && (+ <div style={{ marginBottom: '16px' }}>+ <Space direction="vertical" size="small">+ <Text type="secondary">下载链接:</Text>+ <div style={{+ display: 'flex',+ alignItems: 'center',+ gap: '8px',+ justifyContent: 'center'+ }}>+ <Text+ code+ style={{+ maxWidth: '300px',+ overflow: 'hidden',+ textOverflow: 'ellipsis',+ whiteSpace: 'nowrap'+ }}+ >+ {downloadUrl}+ </Text>+ <Button+ size="small"+ onClick={handleCopyLink}+ type="text"+ >+ 复制+ </Button>+ </div>+ </Space>+ </div>+ )}++ <div style={{+ padding: '16px',+ backgroundColor: '#f6f8fa',+ borderRadius: '8px',+ border: '1px solid #e1e4e8'+ }}>+ <Text type="secondary">+ 💡 提示:安装完成后,请在App中登录您的账号,然后重新尝试相关操作+ </Text>+ </div>+ </div>+ </Modal>+ );+};++export default DownloadAppModal;diff --git a/src/components/common/index.ts b/src/components/common/index.tsnew file mode 100644index 00000000..6f741e93--- /dev/null+++ b/src/components/common/index.ts@@ -0,0 +1,2 @@+// 通用组件导出+export { default as DownloadAppModal } from './DownloadAppModal';diff --git a/src/components/notification/NotificationPanel.tsx b/src/components/notification/NotificationPanel.tsxindex a45ea890..d552b1f7 100644--- a/src/components/notification/NotificationPanel.tsx+++ b/src/components/notification/NotificationPanel.tsx@@ -19,6 +19,8 @@ import {} from "@/api/notification";import { getOssUrl } from "@/utils/oss";import { PubType } from "@/app/config/publishConfig";+import { getAppDownloadConfig, getTasksRequiringApp } from "@/app/config/appDownloadConfig";+import DownloadAppModal from "@/components/common/DownloadAppModal";import styles from "./NotificationPanel.module.scss";interface NotificationPanelProps {@@ -36,6 +38,15 @@ const NotificationPanel: React.FC<NotificationPanelProps> = ({ visible, onCloseconst [selectedTask, setSelectedTask] = useState<TaskItem | null>(null);const [detailModalVisible, setDetailModalVisible] = useState(false);const [taskLoading, setTaskLoading] = useState(false);++ // 下载App弹窗状态+ const [downloadAppVisible, setDownloadAppVisible] = useState(false);+ const [downloadAppConfig, setDownloadAppConfig] = useState({+ platform: "",+ appName: "",+ downloadUrl: "",+ qrCodeUrl: "" as string | undefined+ });// 获取通知列表const fetchNotifications = async () => {@@ -163,6 +174,38 @@ const NotificationPanel: React.FC<NotificationPanelProps> = ({ visible, onClose}};+ // 检查任务类型并显示相应的操作提示+ const handleTaskAction = (task: TaskItem) => {+ if (!task.accountTypes || task.accountTypes.length === 0) {+ // 没有账号类型限制,直接接取任务+ handleAcceptTask();+ return;+ }++ // 检查需要App操作的平台+ const appRequiredPlatforms = getTasksRequiringApp(task.accountTypes);++ if (appRequiredPlatforms.length > 0) {+ // 有需要App操作的平台,显示第一个平台的下载提示+ const firstPlatform = appRequiredPlatforms[0];+ const config = getAppDownloadConfig(firstPlatform);++ if (config) {+ setDownloadAppConfig({+ platform: config.platform,+ appName: config.appName,+ downloadUrl: config.downloadUrl,+ qrCodeUrl: config.qrCodeUrl+ });+ setDownloadAppVisible(true);+ return;+ }+ }++ // 其他任务类型正常接取+ handleAcceptTask();+ };+// 格式化时间const formatTime = (timeString: string) => {const date = new Date(timeString);@@ -535,9 +578,33 @@ const NotificationPanel: React.FC<NotificationPanelProps> = ({ visible, onClose</div>{selectedTask.status === 'active' && selectedTask.currentRecruits < selectedTask.maxRecruits && (<div className={styles.taskActions}>+ {/* 需要App操作的平台提示 */}+ {selectedTask.accountTypes && selectedTask.accountTypes.length > 0 && (+ (() => {+ const appRequiredPlatforms = getTasksRequiringApp(selectedTask.accountTypes);+ if (appRequiredPlatforms.length > 0) {+ const platformNames = appRequiredPlatforms.map(p => getAppDownloadConfig(p)?.platform).filter(Boolean);+ return (+ <div style={{+ marginBottom: '12px',+ padding: '12px',+ backgroundColor: '#fff7e6',+ border: '1px solid #ffd591',+ borderRadius: '6px',+ color: '#d46b08'+ }}>+ <strong>⚠️ 注意:</strong>+ {platformNames.join('、')}任务需要在移动端App中操作,请下载对应App后继续。+ </div>+ );+ }+ return null;+ })()+ )}+<Buttontype="primary"- onClick={handleAcceptTask}+ onClick={() => handleTaskAction(selectedTask)}style={{ marginTop: '12px' }}>接受任务@@ -556,6 +623,16 @@ const NotificationPanel: React.FC<NotificationPanelProps> = ({ visible, onClose</div>)}</Modal>++ {/* 下载App提示弹窗 */}+ <DownloadAppModal+ visible={downloadAppVisible}+ onClose={() => setDownloadAppVisible(false)}+ platform={downloadAppConfig.platform}+ appName={downloadAppConfig.appName}+ downloadUrl={downloadAppConfig.downloadUrl}+ qrCodeUrl={downloadAppConfig.qrCodeUrl}+ /></>);};