使用 shinyauthr 时如何为仪表板标题添加徽标

问题描述 投票:0回答:0
# Init DB using credentials data
credentials <- data.frame(
  user = c("shiny", "shinymanager"),
  password = c("azerty", "12345"),
  # password will automatically be hashed
  admin = c(FALSE, TRUE),
  stringsAsFactors = FALSE
)

# you can use keyring package to set database key
library(keyring)
key_set("R-shinymanager-key", "obiwankenobi")

# Init the database
create_db(
  credentials_data = credentials,
  sqlite_path = "path/to/database.sqlite", # will be created
  passphrase = key_get("R-shinymanager-key", "obiwankenobi")
  # passphrase = "passphrase_wihtout_keyring"
)

# Wrap your UI with secure_app, enabled admin mode or not
body <- dashboardBody(shinyjs::useShinyjs(),  tags$head(
  tags$link(rel = "stylesheet", type = "text/css", href = "style.css"),
  tags$script(src = "myscript.js"),
), 
verbatimTextOutput("auth_output")
)

header <- dashboardHeader(title = tags$a(
        href = "#",
        tags$img(
          src = "my-logo.png",
          height = "80px",
          width = "170px",
        ),
      ),

)


ui <- dashboardPage(title = "Adtree",header,
                    dashboardSidebar(disable = TRUE),
                    body, skin = "blue")
ui <- secure_app(ui, enable_admin = TRUE)


server <- function(input, output, session) {
  
  # check_credentials directly on sqlite db
  res_auth <- secure_server(
    check_credentials = check_credentials(
        "path/to/database.sqlite",
        passphrase = key_get("R-shinymanager-key", "obiwankenobi")
        # passphrase = "passphrase_wihtout_keyring"
    )
  )
  
  output$auth_output <- renderPrint({
    reactiveValuesToList(res_auth)
  })
  
  # your classic server logic
  ...
}

好的,这是我的代码

tags$a(
        href = "#",
        tags$img(
          src = "my-logo.png",
          height = "80px",
          width = "170px",
        ),
      ),

我用它在左下角输入我公司的标志,我已经尝试过不使用 shinyauthr

ui <- secure_app(ui, enable_admin = TRUE)
并且它运行完美,标志出现并且没有给出这样的错误:

Error in dashboardHeader(title = tags$a(href = "#", tags$img(src = "www/my-logo.png",  : 
  argument is missing, with no default

例如,如果我将图像代码删除到

dashboardHeader(title = "testing")
,它也可以完美运行,标题标题将显示“测试”。那么如何使用 shinyauthr 将图像放入 ui 包装器中,或者 shinyauthr 可能不支持图像?

css r shiny rstudio shinydashboard
© www.soinside.com 2019 - 2024. All rights reserved.