诀窍是,在htmlDependency
调用内部(icon()
函数中),删除package = "shiny"
并替换"www/shared/fontawesome"
为我的 FA 文件夹的绝对路径(我还更新了版本号)。
编辑:更准确地说,下面是(非常轻微的)修改后的图标功能:
my_icon = function (name, class = NULL, lib = "font-awesome") {
prefixes <- list(`font-awesome` = "fa", glyphicon = "glyphicon")
prefix <- prefixes[[lib]]
if (is.null(prefix)) {
stop("Unknown font library '", lib, "' specified. Must be one of ",
paste0("\"", names(prefixes), "\"", collapse = ", "))
}
iconClass <- ""
if (!is.null(name)) {
prefix_class <- prefix
#if (prefix_class == "fa" && name %in% font_awesome_brands) {
# prefix_class <- "fab"
#}
iconClass <- paste0(prefix_class, " ", prefix, "-", name)
}
if (!is.null(class))
iconClass <- paste(iconClass, class)
iconTag <- tags$i(class = iconClass)
if (lib == "font-awesome") {
htmlDependencies(iconTag) <- htmlDependency("font-awesome",
"5.7.2", "./www/shared/fontawesome/",
stylesheet = c("css/all.min.css"))
}
htmltools::browsable(iconTag)
}
除了注释掉一些行之外,我唯一改变的部分是htmlDependency
调用。在原始函数中,它是:
htmlDependency("font-awesome", "5.3.1", "www/shared/fontawesome", package = "shiny",
stylesheet = c("css/all.min.css", "css/v4-shims.min.css")