2022-06-30 18:15:13 +08:00
|
|
|
export const genOptions = (data: string[] | { label: string, name: string }[], key: string) => {
|
|
|
|
|
let html = "";
|
|
|
|
|
data.forEach((item: string | { label: string, name: string }) => {
|
|
|
|
|
if (typeof item === "string") {
|
|
|
|
|
html += `<option value="${item}" ${key === item ? "selected" : ""}>${item}</option>`;
|
|
|
|
|
} else {
|
|
|
|
|
html += `<option value="${item.name}" ${key === item.name ? "selected" : ""}>${item.label}</option>`;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return html;
|
2022-07-01 10:52:17 +08:00
|
|
|
};
|
2024-05-01 16:10:07 +08:00
|
|
|
|
|
|
|
|
export const genLangOptions = (data: { label: string, name: string }[], key: string) => {
|
|
|
|
|
let html = "";
|
|
|
|
|
data.forEach((item: { label: string, name: string }) => {
|
|
|
|
|
html += `<option value="${item.name}" ${key === item.name ? "selected" : ""}>${item.label} (${item.name})</option>`;
|
|
|
|
|
});
|
|
|
|
|
return html;
|
|
|
|
|
};
|
|
|
|
|
|