为什么:超管点进创作者中心原本是一片"未绑定创作者主体"的报错,既没说明原因也没有出路。 这批把两件事做出来:超管能在顶部选一个创作者只读代看;没有创作者身份的账号看到明确的引导页而不是白屏。 - 新增 useCreatorAccess(身份三态:granted / need-target / unbound)+ ImpersonationBar + CreatorAccessGuide, 四个页面用 CreatorCenterPage 统一套壳;身份不满足时不打业务接口,避免一串无意义的报错提示 - 代看目标存 localStorage,由 axios.request 统一给 /admin/creator-center 的请求加 X-Creator-Id 头 (不做查询参数;后端只对具备 impersonate 权限的账号认这个头) - axios 支持 silent 请求:业务码非 0 时不弹全局提示、把 Result 交给调用方判断(引导页据此分流) - 代看只读体验:代看态下「新建作品 / 编辑 / 提交审核 / 撤回」不渲染,编辑页整页禁用并提示原因 - 顶部下拉只在有 impersonate 权限时显示;无权限账号看不到、也不会请求 targets 接口
69 lines
2.0 KiB
TypeScript
69 lines
2.0 KiB
TypeScript
import type { CSSProperties } from 'vue'
|
|
import { RawAxiosRequestHeaders } from 'axios'
|
|
declare global {
|
|
declare interface Fn<T = any> {
|
|
(...arg: T[]): T
|
|
}
|
|
|
|
declare type Nullable<T> = T | null
|
|
|
|
declare type ElRef<T extends HTMLElement = HTMLDivElement> = Nullable<T>
|
|
|
|
declare type Recordable<T = any, K = string> = Record<K extends null | undefined ? string : K, T>
|
|
|
|
declare type RemoveReadonly<T> = {
|
|
-readonly [P in keyof T]: T[P]
|
|
}
|
|
|
|
declare type ComponentRef<T> = InstanceType<T>
|
|
|
|
declare type LocaleType = 'zh-CN' | 'en'
|
|
|
|
declare type TimeoutHandle = ReturnType<typeof setTimeout>
|
|
declare type IntervalHandle = ReturnType<typeof setInterval>
|
|
|
|
declare type ElementPlusInfoType = 'success' | 'info' | 'warning' | 'danger'
|
|
|
|
declare type LayoutType = 'classic' | 'topLeft' | 'top' | 'cutMenu'
|
|
|
|
declare type AxiosContentType =
|
|
'application/json' | 'application/x-www-form-urlencoded' | 'multipart/form-data' | 'text/plain'
|
|
|
|
declare type AxiosMethod = 'get' | 'post' | 'delete' | 'put'
|
|
|
|
declare type AxiosResponseType = 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'
|
|
|
|
declare interface AxiosConfig {
|
|
params?: any
|
|
data?: any
|
|
url?: string
|
|
method?: AxiosMethod
|
|
headers?: RawAxiosRequestHeaders
|
|
responseType?: AxiosResponseType
|
|
/** 静默请求:业务码非 0 时不弹全局提示,并把完整 Result 交给调用方判断 */
|
|
silent?: boolean
|
|
}
|
|
|
|
declare interface IResponse<T = any> {
|
|
code: number
|
|
data: T extends any ? T : T & any
|
|
}
|
|
|
|
declare interface ThemeTypes {
|
|
elColorPrimary?: string
|
|
leftMenuBorderColor?: string
|
|
leftMenuBgColor?: string
|
|
leftMenuBgLightColor?: string
|
|
leftMenuBgActiveColor?: string
|
|
leftMenuCollapseBgActiveColor?: string
|
|
leftMenuTextColor?: string
|
|
leftMenuTextActiveColor?: string
|
|
logoTitleTextColor?: string
|
|
logoBorderColor?: string
|
|
topHeaderBgColor?: string
|
|
topHeaderTextColor?: string
|
|
topHeaderHoverColor?: string
|
|
topToolBorderColor?: string
|
|
}
|
|
}
|