JHipster 6.4.1 + Angular 中的 Bootswatch 主题切换器

问题描述

我正在尝试按照此处的文档使用 Angular 和 JHipster 6.4.1 将 bootswatch 主题切换器添加到我的 JHipster 应用程序:https://www.jhipster.tech/tips/009_tips_using_bootswatch_themes.html#dropdown-12

我的问题是关于 authInterceptor.ts 文件中 bootswatch URL 的排除。提供的代码片段在我的 auth.interceptor.ts 文件中的何处?我认为这可能是 JHipster 的更新版本,可能与文档中提供的示例不兼容。这是我的 auth.interceptor.ts 文件

import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { LocalStorageService,SessionStorageService } from 'ngx-webstorage';
import { HttpInterceptor,HttpRequest,HttpHandler,HttpEvent } from '@angular/common/http';

import { SERVER_API_URL } from 'app/app.constants';

@Injectable()
export class AuthInterceptor implements HttpInterceptor {
  constructor(private localStorage: LocalStorageService,private sessionStorage: SessionStorageService) {}

  intercept(request: HttpRequest<any>,next: HttpHandler): Observable<HttpEvent<any>> {
    if (!request || !request.url || (request.url.startsWith('http') && !(SERVER_API_URL && request.url.startsWith(SERVER_API_URL)))) {
      return next.handle(request);
    }

    
    const token = this.localStorage.retrieve('authenticationToken') || this.sessionStorage.retrieve('authenticationToken');
    if (token) {
      request = request.clone({
        setHeaders: {
          Authorization: 'Bearer ' + token
        }
      });
    }
    return next.handle(request);
  }
}

相关问题:文档说在“vendor.css build”之后将样式表链接放在 index.html 文件中。我在 index.html 文件中没有看到,我只是将 <link rel="stylesheet" href="" id="bootswatch-css" title="Default"> 标签在这里。这看起来对吗?任何帮助/想法将不胜感激:

<!doctype html>
<html class="no-js" lang="en" dir="ltr">
<head>
    <base href="/" />
    <Meta charset="utf-8">
    <Meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>myApp</title>
    <Meta name="description" content="Description for myApp">
    <Meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
    <Meta name="theme-color" content="#000000">
    <link rel="shortcut icon" href="favicon.ico" />
    <link rel="manifest" href="manifest.webapp" />
    <link rel="stylesheet" href="content/css/loading.css">

<!-- ************ BOOTSWATCH THEME <link> TAG BEGIN ************ -->

    <!-- placeholder link to load bootswatch themes,title holds the current applied theme name-->
<link rel="stylesheet" href="" id="bootswatch-css" title="Default">
<!-- build:css assets/styles/main.css -->

<!-- ************ BOOTSWATCH THEME <link> TAG END ************ -->
    <!-- jhipster-needle-add-resources-to-root - JHipster will add new resources here -->
</head>
<body>
    <!--[if lt IE 9]>
        <p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
    <![endif]-->
    <jhi-main>
        <div class="app-loading">
            <div class="lds-css ng-scope">
                <div class="lds-pacman">
                    <div><div></div><div></div><div></div></div>
                    <div><div></div><div></div><div></div></div>
                </div>
            </div>
        </div>
        <div class="app-loading">
            <div id="jhipster-error" style="display:none">
                <!-- This content is for troubleshooting purpose and will be removed when app renders -->
                <h1>An error has occurred :-(</h1>
                <h2>Usual error causes</h2>
                <ol>
                    <li>You started the application from an IDE and you didn't run <code style="color:red">npm start</code> or <code style="color:red">npm run webpack:build</code>.</li>
                    <li>You had a network error while running <code style="color:red">npm install</code>. If you are behind a corporate proxy,it is likely that this error was caused by your proxy. Have a look at the JHipster error logs,you will probably have the cause of the error.</li>
                    <li>You installed a Node.js version that doesn't work with JHipster: please use an LTS (long-term support) version,as it's the only version we support.</li>
                </ol>
                <h2>Building the client side code again</h2>
                <p>If you want to go fast,run <code style="color:red">./gradlew</code> to build and run everything.</p>
                <p>If you want to have more control,so you can debug your issue more easily,you should follow the following steps:</p>
                <ol>
                    <li>Install npm dependencies with the command <code style="color:red">npm install</code></li>
                    <li>Build the client with the command <code style="color:red">npm run webpack:build</code> or <code style="color:red">npm start</code></li>
                    <li>Start the server with <code style="color:red">./gradlew</code> or using your IDE</li>
                </ol>

                <h2>Getting more help</h2>

                <h3>If you have a question on how to use JHipster</h3>
                <p>
                    Go to Stack Overflow with the <a href="http://stackoverflow.com/tags/jhipster" target="_blank" rel="noopener noreferrer">"jhipster"</a> tag.
                </p>

                <h3>If you have a bug or a feature request</h3>
                <p>
                    First read our <a href="https://github.com/jhipster/generator-jhipster/blob/master/CONTRIBUTING.md" target="_blank" rel="noopener noreferrer">contributing guidelines</a>.
                </p>
                <p>
                    Then,fill a ticket on our <a href="https://github.com/jhipster/generator-jhipster/issues/new/choose" target="_blank" rel="noopener noreferrer">bug tracker</a>,we'll be happy to resolve your issue!
                </p>

                <h3>If you want to chat with contributors and other users</h3>
                <p>
                    Join our chat room on <a href="https://gitter.im/jhipster/generator-jhipster" target="_blank" rel="noopener noreferrer">Gitter.im</a>. Please note that this is a public chat room,and that we expect you to respect other people and write in a correct English language!
                </p>
                <!-- end of troubleshooting content -->
            </div>
        </div>
    </jhi-main>
    <noscript>
        <h1>You must enable javascript to view this page.</h1>
    </noscript>
    <script type="text/javascript" language="javascript">
        // show an error message if the app loading takes more than 5 sec
        window.onload=function() {
            setTimeout(showError,4000);
        }
        function showError() {
            var errorElm = document.getElementById("jhipster-error");
            if (errorElm && errorElm.style) {
                errorElm.style.display = "block";
            }
        }
    </script>

    <!-- Google Analytics: uncomment and change UA-XXXXX-X to be your site's ID.
    <script>
        (function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=
        function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;
        e=o.createElement(i);r=o.getElementsByTagName(i)[0];
        e.src='//www.google-analytics.com/analytics.js';
        r.parentNode.insertBefore(e,r)}(window,document,'script','ga'));
        ga('create','UA-XXXXX-X');ga('send','pageview');
    </script>-->
</body>
</html>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)