Commit e6508226 authored by 王玉鑫's avatar 王玉鑫

feat: 我的园区401跳首页

parent dbc68277
......@@ -21,14 +21,17 @@ export function useDetail<T>(url: RequestUrl) {
const initDetail = async () => {
try {
const { success, msg, data } = await requestDetail();
const result = await requestDetail();
const { success, msg, data } = result;
if (success) {
detail.value = data;
} else {
message.error(msg || '请求失败');
}
return result;
} catch (error) {
console.log(error);
return Promise.reject(error);
}
};
......
......@@ -2,10 +2,11 @@ import { useQueryList } from '@/composable/useQueryList.ts';
import { ref, type Ref, watchEffect, nextTick, type ShallowRef, computed } from 'vue';
import { RequestUrl } from '@/types/api.ts';
import type { CommonListResp, CommonListParams } from '@/types/common';
import type { RouteName } from '@/router/router.ts';
import { RouteName } from '@/router/router.ts';
import { useRoute, onBeforeRouteLeave } from 'vue-router';
import { useSearchParamsStore } from '@/stores/searchParams.ts';
import { cloneDeep, isEmpty } from 'lodash-es';
import { handleNoAuth } from '@/utils/tools.ts';
import { useRequest } from './useRequest.ts';
import { useJump } from './useJump.ts';
......@@ -74,10 +75,10 @@ export function useListView<
isRequesting.value = b;
};
watchEffect(async () => {
const callQuery = async () => {
try {
changeIsRequesting(true);
const { data } = await queryList(
const { data, code } = await queryList(
{
...searchParams.value,
...otherParams.value,
......@@ -86,11 +87,16 @@ export function useListView<
);
handleUrlClear();
datas.value = data.records;
handleNoAuth(code);
} catch (error) {
console.log(error);
} finally {
changeIsRequesting(false);
}
};
watchEffect(() => {
callQuery();
});
/**
......@@ -142,6 +148,7 @@ export function useListView<
isRequesting,
haveSearchParams,
queryList,
callQuery,
handleDetail,
initPagination,
handleFilterChange,
......
import router, { RouteName } from '@/router/router.ts';
export const heightLight = (str: string, key: string) => {
const reg = new RegExp(key, 'ig');
return str.replace(reg, (val) => {
return `<span style="color: #C0322B;line-height: 25px;background: rgba(192,50,43,0.06);display: inline-block;">${val}</span>`;
});
};
export const handleNoAuth = (code: number) => {
if (code === 401) {
router.replace({
name: RouteName.home,
});
}
};
......@@ -136,6 +136,7 @@ import { filterAddress, formatNumber } from '@/utils/filters.ts';
import { useJump } from '@/composable/useJump.ts';
import { RouteName } from '@/router/router.ts';
import { useIndustryBase } from '@/composable/useIndustryBase.ts';
import { handleNoAuth } from '@/utils/tools.ts';
const { detail, initDetail } = useDetail<MyParkDevelopDetailResp>(RequestUrl.myParkDevelopDetail);
const { router } = useJump();
......@@ -536,5 +537,7 @@ const handleBack = () => {
});
};
initDetail();
initDetail().then(({ code }) => {
handleNoAuth(code);
});
</script>
......@@ -138,6 +138,7 @@ import { filterAddress, formatNumber } from '@/utils/filters.ts';
import { useJump } from '@/composable/useJump.ts';
import { RouteName } from '@/router/router.ts';
import { useIndustryBase } from '@/composable/useIndustryBase.ts';
import { handleNoAuth } from '@/utils/tools.ts';
const { detail, initDetail } = useDetail<MyParkIndustrialDetailResp>(
RequestUrl.myParkIndustrialDetail,
......@@ -504,5 +505,7 @@ const handleBack = () => {
});
};
initDetail();
initDetail().then(({ code }) => {
handleNoAuth(code);
});
</script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment