import { DesktopAppTypeEnum, LightApp, UserSettingInfo, WidgetCatalog, WidgetPositionResp } from "@/types"; import { BaseDict, PageData, PageParams } from "@/types/Basics"; import Abstract from "@/utils/axios/abstract"; const path = "/api"; class UserSettings extends Abstract { getUserWallpaperList(schId: number) { const url = path + "/getUserWallpaperList"; return this.getRequest({ url, params: { schId } }); } deleteWallById(id: number) { const url = path + "/deleteWallById"; return this.postRequest({ url, params: { id } }); } checkWallpaper(schId: number, wallpaperUrl: string) { const url = path + "/checkWallpaper"; return this.postRequest({ url, data: { schId, wallpaperUrl } }); } getLogoList() { const url = path + "/getLogoList"; return this.getRequest({ url }); } deleteLogoById(id: number) { const url = path + "/deleteLogoById"; return this.postRequest({ url, params: { id } }); } getUserSettings() { const url = path + "/getUserSettings"; return this.getRequest({ url }); } toggleWidgetShow(id?: number) { const url = path + "/toggleWidgetShow"; return this.postRequest({ url, data: { id } }); } saveUserWidget(info: WidgetPositionResp) { const url = path + "/saveUserWidget"; return this.postRequest({ url, data: info as any }); } saveUserAppIds(id: number | undefined, appIds: string) { const url = path + "/saveUserAppIds"; return this.postRequest({ url, data: { id, appIds } }); } getLightAppSel() { const url = path + "/getLightAppGroup"; return this.getRequest({ url }); } getLightAppList(): Promise { const url = path + "/getLightAppList"; return new Promise(async (resolve, reject) => { let result: any[] = await this.getRequest({ url }); result.forEach(element => { if (!!element.layout) element.layout = JSON.parse(element.layout); }); resolve(result); }); } saveLightApp(lightapp: LightApp) { const url = path + "/saveLightApp"; lightapp.layout = JSON.stringify(lightapp.layout); return this.postRequest({ url, data: lightapp as any }); } deleteLightAppById(id: number) { const url = path + "/deleteLightAppById"; return this.postRequest({ url, params: { id } }); } getUserDesktopAppList() { const url = path + "/getUserDesktopAppList"; return this.getRequest({ url }); } saveUserDesktopAppById(appId: number, type: DesktopAppTypeEnum) { const url = path + "/saveUserDesktopAppById"; return this.postRequest({ url, data: { id: appId, type } }); } deleteUserDesktopAppById(id: number, appId: number) { const url = path + "/deleteDesktopAppById"; return this.postRequest({ url, data: { id, appId } }); } sortUserDesktopApp(ids: number[]) { const url = path + "/sortUserDesktopApp"; return this.postRequest({ url, data: { ids: ids.join(",") } }); } /** 小组件统一取数:params 为 urlencoded 查询串(对齐旧 otherParams 口径) */ getWidgetData(code: string, params: string) { const url = path + "/getWidgetData"; return this.getRequest({ url, params: { code: code, params: params } }); } /** 仅 comp_type=2:按需取自定义片段内容 */ getWidgetContent(code: string) { const url = path + "/getWidgetContent"; return this.getRequest({ url, params: { code: code } }); } getWidgetCatalogList() { const url = path + "/GetWidgetCatalogList"; return this.getRequest({ url }); } /** 新增/编辑全局目录(仅超管):scopeType/roleTypes/roleAlias/scopeSchIds 一并提交 */ saveWidgetCatalog(catalog: Partial & Record) { const url = path + "/SaveWidgetCatalog"; return this.postRequest({ url, data: catalog }); } /** 删除全局目录(仅超管),后端连带删点名表与校级覆盖行 */ deleteWidgetCatalog(id: number) { const url = path + "/DeleteWidgetCatalog"; return this.postRequest({ url, params: { id } }); } /** 读本校覆盖行(编辑回显):schId 由后端取当前登录校 */ getWidgetSchoolSetting(widgetId: number) { const url = path + "/GetWidgetSchoolSetting"; return this.getRequest({ url, params: { widgetId } }); } /** 保存本校覆盖(校管/超管):schId 由后端强制取当前登录校,前端不传 */ saveWidgetSchoolSetting(setting: Record) { const url = path + "/SaveWidgetSchoolSetting"; return this.postRequest({ url, data: setting }); } /** 机构树(仅超管):递归裁剪到学校层,children 即学校列表,用于可见范围多选 */ getSchTree() { const url = path + "/getSchTree"; return this.getRequest({ url }); } } export default new UserSettings();