쿠키로 푸터 내비게이션 강제 표시

Discourse는 특정 조건에 따라 해당 푸터를 렌더링합니다. 푸터는 여기에 추가됩니다.

discourse/app/assets/javascripts/discourse/app/templates/application.hbs at a0bbc346cb5d5b89d1a3efdfa89869349a8b067f · discourse/discourse · GitHub

showFooterNav는 여기에 정의되어 있습니다.

discourse/app/assets/javascripts/discourse/app/controllers/application.js at 1472e47aae5bfdfb6fd9abfe89beb186c751f514 · discourse/discourse · GitHub

이 중 어느 하나가 true인 경우, 내비게이션이 표시됩니다.

isiOSPWA()와 isAppWebview()는 여기에 정의되어 있습니다

discourse/app/assets/javascripts/discourse/app/lib/utilities.js at 1472e47aae5bfdfb6fd9abfe89beb186c751f514 · discourse/discourse · GitHub

예를 들어, isAppWebview()는 다음과 같은 형태입니다.

discourse/app/assets/javascripts/discourse/app/lib/utilities.js at 1472e47aae5bfdfb6fd9abfe89beb186c751f514 · discourse/discourse · GitHub

테마에서 쿠키를 확인하기 위한 추가 조건을 만들 수 있습니다. 예를 들어 다음과 같이요.

const isWKWebView = () => {
  // 쿠키를 확인하고 존재하면 true를 반환합니다.
  // 또는 사용자가 애플리케이션을 사용 중인지 감지하기 위한 다른 방법을 사용할 수 있습니다.
}

다른 클래스의 경우, 일반적으로 다음과 같이 showFooterNav()를 수정할 수 있습니다.

api.modifyClass("controller:application", {
  pluginId: "show-footer-nav",
  @discourseComputed
  showFooterNav() {
    // ...
  }
});

하지만 이것은 애플리케이션 컨트롤러이므로, 코드가 실행될 기회를 갖기 전에 캐시됩니다. 즉, 클래스를 수정할 수 없습니다.

그럼에도 불구하고, 다음과 같은 방식으로 showFooterNav 값을 변경할 수 있습니다.

<script type="text/discourse-plugin" version="0.8">
  const isWKWebView = () => {
    // 조건을 확인하고 반환합니다.
  };

  if (isWKWebView()) {
    const applicationController = api.container.lookup("controller:application");
    applicationController.set("showFooterNav", true);
  }
</script>

테마의 헤더 탭에, 또는 원격 테마를 사용하는 경우 이니셜라이저에 이 코드를 추가하세요.

5개의 좋아요