fix(sj_1.1.0_beta1): 修复toString()空指针问题

This commit is contained in:
xlsea 2024-06-15 10:39:12 +08:00
parent 3795b552ac
commit c1f9be990b
12 changed files with 26 additions and 26 deletions

View File

@ -49,7 +49,7 @@ const fields = computed(() => {
// }); // });
const previewLabel = computed(() => { const previewLabel = computed(() => {
return Locales[props.lang].preview.join(previewTime.value.toString()); return Locales[props.lang].preview.join(previewTime.value?.toString());
}); });
const expression = computed(() => { const expression = computed(() => {

View File

@ -31,7 +31,7 @@ const value = computed({
}); });
const formatter = (val: number) => { const formatter = (val: number) => {
return props.fieldValue === WEEK ? formatterWeek(val.toString(), props.locale!) : null; return props.fieldValue === WEEK ? formatterWeek(val?.toString(), props.locale!) : null;
}; };
const parser = (val: string) => { const parser = (val: string) => {

View File

@ -19,7 +19,7 @@ export function generateSpecifies(
let index = 0; let index = 0;
for (let specify = min; specify <= max; specify += 1) { for (let specify = min; specify <= max; specify += 1) {
specifies.push({ value: specify, label: labels ? labels[index] : specify.toString() }); specifies.push({ value: specify, label: labels ? labels[index] : specify?.toString() });
index += 1; index += 1;
} }

View File

@ -11,7 +11,7 @@ export class Crypto<T extends object> {
encrypt(data: T): string { encrypt(data: T): string {
const dataString = JSON.stringify(data); const dataString = JSON.stringify(data);
const encrypted = CryptoJS.AES.encrypt(dataString, this.secret); const encrypted = CryptoJS.AES.encrypt(dataString, this.secret);
return encrypted.toString(); return encrypted?.toString();
} }
decrypt(encrypted: string) { decrypt(encrypted: string) {

View File

@ -113,14 +113,14 @@ onBeforeUnmount(() => {
}); });
function timestampToDate(timestamp: string): string { function timestampToDate(timestamp: string): string {
const date = new Date(Number.parseInt(timestamp.toString(), 10)); const date = new Date(Number.parseInt(timestamp?.toString(), 10));
const year = date.getFullYear(); const year = date.getFullYear();
const month = const month =
(date.getMonth() + 1).toString().length === 1 ? `0${date.getMonth() + 1}` : (date.getMonth() + 1).toString(); (date.getMonth() + 1)?.toString().length === 1 ? `0${date.getMonth() + 1}` : (date.getMonth() + 1)?.toString();
const day = date.getDate().toString().length === 1 ? `0${date.getDate()}` : date.getDate().toString(); const day = date.getDate()?.toString().length === 1 ? `0${date.getDate()}` : date.getDate()?.toString();
const hours = date.getHours().toString().length === 1 ? `0${date.getHours()}` : date.getHours().toString(); const hours = date.getHours()?.toString().length === 1 ? `0${date.getHours()}` : date.getHours()?.toString();
const minutes = date.getMinutes().toString().length === 1 ? `0${date.getMinutes()}` : date.getMinutes().toString(); const minutes = date.getMinutes()?.toString().length === 1 ? `0${date.getMinutes()}` : date.getMinutes()?.toString();
const seconds = date.getSeconds().toString().length === 1 ? `0${date.getSeconds()}` : date.getSeconds().toString(); const seconds = date.getSeconds()?.toString().length === 1 ? `0${date.getSeconds()}` : date.getSeconds()?.toString();
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}.${date.getMilliseconds()}`; return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}.${date.getMilliseconds()}`;
} }
</script> </script>

View File

@ -148,7 +148,7 @@ const showDetail = (item: Flow.ConditionNodeType, index: number) => {
if (job.id) { if (job.id) {
detailIds.value?.push(job.id); detailIds.value?.push(job.id);
} else if (job.jobId) { } else if (job.jobId) {
detailId.value = job.jobId.toString(); detailId.value = job.jobId?.toString();
} }
}); });
if (detailIds.value.length === 0) { if (detailIds.value.length === 0) {

View File

@ -92,7 +92,7 @@ const showDetail = (item: Flow.ConditionNodeType, index: number) => {
if (job.id) { if (job.id) {
detailIds.value?.push(job.id); detailIds.value?.push(job.id);
} else if (job.jobId) { } else if (job.jobId) {
detailId.value = job.jobId.toString(); detailId.value = job.jobId?.toString();
} }
}); });
if (detailIds.value.length === 0) { if (detailIds.value.length === 0) {

View File

@ -141,11 +141,11 @@ const showDetail = (node: Flow.ConditionNodeType, detailIndex: number) => {
if (item.id) { if (item.id) {
detailIds.value?.push(item.id); detailIds.value?.push(item.id);
} else if (item.jobId) { } else if (item.jobId) {
detailId.value = item.jobId.toString(); detailId.value = item.jobId?.toString();
} }
}); });
if (node.jobTask?.jobId) { if (node.jobTask?.jobId) {
detailId.value = node.jobTask?.jobId.toString(); detailId.value = node.jobTask?.jobId?.toString();
} }
cardDrawer.value = true; cardDrawer.value = true;
} else if (store.type === 1) { } else if (store.type === 1) {

View File

@ -27,7 +27,7 @@ export const request = createFlatRequest<Service.Response>(
isBackendSuccess(response) { isBackendSuccess(response) {
// when the backend response code is "0000"(default), it means the request is success // when the backend response code is "0000"(default), it means the request is success
// to change this logic by yourself, you can modify the `VITE_SERVICE_SUCCESS_CODE` in `.env` file // to change this logic by yourself, you can modify the `VITE_SERVICE_SUCCESS_CODE` in `.env` file
return response.data.status.toString() === import.meta.env.VITE_SERVICE_SUCCESS_CODE; return response.data.status?.toString() === import.meta.env.VITE_SERVICE_SUCCESS_CODE;
}, },
transformBackendResponse(response) { transformBackendResponse(response) {
return response.data.total ? response.data : response.data.data; return response.data.total ? response.data : response.data.data;
@ -41,7 +41,7 @@ export const request = createFlatRequest<Service.Response>(
// get backend error message and code // get backend error message and code
if (error.code === BACKEND_ERROR_CODE) { if (error.code === BACKEND_ERROR_CODE) {
msg = error.response?.data?.message || msg; msg = error.response?.data?.message || msg;
backendErrorCode = error.response?.data?.status.toString() || ''; backendErrorCode = error.response?.data?.status?.toString() || '';
} }
// the error message is displayed in the modal // the error message is displayed in the modal

View File

@ -68,14 +68,14 @@ const onUpdateShow = (value: boolean) => {
}; };
function timestampToDate(timestamp: string): string { function timestampToDate(timestamp: string): string {
const date = new Date(Number.parseInt(timestamp.toString(), 10)); const date = new Date(Number.parseInt(timestamp?.toString(), 10));
const year = date.getFullYear(); const year = date.getFullYear();
const month = const month =
(date.getMonth() + 1).toString().length === 1 ? `0${date.getMonth() + 1}` : (date.getMonth() + 1).toString(); (date.getMonth() + 1)?.toString().length === 1 ? `0${date.getMonth() + 1}` : (date.getMonth() + 1)?.toString();
const day = date.getDate().toString().length === 1 ? `0${date.getDate()}` : date.getDate().toString(); const day = date.getDate()?.toString().length === 1 ? `0${date.getDate()}` : date.getDate()?.toString();
const hours = date.getHours().toString().length === 1 ? `0${date.getHours()}` : date.getHours().toString(); const hours = date.getHours()?.toString().length === 1 ? `0${date.getHours()}` : date.getHours()?.toString();
const minutes = date.getMinutes().toString().length === 1 ? `0${date.getMinutes()}` : date.getMinutes().toString(); const minutes = date.getMinutes()?.toString().length === 1 ? `0${date.getMinutes()}` : date.getMinutes()?.toString();
const seconds = date.getSeconds().toString().length === 1 ? `0${date.getSeconds()}` : date.getSeconds().toString(); const seconds = date.getSeconds()?.toString().length === 1 ? `0${date.getSeconds()}` : date.getSeconds()?.toString();
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}.${date.getMilliseconds()}`; return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}.${date.getMilliseconds()}`;
} }
</script> </script>

View File

@ -52,14 +52,14 @@ export const request = createFlatRequest<App.Service.Response, RequestInstanceSt
// when the backend response code is in `logoutCodes`, it means the user will be logged out and redirected to login page // when the backend response code is in `logoutCodes`, it means the user will be logged out and redirected to login page
const logoutCodes = import.meta.env.VITE_SERVICE_LOGOUT_CODES?.split(',') || []; const logoutCodes = import.meta.env.VITE_SERVICE_LOGOUT_CODES?.split(',') || [];
if (logoutCodes.includes(response.data.status.toString())) { if (logoutCodes.includes(response.data.status?.toString())) {
handleLogout(); handleLogout();
return null; return null;
} }
// when the backend response code is in `modalLogoutCodes`, it means the user will be logged out by displaying a modal // when the backend response code is in `modalLogoutCodes`, it means the user will be logged out by displaying a modal
const modalLogoutCodes = import.meta.env.VITE_SERVICE_MODAL_LOGOUT_CODES?.split(',') || []; const modalLogoutCodes = import.meta.env.VITE_SERVICE_MODAL_LOGOUT_CODES?.split(',') || [];
if (modalLogoutCodes.includes(response.data.status.toString())) { if (modalLogoutCodes.includes(response.data.status?.toString())) {
request.state.errMsgStack = [...(request.state.errMsgStack || []), response.data.message]; request.state.errMsgStack = [...(request.state.errMsgStack || []), response.data.message];
// prevent the user from refreshing the page // prevent the user from refreshing the page
@ -116,7 +116,7 @@ export const request = createFlatRequest<App.Service.Response, RequestInstanceSt
// get backend error message and code // get backend error message and code
message = error.response?.data?.message || message; message = error.response?.data?.message || message;
backendErrorCode = error.response?.data?.status.toString() || ''; backendErrorCode = error.response?.data?.status?.toString() || '';
// the error message is displayed in the modal // the error message is displayed in the modal
const modalLogoutCodes = import.meta.env.VITE_SERVICE_MODAL_LOGOUT_CODES?.split(',') || []; const modalLogoutCodes = import.meta.env.VITE_SERVICE_MODAL_LOGOUT_CODES?.split(',') || [];

View File

@ -37,7 +37,7 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => {
const isStaticSuper = computed(() => { const isStaticSuper = computed(() => {
const { VITE_AUTH_ROUTE_MODE, VITE_STATIC_SUPER_ROLE } = import.meta.env; const { VITE_AUTH_ROUTE_MODE, VITE_STATIC_SUPER_ROLE } = import.meta.env;
return ( return (
VITE_AUTH_ROUTE_MODE === 'static' && userInfo.roles.map(role => role.toString()).includes(VITE_STATIC_SUPER_ROLE) VITE_AUTH_ROUTE_MODE === 'static' && userInfo.roles.map(role => role?.toString()).includes(VITE_STATIC_SUPER_ROLE)
); );
}); });