feat: 学时历史可打开对应课程
This commit is contained in:
@@ -135,13 +135,33 @@ const paged = computed(() => {
|
||||
return rows.slice(start, start + pageSize.value);
|
||||
});
|
||||
|
||||
const EUNIV_ORIGIN = "https://euniv.zte.com.cn";
|
||||
|
||||
function courseHref(path: string) {
|
||||
const text = path.trim();
|
||||
if (text.startsWith("/") && !text.startsWith("//")) return `${EUNIV_ORIGIN}${text}`;
|
||||
try {
|
||||
const url = new URL(text);
|
||||
if (url.protocol === "https:" && url.hostname === "euniv.zte.com.cn") return url.href;
|
||||
} catch {
|
||||
return "";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
const columns: DataTableColumns<HistoryItem> = [
|
||||
{
|
||||
title: "来源",
|
||||
key: "title",
|
||||
ellipsis: { tooltip: true },
|
||||
render(row) {
|
||||
return h("span", { class: "history-title", title: row.title }, row.title || "—");
|
||||
const text = row.title || "—";
|
||||
const href = courseHref(row.path);
|
||||
if (!href) return h("span", { class: "history-title", title: row.title }, text);
|
||||
return h(
|
||||
"a",
|
||||
{ class: "history-title", href, target: "_blank", rel: "noreferrer", title: row.title || "在学习平台打开" },
|
||||
text,
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1556,6 +1556,15 @@ select {
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
a.history-title {
|
||||
color: var(--accent);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a.history-title:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.n-data-table {
|
||||
--n-merged-th-color: transparent;
|
||||
--n-merged-td-color: transparent;
|
||||
|
||||
Reference in New Issue
Block a user