feat: init

This commit is contained in:
ygx
2026-03-05 23:45:39 +08:00
commit 8fab91c5c7
214 changed files with 33682 additions and 0 deletions

22
src/api/dashboard.ts Normal file
View File

@@ -0,0 +1,22 @@
import type { TableData } from '@arco-design/web-vue/es/table/interface'
import axios from 'axios'
export interface ContentDataRecord {
x: string
y: number
}
export function queryContentData() {
return axios.get<ContentDataRecord[]>('/api/content-data')
}
export interface PopularRecord {
key: number
clickNumber: string
title: string
increases: number
}
export function queryPopularList(params: { type: string }) {
return axios.get<TableData[]>('/api/popular/list', { params })
}

72
src/api/interceptor.ts Normal file
View File

@@ -0,0 +1,72 @@
import { useUserStore } from '@/store'
import { getToken } from '@/utils/auth'
import { Message, Modal } from '@arco-design/web-vue'
import axios from 'axios'
export interface HttpResponse<T = unknown> {
status: number
msg: string
code: number
data: T
}
if (import.meta.env.VITE_API_BASE_URL) {
axios.defaults.baseURL = import.meta.env.VITE_API_BASE_URL
}
axios.interceptors.request.use(
(config: any) => {
// let each request carry token
// this example using the JWT token
// Authorization is a custom headers key
// please modify it according to the actual situation
const token = getToken()
if (token) {
if (!config.headers) {
config.headers = {}
}
config.headers.Authorization = `Bearer ${token}`
}
return config
},
(error) => {
// do something
return Promise.reject(error)
}
)
// add response interceptors
axios.interceptors.response.use(
(response: any) => {
const res = response.data
// if the custom code is not 20000, it is judged as an error.
if (res.code !== 20000) {
Message.error({
content: res.msg || 'Error',
duration: 5 * 1000,
})
// 50008: Illegal token; 50012: Other clients logged in; 50014: Token expired;
if ([50008, 50012, 50014].includes(res.code) && response.config.url !== '/api/user/info') {
Modal.error({
title: 'Confirm logout',
content: 'You have been logged out, you can cancel to stay on this page, or log in again',
okText: 'Re-Login',
async onOk() {
const userStore = useUserStore()
await userStore.logout()
window.location.reload()
},
})
}
return Promise.reject(new Error(res.msg || 'Error'))
}
return res
},
(error) => {
Message.error({
content: error.msg || 'Request Error',
duration: 5 * 1000,
})
return Promise.reject(error)
}
)

56
src/api/list.ts Normal file
View File

@@ -0,0 +1,56 @@
import type { DescData } from '@arco-design/web-vue/es/descriptions/interface'
import axios from 'axios'
import qs from 'query-string'
export interface PolicyRecord {
id: string
number: number
name: string
contentType: 'img' | 'horizontalVideo' | 'verticalVideo'
filterType: 'artificial' | 'rules'
count: number
status: 'online' | 'offline'
createdTime: string
}
export interface PolicyParams extends Partial<PolicyRecord> {
current: number
pageSize: number
}
export interface PolicyListRes {
list: PolicyRecord[]
total: number
}
export function queryPolicyList(params: PolicyParams) {
return axios.get<PolicyListRes>('/api/list/policy', {
params,
paramsSerializer: (obj) => {
return qs.stringify(obj)
},
})
}
export interface ServiceRecord {
id: number
title: string
description: string
name?: string
actionType?: string
icon?: string
data?: DescData[]
enable?: boolean
expires?: boolean
}
export function queryInspectionList() {
return axios.get('/api/list/quality-inspection')
}
export function queryTheServiceList() {
return axios.get('/api/list/the-service')
}
export function queryRulesPresetList() {
return axios.get('/api/list/rules-preset')
}

38
src/api/message.ts Normal file
View File

@@ -0,0 +1,38 @@
import axios from 'axios'
export interface MessageRecord {
id: number
type: string
title: string
subTitle: string
avatar?: string
content: string
time: string
status: 0 | 1
messageType?: number
}
export type MessageListType = MessageRecord[]
export function queryMessageList() {
return axios.post<MessageListType>('/api/message/list')
}
interface MessageStatus {
ids: number[]
}
export function setMessageStatus(data: MessageStatus) {
return axios.post<MessageListType>('/api/message/read', data)
}
export interface ChatRecord {
id: number
username: string
content: string
time: string
isCollect: boolean
}
export function queryChatList() {
return axios.post<ChatRecord[]>('/api/chat/list')
}

49
src/api/profile.ts Normal file
View File

@@ -0,0 +1,49 @@
import axios from 'axios'
export interface ProfileBasicRes {
status: number
video: {
mode: string
acquisition: {
resolution: string
frameRate: number
}
encoding: {
resolution: string
rate: {
min: number
max: number
default: number
}
frameRate: number
profile: string
}
}
audio: {
mode: string
acquisition: {
channels: number
}
encoding: {
channels: number
rate: number
profile: string
}
}
}
export function queryProfileBasic() {
return axios.get<ProfileBasicRes>('/api/profile/basic')
}
export type operationLogRes = Array<{
key: string
contentNumber: string
updateContent: string
status: number
updateTime: string
}>
export function queryOperationLog() {
return axios.get<operationLogRes>('/api/operation/log')
}

88
src/api/user-center.ts Normal file
View File

@@ -0,0 +1,88 @@
import axios from 'axios'
export interface MyProjectRecord {
id: number
name: string
description: string
peopleNumber: number
contributors: {
name: string
email: string
avatar: string
}[]
}
export function queryMyProjectList() {
return axios.post('/api/user/my-project/list')
}
export interface MyTeamRecord {
id: number
avatar: string
name: string
peopleNumber: number
}
export function queryMyTeamList() {
return axios.post('/api/user/my-team/list')
}
export interface LatestActivity {
id: number
title: string
description: string
avatar: string
}
export function queryLatestActivity() {
return axios.post<LatestActivity[]>('/api/user/latest-activity')
}
export function saveUserInfo() {
return axios.post('/api/user/save-info')
}
export interface BasicInfoModel {
email: string
nickname: string
countryRegion: string
area: string
address: string
profile: string
}
export interface EnterpriseCertificationModel {
accountType: number
status: number
time: string
legalPerson: string
certificateType: string
authenticationNumber: string
enterpriseName: string
enterpriseCertificateType: string
organizationCode: string
}
export type CertificationRecord = Array<{
certificationType: number
certificationContent: string
status: number
time: string
}>
export interface UnitCertification {
enterpriseInfo: EnterpriseCertificationModel
record: CertificationRecord
}
export function queryCertification() {
return axios.post<UnitCertification>('/api/user/certification')
}
export function userUploadApi(
data: FormData,
config: {
controller: AbortController
onUploadProgress?: (progressEvent: any) => void
}
) {
// const controller = new AbortController();
return axios.post('/api/user/upload', data, config)
}

27
src/api/user.ts Normal file
View File

@@ -0,0 +1,27 @@
import { UserState } from '@/store/modules/user/types'
import axios from 'axios'
import type { RouteRecordNormalized } from 'vue-router'
export interface LoginData {
username: string
password: string
}
export interface LoginRes {
token: string
}
export function login(data: LoginData) {
return axios.post<LoginRes>('/api/user/login', data)
}
export function logout() {
return axios.post<LoginRes>('/api/user/logout')
}
export function getUserInfo() {
return axios.post<UserState>('/api/user/info')
}
export function getMenuList() {
return axios.post<RouteRecordNormalized[]>('/api/user/menu')
}

70
src/api/visualization.ts Normal file
View File

@@ -0,0 +1,70 @@
import axios from 'axios'
import { GeneralChart } from '@/types/global'
export interface ChartDataRecord {
x: string
y: number
name: string
}
export interface DataChainGrowth {
quota: string
}
export interface DataChainGrowthRes {
count: number
growth: number
chartData: {
xAxis: string[]
data: { name: string; value: number[] }
}
}
export function queryDataChainGrowth(data: DataChainGrowth) {
return axios.post<DataChainGrowthRes>('/api/data-chain-growth', data)
}
export interface PopularAuthorRes {
list: {
ranking: number
author: string
contentCount: number
clickCount: number
}[]
}
export function queryPopularAuthor() {
return axios.get<PopularAuthorRes>('/api/popular-author/list')
}
export interface ContentPublishRecord {
x: string[]
y: number[]
name: string
}
export function queryContentPublish() {
return axios.get<ContentPublishRecord[]>('/api/content-publish')
}
export function queryContentPeriodAnalysis() {
return axios.post<GeneralChart>('/api/content-period-analysis')
}
export interface PublicOpinionAnalysis {
quota: string
}
export interface PublicOpinionAnalysisRes {
count: number
growth: number
chartData: ChartDataRecord[]
}
export function queryPublicOpinionAnalysis(data: DataChainGrowth) {
return axios.post<PublicOpinionAnalysisRes>('/api/public-opinion-analysis', data)
}
export interface DataOverviewRes {
xAxis: string[]
data: Array<{ name: string; value: number[]; count: number }>
}
export function queryDataOverview() {
return axios.post<DataOverviewRes>('/api/data-overview')
}