diff --git a/src/api/github.ts b/src/api/github.ts index 4e19e71..92160e6 100644 --- a/src/api/github.ts +++ b/src/api/github.ts @@ -11,15 +11,15 @@ const cutToken = 'ghp_qpV8PUxwY7as4jc' const reader = new FileReader() function getBase64(file: File) { return new Promise((resolve) => { - reader.onload = function (event: any) { - const fileContent = event.target.result - resolve(fileContent.split(',')[1]) + reader.onload = function (event) { + const fileContent = event.target && event.target.result + resolve((fileContent as string).split(',')[1]) } reader.readAsDataURL(file) }) } -const putPic = async (file: any) => { +const putPic = async (file: File) => { const repo = 'shawnphang/files' const d = new Date() const content = typeof file === 'string' ? file : await getBase64(file) diff --git a/src/api/home.ts b/src/api/home.ts index 1532edf..8dd3639 100644 --- a/src/api/home.ts +++ b/src/api/home.ts @@ -41,12 +41,12 @@ type IGetTempListResult = TPageRequestResult // 获取模板列表 export const getTempList = (params: IGetTempListParam) => fetch('design/list', params, 'get') -type TGetTempDetail = { +export type TGetTempDetail = { id: number type?: number } -type TTempDetail = { +export type TTempDetail = { /** 分类 */ category: number /** 封面 */ @@ -93,7 +93,7 @@ type TGetCompListParam = { page?: number type?: number pageSize: number - cate: number + cate?: number | string } /** 获取组件返回类型 */ @@ -104,13 +104,19 @@ export type TGetCompListResult = { state: number title: string width: number + name?: string } type getCompListReturn = TPageRequestResult // 组件相关接口 export const getCompList = (params: TGetCompListParam) => fetch('design/list', params, 'get') -export const removeComp = (params: Type.Object = {}) => fetch('design/del', params, 'post') + +type TRemoveComp = { + id: string | number +} + +export const removeComp = (params: TRemoveComp) => fetch('design/del', params, 'post') // export const getCompDetail = (params: Type.Object = {}) => fetch('/api/template/temp_info', params, 'get') // 保存作品 diff --git a/src/components/modules/panel/wrap/CompListWrap.vue b/src/components/modules/panel/wrap/CompListWrap.vue index b20c423..270e0be 100644 --- a/src/components/modules/panel/wrap/CompListWrap.vue +++ b/src/components/modules/panel/wrap/CompListWrap.vue @@ -15,183 +15,212 @@ 推荐组件 --> - + -
    - {{ currentCategory.name }} +
      + {{ state.currentCategory.name }} -
      +
      -
      拼命加载中
      -
      全部加载完毕
      +
      拼命加载中
      +
      全部加载完毕
    -