mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-06 17:18:35 +08:00
issue: ##36621 - For simple types in a struct, add "string" to the JSON tag for automatic string conversion during JSON encoding. - For complex types in a struct, replace "int64" with "string." Signed-off-by: jaime <yun.zhang@zilliz.com>
55 lines
1.8 KiB
JavaScript
55 lines
1.8 KiB
JavaScript
var DEBUG_MODE = false; // Set this to false to disable debug mode
|
|
var MILVUS_URI = "http://127.0.0.1:9091/api/v1"
|
|
|
|
// Function to check URL for "debug" parameter and switch debug mode
|
|
function toggleDebugMode() {
|
|
// Get the current URL's query parameters
|
|
const urlParams = new URLSearchParams(window.location.search);
|
|
|
|
// Check if "debug" parameter is present and its value
|
|
if (urlParams.has('debug')) {
|
|
if (urlParams.get('debug') === 'true') {
|
|
console.log("Debug mode is ON");
|
|
// Enable debug mode: Add any additional debug functionality here
|
|
localStorage.setItem('debug', 'true');
|
|
} else {
|
|
console.log("Debug mode is OFF");
|
|
localStorage.setItem('debug', 'false');
|
|
}
|
|
}
|
|
|
|
// Check if debug mode is enabled
|
|
DEBUG_MODE = localStorage.getItem('debug') === 'true';
|
|
}
|
|
|
|
// Call the function to check the URL and apply debug mode
|
|
toggleDebugMode();
|
|
|
|
const handleError = (error) => {
|
|
console.error('Error fetching data:', error);
|
|
// const errorMessage = encodeURIComponent(error.message || 'Unknown error');
|
|
// window.location.href = `5xx.html?error=${errorMessage}`;
|
|
};
|
|
|
|
const fetchData = (url, localData) => {
|
|
if (DEBUG_MODE) {
|
|
return new Promise((resolve) => {
|
|
resolve(JSON.parse(localData));
|
|
});
|
|
} else {
|
|
return fetch(url).then(response => {
|
|
return response.json();
|
|
})
|
|
}
|
|
};
|
|
|
|
function getQueryParams() {
|
|
const params = {};
|
|
const queryString = window.location.search.substring(1);
|
|
const queryArray = queryString.split('&');
|
|
queryArray.forEach(param => {
|
|
const [key, value] = param.split('=');
|
|
params[decodeURIComponent(key)] = decodeURIComponent(value || '');
|
|
});
|
|
return params;
|
|
} |