112 lines
3.0 KiB
TypeScript
112 lines
3.0 KiB
TypeScript
// =============================================================================
|
|
// 企微IT智能服务台 — 欢迎与引导配置 API
|
|
// =============================================================================
|
|
// 说明:封装欢迎页、引导视频、互动教学、主题模板的 API 调用
|
|
|
|
import apiClient from './index'
|
|
|
|
// ==========================================================================
|
|
// 类型定义
|
|
// ==========================================================================
|
|
|
|
/** 欢迎页配置 */
|
|
export interface WelcomePageConfig {
|
|
enabled: boolean
|
|
title: string
|
|
content: string
|
|
background_color: string
|
|
}
|
|
|
|
/** 引导视频配置 */
|
|
export interface WelcomeVideoConfig {
|
|
url: string
|
|
filename: string
|
|
uploaded_at: string
|
|
}
|
|
|
|
/** 互动教学步骤 */
|
|
export interface TutorialStep {
|
|
id: string
|
|
title: string
|
|
description: string
|
|
}
|
|
|
|
/** 互动教学配置 */
|
|
export interface TutorialConfig {
|
|
enabled: boolean
|
|
steps: TutorialStep[]
|
|
}
|
|
|
|
/** 主题模板配置 */
|
|
export interface ThemeConfig {
|
|
theme: 'default' | 'blue' | 'orange' | 'red'
|
|
}
|
|
|
|
/** 完整欢迎与引导配置 */
|
|
export interface WelcomeConfig {
|
|
welcome_page: WelcomePageConfig
|
|
welcome_video: WelcomeVideoConfig | null
|
|
tutorial: TutorialConfig
|
|
theme: ThemeConfig
|
|
}
|
|
|
|
// ==========================================================================
|
|
// API 函数
|
|
// ==========================================================================
|
|
|
|
/**
|
|
* 获取欢迎与引导配置
|
|
*/
|
|
export function getWelcomeConfig(): Promise<{ data: { code: number; data: WelcomeConfig; message: string } }> {
|
|
return apiClient.get('/admin/welcome-config')
|
|
}
|
|
|
|
/**
|
|
* 更新欢迎与引导配置
|
|
*/
|
|
export function updateWelcomeConfig(
|
|
data: WelcomeConfig
|
|
): Promise<{ data: { code: number; data: WelcomeConfig; message: string } }> {
|
|
return apiClient.put('/admin/welcome-config', data)
|
|
}
|
|
|
|
/**
|
|
* 上传引导视频
|
|
*/
|
|
export function uploadWelcomeVideo(
|
|
file: File
|
|
): Promise<{ data: { code: number; data: { url: string; filename: string; uploaded_at: string }; message: string } }> {
|
|
const formData = new FormData()
|
|
formData.append('file', file)
|
|
return apiClient.post('/admin/welcome-video', formData, {
|
|
headers: {
|
|
'Content-Type': 'multipart/form-data',
|
|
},
|
|
})
|
|
}
|
|
|
|
/**
|
|
* 删除引导视频
|
|
*/
|
|
export function deleteWelcomeVideo(): Promise<{ data: { code: number; data: null; message: string } }> {
|
|
return apiClient.delete('/admin/welcome-video')
|
|
}
|
|
|
|
// ==========================================================================
|
|
// 预设主题颜色映射
|
|
// ==========================================================================
|
|
|
|
export const THEME_COLORS: Record<string, string> = {
|
|
default: '#07C160', // 绿色
|
|
blue: '#1989FA', // 蓝色
|
|
orange: '#E6A23C', // 橙色
|
|
red: '#F56C6C', // 红色
|
|
}
|
|
|
|
export const THEME_LABELS: Record<string, string> = {
|
|
default: '默认绿色',
|
|
blue: '商务蓝色',
|
|
orange: '活力橙色',
|
|
red: '热情红色',
|
|
}
|