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

feat: 我的园区401跳首页

parent dbc68277
...@@ -21,14 +21,17 @@ export function useDetail<T>(url: RequestUrl) { ...@@ -21,14 +21,17 @@ export function useDetail<T>(url: RequestUrl) {
const initDetail = async () => { const initDetail = async () => {
try { try {
const { success, msg, data } = await requestDetail(); const result = await requestDetail();
const { success, msg, data } = result;
if (success) { if (success) {
detail.value = data; detail.value = data;
} else { } else {
message.error(msg || '请求失败'); message.error(msg || '请求失败');
} }
return result;
} catch (error) { } catch (error) {
console.log(error); console.log(error);
return Promise.reject(error);
} }
}; };
......
...@@ -2,10 +2,11 @@ import { useQueryList } from '@/composable/useQueryList.ts'; ...@@ -2,10 +2,11 @@ import { useQueryList } from '@/composable/useQueryList.ts';
import { ref, type Ref, watchEffect, nextTick, type ShallowRef, computed } from 'vue'; import { ref, type Ref, watchEffect, nextTick, type ShallowRef, computed } from 'vue';
import { RequestUrl } from '@/types/api.ts'; import { RequestUrl } from '@/types/api.ts';
import type { CommonListResp, CommonListParams } from '@/types/common'; 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 { useRoute, onBeforeRouteLeave } from 'vue-router';
import { useSearchParamsStore } from '@/stores/searchParams.ts'; import { useSearchParamsStore } from '@/stores/searchParams.ts';
import { cloneDeep, isEmpty } from 'lodash-es'; import { cloneDeep, isEmpty } from 'lodash-es';
import { handleNoAuth } from '@/utils/tools.ts';
import { useRequest } from './useRequest.ts'; import { useRequest } from './useRequest.ts';
import { useJump } from './useJump.ts'; import { useJump } from './useJump.ts';
...@@ -74,10 +75,10 @@ export function useListView< ...@@ -74,10 +75,10 @@ export function useListView<
isRequesting.value = b; isRequesting.value = b;
}; };
watchEffect(async () => { const callQuery = async () => {
try { try {
changeIsRequesting(true); changeIsRequesting(true);
const { data } = await queryList( const { data, code } = await queryList(
{ {
...searchParams.value, ...searchParams.value,
...otherParams.value, ...otherParams.value,
...@@ -86,11 +87,16 @@ export function useListView< ...@@ -86,11 +87,16 @@ export function useListView<
); );
handleUrlClear(); handleUrlClear();
datas.value = data.records; datas.value = data.records;
handleNoAuth(code);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} finally { } finally {
changeIsRequesting(false); changeIsRequesting(false);
} }
};
watchEffect(() => {
callQuery();
}); });
/** /**
...@@ -142,6 +148,7 @@ export function useListView< ...@@ -142,6 +148,7 @@ export function useListView<
isRequesting, isRequesting,
haveSearchParams, haveSearchParams,
queryList, queryList,
callQuery,
handleDetail, handleDetail,
initPagination, initPagination,
handleFilterChange, handleFilterChange,
......
import router, { RouteName } from '@/router/router.ts';
export const heightLight = (str: string, key: string) => { export const heightLight = (str: string, key: string) => {
const reg = new RegExp(key, 'ig'); const reg = new RegExp(key, 'ig');
return str.replace(reg, (val) => { 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>`; 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'; ...@@ -136,6 +136,7 @@ import { filterAddress, formatNumber } from '@/utils/filters.ts';
import { useJump } from '@/composable/useJump.ts'; import { useJump } from '@/composable/useJump.ts';
import { RouteName } from '@/router/router.ts'; import { RouteName } from '@/router/router.ts';
import { useIndustryBase } from '@/composable/useIndustryBase.ts'; import { useIndustryBase } from '@/composable/useIndustryBase.ts';
import { handleNoAuth } from '@/utils/tools.ts';
const { detail, initDetail } = useDetail<MyParkDevelopDetailResp>(RequestUrl.myParkDevelopDetail); const { detail, initDetail } = useDetail<MyParkDevelopDetailResp>(RequestUrl.myParkDevelopDetail);
const { router } = useJump(); const { router } = useJump();
...@@ -536,5 +537,7 @@ const handleBack = () => { ...@@ -536,5 +537,7 @@ const handleBack = () => {
}); });
}; };
initDetail(); initDetail().then(({ code }) => {
handleNoAuth(code);
});
</script> </script>
...@@ -138,6 +138,7 @@ import { filterAddress, formatNumber } from '@/utils/filters.ts'; ...@@ -138,6 +138,7 @@ import { filterAddress, formatNumber } from '@/utils/filters.ts';
import { useJump } from '@/composable/useJump.ts'; import { useJump } from '@/composable/useJump.ts';
import { RouteName } from '@/router/router.ts'; import { RouteName } from '@/router/router.ts';
import { useIndustryBase } from '@/composable/useIndustryBase.ts'; import { useIndustryBase } from '@/composable/useIndustryBase.ts';
import { handleNoAuth } from '@/utils/tools.ts';
const { detail, initDetail } = useDetail<MyParkIndustrialDetailResp>( const { detail, initDetail } = useDetail<MyParkIndustrialDetailResp>(
RequestUrl.myParkIndustrialDetail, RequestUrl.myParkIndustrialDetail,
...@@ -504,5 +505,7 @@ const handleBack = () => { ...@@ -504,5 +505,7 @@ const handleBack = () => {
}); });
}; };
initDetail(); initDetail().then(({ code }) => {
handleNoAuth(code);
});
</script> </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