universal_table/app/assets/javascripts/mind_map/utils/custom.config.js

104 lines
2.1 KiB
JavaScript
Raw Normal View History

2025-05-23 03:41:14 +00:00
// 顏色選項集中管理
// Color options management
export const PALETTE_COLORS = [
2025-06-09 12:14:55 +00:00
'#c93a42',
'#fbefdb',
2025-05-23 03:41:14 +00:00
'#0000FF',
2025-06-09 12:14:55 +00:00
'#06c755',
'#FFBF48',
'#1e5b9e',
2025-05-23 03:41:14 +00:00
'#000000',
'#666666',
'#999999',
'#FFFFFF',
2025-06-09 12:14:55 +00:00
// 紅色系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',
2025-05-23 03:41:14 +00:00
]
// 心智圖初始數據
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
2025-05-23 15:17:06 +00:00
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();
});
2025-05-23 03:41:14 +00:00
}