feat: 完成 v0.6.0 墨呈品牌迁移
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
session
|
||||
} from "electron";
|
||||
import { access, mkdir } from "node:fs/promises";
|
||||
import { existsSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath, pathToFileURL } from "node:url";
|
||||
import {
|
||||
@@ -25,6 +26,7 @@ import {
|
||||
findMarkdownFileArgument,
|
||||
isMarkdownFilePath
|
||||
} from "./markdown-file.js";
|
||||
import { migrateLegacyUserData } from "./user-data-migration.js";
|
||||
|
||||
const APP_SCHEME = "mdpdf";
|
||||
const APP_HOST = "bundle";
|
||||
@@ -37,6 +39,28 @@ let pendingExternalMarkdownPath = findMarkdownFileArgument(
|
||||
process.cwd()
|
||||
);
|
||||
|
||||
function configurePackagedUserDataDirectory() {
|
||||
if (!app.isPackaged) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
const appDataDirectory = app.getPath("appData");
|
||||
const targetDirectory = path.join(
|
||||
appDataDirectory,
|
||||
__APP_ENGLISH_NAME__
|
||||
);
|
||||
const targetAlreadyExists = existsSync(targetDirectory);
|
||||
app.setPath("userData", targetDirectory);
|
||||
if (targetAlreadyExists) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
return migrateLegacyUserData(
|
||||
[path.join(appDataDirectory, __APP_LEGACY_DISPLAY_NAME__)],
|
||||
targetDirectory
|
||||
).then(() => undefined);
|
||||
}
|
||||
|
||||
const userDataMigration = configurePackagedUserDataDirectory();
|
||||
|
||||
protocol.registerSchemesAsPrivileged([
|
||||
{
|
||||
scheme: APP_SCHEME,
|
||||
@@ -300,9 +324,10 @@ if (!hasSingleInstanceLock) {
|
||||
app
|
||||
.whenReady()
|
||||
.then(async () => {
|
||||
await userDataMigration;
|
||||
Menu.setApplicationMenu(null);
|
||||
if (process.platform === "win32") {
|
||||
app.setAppUserModelId("com.md-to-pdf.desktop");
|
||||
app.setAppUserModelId(__APP_ID__);
|
||||
}
|
||||
const themeDirectory = getDesktopThemeDirectory();
|
||||
await mkdir(themeDirectory, { recursive: true });
|
||||
|
||||
Reference in New Issue
Block a user