mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-29 19:12:27 +08:00
Merge pull request #900 from pano9000/refactor_views-windowGlobal-ejs-partial
refactor(views): use ejs partial for injecting window.glob
This commit is contained in:
commit
bacba7d00b
@ -34,6 +34,7 @@ function index(req: Request, res: Response) {
|
|||||||
|
|
||||||
const isElectron = utils.isElectron();
|
const isElectron = utils.isElectron();
|
||||||
res.render(view, {
|
res.render(view, {
|
||||||
|
device: view,
|
||||||
csrfToken: csrfToken,
|
csrfToken: csrfToken,
|
||||||
themeCssUrl: getThemeCssUrl(theme, themeNote),
|
themeCssUrl: getThemeCssUrl(theme, themeNote),
|
||||||
themeUseNextAsBase: themeNote?.getAttributeValue("label", "appThemeBase") === "next",
|
themeUseNextAsBase: themeNote?.getAttributeValue("label", "appThemeBase") === "next",
|
||||||
@ -51,7 +52,7 @@ function index(req: Request, res: Response) {
|
|||||||
instanceName: config.General ? config.General.instanceName : null,
|
instanceName: config.General ? config.General.instanceName : null,
|
||||||
appCssNoteIds: getAppCssNoteIds(),
|
appCssNoteIds: getAppCssNoteIds(),
|
||||||
isDev: env.isDev(),
|
isDev: env.isDev(),
|
||||||
isMainWindow: !req.query.extraWindow,
|
isMainWindow: (view === "mobile") ? true : !req.query.extraWindow,
|
||||||
isProtectedSessionAvailable: protectedSessionService.isProtectedSessionAvailable(),
|
isProtectedSessionAvailable: protectedSessionService.isProtectedSessionAvailable(),
|
||||||
maxContentWidth: Math.max(640, parseInt(options.maxContentWidth)),
|
maxContentWidth: Math.max(640, parseInt(options.maxContentWidth)),
|
||||||
triliumVersion: packageJson.version,
|
triliumVersion: packageJson.version,
|
||||||
|
@ -21,29 +21,7 @@
|
|||||||
|
|
||||||
<div class="dropdown-menu dropdown-menu-sm" id="context-menu-container"></div>
|
<div class="dropdown-menu dropdown-menu-sm" id="context-menu-container"></div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<%- include("./partials/windowGlobal.ejs", locals) %>
|
||||||
global = globalThis; /* fixes https://github.com/webpack/webpack/issues/10035 */
|
|
||||||
|
|
||||||
window.glob = {
|
|
||||||
device: "desktop",
|
|
||||||
baseApiUrl: 'api/',
|
|
||||||
activeDialog: null,
|
|
||||||
maxEntityChangeIdAtLoad: <%= maxEntityChangeIdAtLoad %>,
|
|
||||||
maxEntityChangeSyncIdAtLoad: <%= maxEntityChangeSyncIdAtLoad %>,
|
|
||||||
instanceName: '<%= instanceName %>',
|
|
||||||
csrfToken: '<%= csrfToken %>',
|
|
||||||
isDev: <%= isDev %>,
|
|
||||||
appCssNoteIds: <%- JSON.stringify(appCssNoteIds) %>,
|
|
||||||
isMainWindow: <%= isMainWindow %>,
|
|
||||||
isProtectedSessionAvailable: <%= isProtectedSessionAvailable %>,
|
|
||||||
triliumVersion: "<%= triliumVersion %>",
|
|
||||||
assetPath: "<%= assetPath %>",
|
|
||||||
appPath: "<%= appPath %>",
|
|
||||||
platform: "<%= platform %>",
|
|
||||||
hasNativeTitleBar: <%= hasNativeTitleBar %>,
|
|
||||||
TRILIUM_SAFE_MODE: <%= !!process.env.TRILIUM_SAFE_MODE %>
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.note-split {
|
.note-split {
|
||||||
|
@ -106,26 +106,7 @@
|
|||||||
|
|
||||||
<div class="dropdown-menu dropdown-menu-sm" id="context-menu-container"></div>
|
<div class="dropdown-menu dropdown-menu-sm" id="context-menu-container"></div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<%- include("./partials/windowGlobal.ejs", locals) %>
|
||||||
global = globalThis; /* fixes https://github.com/webpack/webpack/issues/10035 */
|
|
||||||
|
|
||||||
window.glob = {
|
|
||||||
device: "mobile",
|
|
||||||
baseApiUrl: 'api/',
|
|
||||||
activeDialog: null,
|
|
||||||
maxEntityChangeIdAtLoad: <%= maxEntityChangeIdAtLoad %>,
|
|
||||||
maxEntityChangeSyncIdAtLoad: <%= maxEntityChangeSyncIdAtLoad %>,
|
|
||||||
instanceName: '<%= instanceName %>',
|
|
||||||
csrfToken: '<%= csrfToken %>',
|
|
||||||
isDev: <%= isDev %>,
|
|
||||||
appCssNoteIds: <%- JSON.stringify(appCssNoteIds) %>,
|
|
||||||
isMainWindow: true,
|
|
||||||
isProtectedSessionAvailable: <%= isProtectedSessionAvailable %>,
|
|
||||||
assetPath: "<%= assetPath %>",
|
|
||||||
appPath: "<%= appPath %>",
|
|
||||||
TRILIUM_SAFE_MODE: <%= !!process.env.TRILIUM_SAFE_MODE %>
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script src="<%= assetPath %>/node_modules/jquery/dist/jquery.min.js"></script>
|
<script src="<%= assetPath %>/node_modules/jquery/dist/jquery.min.js"></script>
|
||||||
|
|
||||||
|
23
src/views/partials/windowGlobal.ejs
Normal file
23
src/views/partials/windowGlobal.ejs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<script type="text/javascript">
|
||||||
|
global = globalThis; /* fixes https://github.com/webpack/webpack/issues/10035 */
|
||||||
|
|
||||||
|
window.glob = {
|
||||||
|
device: "<%= device %>",
|
||||||
|
baseApiUrl: 'api/',
|
||||||
|
activeDialog: null,
|
||||||
|
maxEntityChangeIdAtLoad: <%= maxEntityChangeIdAtLoad %>,
|
||||||
|
maxEntityChangeSyncIdAtLoad: <%= maxEntityChangeSyncIdAtLoad %>,
|
||||||
|
instanceName: '<%= instanceName %>',
|
||||||
|
csrfToken: '<%= csrfToken %>',
|
||||||
|
isDev: <%= isDev %>,
|
||||||
|
appCssNoteIds: <%- JSON.stringify(appCssNoteIds) %>,
|
||||||
|
isMainWindow: <%= isMainWindow %>,
|
||||||
|
isProtectedSessionAvailable: <%= isProtectedSessionAvailable %>,
|
||||||
|
triliumVersion: "<%= triliumVersion %>",
|
||||||
|
assetPath: "<%= assetPath %>",
|
||||||
|
appPath: "<%= appPath %>",
|
||||||
|
platform: "<%= platform %>",
|
||||||
|
hasNativeTitleBar: <%= hasNativeTitleBar %>,
|
||||||
|
TRILIUM_SAFE_MODE: <%= !!process.env.TRILIUM_SAFE_MODE %>
|
||||||
|
};
|
||||||
|
</script>
|
Loading…
x
Reference in New Issue
Block a user