Skip to content

Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.

5.0 KB
Raw Blame
.chat-citation-pills() {
  :deep(.citation) {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    vertical-align: baseline;
    box-sizing: border-box;
    border-radius: var(--app-radius-pill);
    padding: 0 5px;
    font-size: 0.72em;
    line-height: 1.45;
    margin: 0 0.06em;
    background-clip: padding-box;
    transform: translateY(-0.04em);
  }

  :deep(.citation-icon) {
    display: inline-block;
    width: 1em;
    height: 1em;
    flex-shrink: 0;
    background-color: currentColor;
    opacity: 0.68;
    mask-size: contain;
    mask-repeat: no-repeat;
    mask-position: center;
    -webkit-mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
  }

  :deep(.citation-icon--book) {
    mask-image: url('@/assets/img/ziliao.svg');
    -webkit-mask-image: url('@/assets/img/ziliao.svg');
  }

  :deep(.citation-icon--web) {
    mask-image: url('@/assets/img/websearch-globe.svg');
    -webkit-mask-image: url('@/assets/img/websearch-globe.svg');
  }

  :deep(.citation-text),
  :deep(.citation-domain) {
    line-height: 1.45;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  // 引用标签只用浅底色区分,不加描边,避免像按钮一样抢正文
  :deep(.citation-kb),
  :deep(.citation-web) {
    background: color-mix(in srgb, var(--td-text-color-primary) 6%, transparent);
    color: var(--td-text-color-secondary);
    border: 0;
    cursor: pointer;
    white-space: nowrap;
    position: relative;
    text-decoration: none;
    transition: background var(--app-motion-fast) ease, color var(--app-motion-fast) ease;
  }

  :deep(.citation-kb:hover),
  :deep(.citation-web:hover) {
    background: color-mix(in srgb, var(--td-text-color-primary) 10%, transparent);
    color: var(--td-text-color-primary);
  }

  :deep(.citation-web:focus-visible),
  :deep(.citation-kb:focus-visible) {
    outline: 2px solid var(--td-component-border);
    outline-offset: 2px;
  }

  :deep(.citation-tip) {
    display: none;
  }

  :deep(a.wiki-content-link),
  :deep(.weknora-entity-link) {
    color: var(--td-brand-color);
    cursor: pointer;
    border-bottom: 1px dashed var(--td-brand-color);
    text-decoration: none;
    font-weight: 500;
    transition: border-bottom-style var(--app-motion-fast) ease;

    &:hover {
      border-bottom-style: solid;
      text-decoration: none !important;
    }

    &:focus-visible {
      outline: 2px solid var(--td-brand-color);
      outline-offset: 2px;
      border-radius: 2px;
    }
  }
}

.chat-citation-float {
  position: absolute;
  z-index: 10000;
  box-sizing: border-box;
  width: 300px;
  max-width: calc(100vw - 32px);
  padding: 10px 12px 12px;
  border: 0.5px solid var(--td-component-stroke);
  border-radius: var(--app-radius-lg);
  background: var(--td-bg-color-container);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04), 0 6px 20px rgba(0, 0, 0, 0.08);
  font-family: var(--app-font-family);
  font-size: var(--app-text-sm);
  line-height: 1.6;
  color: var(--td-text-color-primary);
  overflow-wrap: anywhere;
  animation: chat-citation-float-in var(--app-motion-fast) ease-out both;

  &__header {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--td-component-stroke);
  }

  &__icon {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    margin-top: 3px;
    background-color: var(--td-text-color-placeholder);
    mask-size: contain;
    mask-repeat: no-repeat;
    mask-position: center;
    -webkit-mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;

    &--book {
      mask-image: url('@/assets/img/ziliao.svg');
      -webkit-mask-image: url('@/assets/img/ziliao.svg');
    }

    &--web {
      mask-image: url('@/assets/img/websearch-globe.svg');
      -webkit-mask-image: url('@/assets/img/websearch-globe.svg');
    }
  }

  &__title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    font-size: var(--app-text-md);
    font-weight: 500;
    line-height: 20px;
    color: var(--td-text-color-primary);
  }

  &__link {
    display: block;
    overflow: hidden;
    color: var(--td-text-color-secondary);
    text-overflow: ellipsis;
    white-space: nowrap;
    text-decoration: none;

    &:hover {
      color: var(--td-brand-color);
    }
  }

  // 摘录只展示前几行,完整内容点击引用后在侧栏查看
  &__body {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 7;
    line-clamp: 7;
    overflow: hidden;
    white-space: pre-line;
    color: var(--td-text-color-secondary);
  }

  &__muted {
    color: var(--td-text-color-placeholder);
  }

  &__error {
    color: var(--td-error-color);
  }

  &--web &__header {
    margin-bottom: 6px;
  }
}

@keyframes chat-citation-float-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-citation-float {
    animation: none;
  }
}