Files
universal_table-rails7/app/assets/javascripts/mind_map/utils/custom.config.js
T
2025-06-09 20:14:55 +08:00

104 lines
2.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 顏色選項集中管理
// Color options management
export const PALETTE_COLORS = [
'#c93a42',
'#fbefdb',
'#0000FF',
'#06c755',
'#FFBF48',
'#1e5b9e',
'#000000',
'#666666',
'#999999',
'#FFFFFF',
// 紅色系(Morandi Red)
'#c8a39e',
'#b4746c',
'#a16666',
'#d3a29d',
'#8e5d5a',
// 橘色系(Morandi Orange)
'#d4a186',
'#e1b7a7',
'#c98e63',
'#e5b58e',
'#b57758',
// 黃色系(Morandi Yellow)
'#d8c29d',
'#e6d3aa',
'#c4b07c',
'#e2c892',
'#a8985c',
// 綠色系(Morandi Green)
'#a3b1a8',
'#8ca39b',
'#9fb7ad',
'#b0c0ae',
'#798d87',
// 藍色系(Morandi Blue)
'#9ca8b8',
'#a0b1c2',
'#8193a8',
'#6e7d91',
'#c0c8d2',
'#b8a9c9',
'#c1adc8',
'#a68ca9',
'#cabed4',
'#8f799e',
'#a0a0a0',
'#bcbcbc',
'#8c8c8c',
'#747474',
'#5e5e5e',
]
// 心智圖初始數據
export const INITIAL_MIND = {
meta: {},
format: 'node_array',
data: [
{
id: 'root',
topic: 'FirstNode',
expanded: true,
isroot: true,
},
],
}
// 模擬打 API
// Simulate an API call to search based on the query
export async function mockSearchApi(query, tableUID) {
return new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
xhr.open("GET", '/admin/universal_tables/get_entries?uid=' + tableUID + "&q=" + query + "&links=true");
xhr.setRequestHeader("Accept", "application/json");
xhr.onload = function () {
if (xhr.status >= 200 && xhr.status < 300) {
try {
const data = JSON.parse(xhr.responseText);
resolve(data); // success
} catch (e) {
reject(new Error("Invalid JSON response"));
}
} else {
reject(new Error(`Request failed with status ${xhr.status}`));
}
};
xhr.onerror = function () {
reject(new Error("Network error"));
};
xhr.send();
});
}