Я недавно начал работать над надстройкой для Microsoft Excel. Я новичок в node js. Документация и онлайн-руководства хороши для одностраничной надстройки, но я не смог найти справки для надстройки, которая имеет несколько страниц, и пользователь может перейти на эти страницы.
Я пробовал несколькими способами, с маршрутами express, она не отображает страницу,
Хотя каждый файл содержит вызов Office.OnReady, как упоминалось в руководствах.
Я знаю, что я делаю что-то не так, но не могу поставить на это свой палец. Любая помощь по этому вопросу будет высоко ценится.
Спасибо
Редактировать: location.href работает, но это хорошая практика, чтобы использовать его для навигации?
Вот js код:
Office.onReady(info => {
if (info.host === Office.HostType.Excel) {
// Determine if the user's version of Office supports all the Office.js APIs that are used in the tutorial.
if (!Office.context.requirements.isSetSupported('ExcelApi', '1.7')) {
console.log('Sorry. The tutorial add-in uses Excel.js APIs that are not available in your version of Office.');
}
// Assign event handlers and other initialization logic.
document.getElementById("app-body").style.display = "flex",
document.getElementById("login").onclick = authenticate
}
});
function get_user_input() {
var platform_url = document.getElementById("platform-url").value
var username = document.getElementById("username").value
var password = document.getElementById("password").value
return [platform_url, username, password]
}
function authenticate(request, response) {
var input = get_user_input()
// perform authentication logic here
window.location.href = "https://localhost:3000/index.html";
}
А вот соответствующий HTML откуда делается звонок
<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. -->
<!-- This file shows how to design a first-run page that provides a welcome screen to the user about the features of the add-in. -->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Exceljs</title>
<!-- Office JavaScript API -->
<script type="text/javascript" src="https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js"></script>
<!-- For more information on Office UI Fabric, visit https://developer.microsoft.com/fabric. -->
<link rel="stylesheet"
href="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-core/9.6.1/css/fabric.min.css" />
<!-- Template styles -->
<link href="index.css" rel="stylesheet" type="text/css" />
</head>
<body class="ms-font-m ms-welcome ms-Fabric">
<header class="ms-welcome__header ms-bgColor-neutralLighter">
<img width="90" height="90" src="../../assets/logo.png" alt="logo" title="logo" />
</header>
<main id="app-body" class="ms-welcome__main" style="display: none;">
<!-- URL section -->
<div class="form-group">
<label>Platform URL:</label>
<input type="text" id="platform-url" value="" />
</div>
<div class="form-group">
<label>Username:</label>
<input type="text" id="username" value="" />
</div>
<div class="form-group">
<label>Password:</label>
<input type="password" id="password" value="" />
</div>
<!-- Button -->
<div class="form-action">
<button class="ms-Button" id="login">Login</button><br/><br/>
</div>
<div>
<label class="error-banner" id="error-banner"></label>
</div>
</main>
</body>
</html>