Selaa lähdekoodia

fix:修改轮播图渠道接口

zhubo 2 vuotta sitten
vanhempi
commit
1993d8b1fb
3 muutettua tiedostoa jossa 18 lisäystä ja 6 poistoa
  1. 6 4
      src/models/user.ts
  2. 4 2
      src/pages/setting/banner/index.tsx
  3. 8 0
      src/services/role.ts

+ 6 - 4
src/models/user.ts

@@ -2,7 +2,7 @@ import type { Effect, Reducer } from 'umi';
 
 import { queryCurrent, query as queryUsers } from '@/services/user';
 
-import { getRoleList } from '@/services/role';
+import { getRoleList, getRoleListNew } from '@/services/role';
 
 export type CurrentUser = {
   avatar?: string;
@@ -69,11 +69,11 @@ const UserModel: UserModelType = {
     *getRoleList(_, { call, put }) {
       const { payload, callback } = _;
 
-      const r = yield call(getRoleList, payload);
+      const r = yield call(getRoleListNew, payload);
 
       yield put({
         type: 'saveRoleList',
-        payload: r.data.records,
+        payload: r.data,
       });
 
       callback();
@@ -85,7 +85,9 @@ const UserModel: UserModelType = {
      * @description 保存权限列表
      */
     saveRoleList(state, action) {
-      let newState = { ...state, roleList: action.payload.slice(1) || [] };
+      console.log(action, 'action');
+
+      let newState = { ...state, roleList: action.payload || [] };
       return newState;
     },
 

+ 4 - 2
src/pages/setting/banner/index.tsx

@@ -91,7 +91,7 @@ const Banner: React.FC<IProps> = ({ roleList, dispatch }) => {
     bannerList: [],
   });
 
-  const [roleId, setRoleId] = useState<string>('');
+  const [roleId, setRoleId] = useState<string>();
 
   const { visible, bannerList, loading, modalVisible } = state;
 
@@ -108,9 +108,11 @@ const Banner: React.FC<IProps> = ({ roleList, dispatch }) => {
 
   // 设置默认的roleId
   useEffect(() => {
+    console.log(roleList, 'roleList');
+
     if (roleList.length === 0) return;
 
-    setRoleId(roleList[0].id);
+    setRoleId(roleList[0].id.toString());
   }, [roleList]);
 
   useEffect(() => {

+ 8 - 0
src/services/role.ts

@@ -4,10 +4,18 @@ import { role } from '@/types/role';
 type getRoleListType = {
   curPage: number;
 };
+// 获取权限列表
 export async function getRoleList(params: getRoleListType): Promise<any> {
   return request('/forum/admin/role', { params });
 }
 
+/**
+ * @description 获取权限列表(新)
+ */
+export async function getRoleListNew(): Promise<any> {
+  return request('/forum/system/config/list/BANNER_NAME_LIST', { method: 'GET' });
+}
+
 //   修改角色名称
 // /forum/admin/role
 export async function putRoleList(data: role): Promise<any> {