-
Notifications
You must be signed in to change notification settings - Fork 3.2k
feat(system): fix issue with upgrade redirect #8316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,10 @@ | |
| {{ $t('runtime.create') }} | ||
| </el-button> | ||
| </template> | ||
| <template #rightToolBar> | ||
| <TableRefresh @search="search()" /> | ||
| <TableSetting title="dotnet-runtime-refresh" @search="search()" /> | ||
| </template> | ||
| <template #main> | ||
| <ComplexTable :pagination-config="paginationConfig" :data="items" @search="search()"> | ||
| <el-table-column | ||
|
|
@@ -87,7 +91,7 @@ | |
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { onMounted, onUnmounted, reactive, ref, computed } from 'vue'; | ||
| import { onMounted, reactive, ref, computed } from 'vue'; | ||
| import { Runtime } from '@/api/interface/runtime'; | ||
| import { OperateRuntime, RuntimeDeleteCheck, SearchRuntimes, SyncRuntime } from '@/api/modules/runtime'; | ||
| import { dateFormat } from '@/utils/util'; | ||
|
|
@@ -105,7 +109,6 @@ import RuntimeStatus from '@/views/website/runtime/components/runtime-status.vue | |
| import PortJump from '@/views/website/runtime/components/port-jump.vue'; | ||
| import { disabledButton } from '@/utils/runtime'; | ||
|
|
||
| let timer: NodeJS.Timer | null = null; | ||
| const loading = ref(false); | ||
| const items = ref<Runtime.RuntimeDTO[]>([]); | ||
| const operateRef = ref(); | ||
|
|
@@ -250,15 +253,6 @@ const toFolder = (folder: string) => { | |
| onMounted(() => { | ||
| sync(); | ||
| search(); | ||
| timer = setInterval(() => { | ||
| search(); | ||
| sync(); | ||
| }, 1000 * 10); | ||
| }); | ||
|
|
||
| onUnmounted(() => { | ||
| clearInterval(Number(timer)); | ||
| timer = null; | ||
| }); | ||
| </script> | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The provided code makes several changes:
Overall, while these changes improve usability by adding interactive controls and potentially enhancing user experience, there are unnecessary components like |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,10 @@ | |
| {{ $t('runtime.create') }} | ||
| </el-button> | ||
| </template> | ||
| <template #rightToolBar> | ||
| <TableRefresh @search="search()" /> | ||
| <TableSetting title="go-runtime-refresh" @search="search()" /> | ||
| </template> | ||
| <template #main> | ||
| <ComplexTable :pagination-config="paginationConfig" :data="items" @search="search()" :heightDiff="350"> | ||
| <el-table-column | ||
|
|
@@ -87,7 +91,7 @@ | |
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { onMounted, onUnmounted, reactive, ref } from 'vue'; | ||
| import { onMounted, reactive, ref } from 'vue'; | ||
| import { Runtime } from '@/api/interface/runtime'; | ||
| import { OperateRuntime, RuntimeDeleteCheck, SearchRuntimes, SyncRuntime } from '@/api/modules/runtime'; | ||
| import { dateFormat } from '@/utils/util'; | ||
|
|
@@ -109,7 +113,6 @@ const mobile = computed(() => { | |
| return globalStore.isMobile(); | ||
| }); | ||
|
|
||
| let timer: NodeJS.Timer | null = null; | ||
| const loading = ref(false); | ||
| const items = ref<Runtime.RuntimeDTO[]>([]); | ||
| const operateRef = ref(); | ||
|
|
@@ -249,15 +252,6 @@ const toFolder = (folder: string) => { | |
| onMounted(() => { | ||
| sync(); | ||
| search(); | ||
| timer = setInterval(() => { | ||
| search(); | ||
| sync(); | ||
| }, 1000 * 10); | ||
| }); | ||
|
|
||
| onUnmounted(() => { | ||
| clearInterval(Number(timer)); | ||
| timer = null; | ||
| }); | ||
| </script> | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The provided code has no major errors or issues that need correction at this time based on the information up until September 2021. However, there are some areas for improvement:
Here’s an optimized version with these considerations addressed: // Import necessary modules here
const onMounted = () => {
sync();
search();
// Use a debounce function to handle frequent searches
function performSearch() {
// Add your existing search logic here
}
let searchDebounceId: number | null = null;
const delayedSearch = _.debounce(performSearch, 500);
function search() {
searchDebounceId = delayedSearch();
}
// Optionally clear timer when not needed anymore
};
onUnmounted(() => {
clearInterval(searchDebounceId!); // Ensure non-null assertion operator
});
// ... other methods and components ...By implementing a debounce function like lodash's
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code has some slight improvements and necessary corrections:
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,13 +2,7 @@ | |
| <div> | ||
| <RouterMenu /> | ||
| <LayoutContent :title="'PHP'" v-loading="loading"> | ||
| <template #prompt> | ||
| <el-alert type="info" :closable="false"> | ||
| <template #title> | ||
| <span>{{ $t('runtime.systemRestartHelper') }}</span> | ||
| </template> | ||
| </el-alert> | ||
| </template> | ||
| <template #prompt></template> | ||
| <template #leftToolBar> | ||
| <el-button type="primary" @click="openCreate"> | ||
| {{ $t('runtime.create') }} | ||
|
|
@@ -22,6 +16,10 @@ | |
| {{ $t('container.cleanBuildCache') }} | ||
| </el-button> | ||
| </template> | ||
| <template #rightToolBar> | ||
| <TableRefresh @search="search()" /> | ||
| <TableSetting title="php-runtime-refresh" @search="search()" /> | ||
| </template> | ||
| <template #main> | ||
| <ComplexTable :pagination-config="paginationConfig" :data="items" @search="search()" :heightDiff="350"> | ||
| <el-table-column | ||
|
|
@@ -101,15 +99,15 @@ | |
| <Log ref="logRef" @close="search" :heightDiff="280" /> | ||
| <Extensions ref="extensionsRef" @close="search" /> | ||
| <AppResources ref="checkRef" @close="search" /> | ||
| <ExtManagement ref="extManagementRef" @close="search" /> | ||
| <ExtManagement ref="extManagementRef" /> | ||
| <ComposeLogs ref="composeLogRef" /> | ||
| <Config ref="configRef" /> | ||
| <Supervisor ref="supervisorRef" /> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { onMounted, onUnmounted, reactive, ref } from 'vue'; | ||
| import { onMounted, reactive, ref } from 'vue'; | ||
| import { Runtime } from '@/api/interface/runtime'; | ||
| import { DeleteRuntime, OperateRuntime, RuntimeDeleteCheck, SearchRuntimes } from '@/api/modules/runtime'; | ||
| import { dateFormat } from '@/utils/util'; | ||
|
|
@@ -146,7 +144,6 @@ let req = reactive<Runtime.RuntimeReq>({ | |
| pageSize: 40, | ||
| type: 'php', | ||
| }); | ||
| let timer: NodeJS.Timer | null = null; | ||
| const opRef = ref(); | ||
| const logRef = ref(); | ||
| const extensionsRef = ref(); | ||
|
|
@@ -265,7 +262,7 @@ const openLog = (row: Runtime.RuntimeDTO) => { | |
| if (row.status == 'Running') { | ||
| composeLogRef.value.acceptParams({ compose: row.path + '/docker-compose.yml', resource: row.name }); | ||
| } else { | ||
| logRef.value.acceptParams({ id: row.id, type: 'php', tail: row.status == 'building', heightDiff: 220 }); | ||
| logRef.value.acceptParams({ id: row.id, type: 'php', tail: row.status == 'Building', heightDiff: 220 }); | ||
| } | ||
| }; | ||
|
|
||
|
|
@@ -348,14 +345,6 @@ const onOpenBuildCache = () => { | |
|
|
||
| onMounted(() => { | ||
| search(); | ||
| timer = setInterval(() => { | ||
| search(); | ||
| }, 10000 * 1); | ||
| }); | ||
|
|
||
| onUnmounted(() => { | ||
| clearInterval(Number(timer)); | ||
| timer = null; | ||
| }); | ||
| </script> | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The provided JavaScript/TypeScript code contains several potential issues and areas for improvement:
Here's the revised version of the code incorporating these improvements: // Define dependencies at the top of the file
import { onMounted, reactive, ref } from "vue";
import { Runtime } from "@/api/interface/runtime";
import { DeleteRuntime, OperateRuntime, RuntimeDeleteCheck, SearchRuntimes } from "@/api/modules/runtime";
import { dateFormat } from "@/utils/util";
interface PaginationConfig {
// Define pagination configuration interface here
}
export default defineComponent({
components: {
RouterMenu,
LayoutContent,
ElAlert, // Assuming you have these imported somewhere
ElButton, // Assuming you have these imported somewhere
ComplexTable, // Assuming you have this imported somewhere
TableRefresh,
ExtManagement, // Assuming you haven't used any external library for table settings
ComposeLogs,
Config,
Supervisor,
},
setup() {
const loading = ref(false); // Initialize loading state
const items = reactive([]); // Reactively hold data
const paginationConfig: PaginationConfig = {}; // Initialize pagination config object
const req = reactive<Runtime.RuntimeReq>({
keyword: "",
startTime: undefined,
endTime: undefined,
currentPage: 1,
pageSize: 40,
type: "php",
});
let timerId: ReturnType<typeof setInterval> | null = null;
const opRef = ref();
const logRef = ref();
const extensionsRef = ref();
const extManagementRef = ref(); // Corrected component reference
const composeLogRef = ref();
const configRef = ref();
const supervisorRef = ref();
const openLog = (row: Runtime.RuntimeDTO) => {
if (row.status === "Running") {
composeLogRef.value.acceptParams({ compose: row.path + "/docker-compose.yml", resource: row.name });
} else if (row.status === "Pending") {
} else {
logRef.value.acceptParams({ id: row.id, type: "php", tail: false, heightDiff: 220 }); // Updated tail status condition
}
};
const onOpenBuildCache = async () => {
try {
await OnOperateAsync(Runtime.DELETE_CACHES);
alert("Operation successful!");
} catch (error) {
console.error("Failed to delete build cache:", error);
}
};
const search = () => {
// Call SearchRuntimes and update logic here based on response
// Example:
SearchRuntimes(req).then(response => {
items.data = response.runtimes;
items.total = response.count; // Update total count if available
}).catch(error => {
console.error("Error fetching runtimes:", error);
});
};
const initPolling = () => {
if (!timerId) {
timerId = setInterval(search, 10000 * 1); // No need to convert number to string
}
};
const stopPolling = () => {
if (timerId !== null) {
clearInterval(Number(timerId)); // Convert to number before clearing
timerId = null;
}
};
onMounted(() => {
initPolling();
search(); // Initial load
});
onUnmounted(() => {
stopPolling();
});
return {
loading,
items,
search,
openLog,
onOpenBuildCache,
paginationConfig,
opRef,
logRef,
extensionsRef,
extManagementRef,
composeLogRef,
configRef,
supervisorRef,
};
},
});These changes address the identified issues while maintaining good coding standards and functionality. Please note that I've assumed certain functions and components exist based on comments in the original snippet. Adjust them according to your actual project structure and requirements.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code provided appears to be an update to a web component's Vue template and script sections, likely for managing PHP runtime configurations. Here are some observations: Potential Issues and Recommendations:
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The provided code does not contain any irregularities or major issues. However, I do have some suggestions for optimizations:
Remove Timer Initialization: The code attempts to initialize a timer within the
onMountedlifecycle hook but immediately sets it to null before clearing it in theonUnmountedhook. This creates an unnecessary setup.This can be simplified since initializing and clearing the interval within these hooks is redundant because the interval will stop automatically when the component is unmounted.
Consistent Function Call: In the template
<TableRefresh @search="search()" />, you use single quotes around "dotnet-runtime-refresh". It's better consistency to use double quotes or even remove them if they are not needed.These changes make the code cleaner and more optimized without introducing any bugs due to the previous logic errors.