Skip to content

Commit

Permalink
https://github.com/Hi-Windom/Sillot-android/issues/71
Browse files Browse the repository at this point in the history
  • Loading branch information
Soltus committed Jun 5, 2024
1 parent 311917c commit 0fe46c5
Show file tree
Hide file tree
Showing 14 changed files with 1,806 additions and 1,842 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as path from "path";
export function add_task_运行工作区脚本文件(context: vscode.ExtensionContext) {
const disposable = vscode.commands.registerCommand("sillot.运行工作区脚本文件", async () => {
let batFiles: vscode.Uri[] | undefined = undefined;
const limiter1 = 58;
const limiter1 = 31;
const fileNameStartWith = "workspace-";
// 使用 withProgress 显示进度
vscode.window
Expand Down
4 changes: 2 additions & 2 deletions app/src/config/about.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,9 @@ ${ isAppMode() ? `
networkServeElement.addEventListener("change", () => {
fetchPost("/api/system/setNetworkServe", {networkServe: networkServeElement.checked}, () => {
if (window.JSAndroid && networkServeElement.checked) { // 安卓平板
window.JSAndroid?.requestPermissionActivity("Battery","注意:后台稳定伺服会消耗额外电量","coldRestart");
window.JSAndroid?.requestPermissionActivity("Battery","注意:后台稳定伺服会消耗额外电量", "androidReboot");
} else if (window.JSAndroid) {
window.Sillot?.androidRestartSiYuan();
window.JSAndroid?.androidReboot();
} else {
exportLayout({
errorExit: true,
Expand Down
4 changes: 0 additions & 4 deletions app/src/dialog/processSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,6 @@ export const kernelError = () => {
if (document.querySelector("#errorLog")) {
return;
}
if (window.JSAndroid) {
window.JSAndroid.androidReboot();
return;
}
let iosReStart = "";
if (isInIOS()) {
iosReStart = `<div class="fn__hr"></div><div class="fn__flex"><div class="fn__flex-1"></div><button class="b3-button">${window.siyuan.languages.retry}</button></div>`;
Expand Down
432 changes: 211 additions & 221 deletions app/src/index.ts

Large diffs are not rendered by default.

360 changes: 175 additions & 185 deletions app/src/mobile/index.ts

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions app/src/mobile/settings/about.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,9 @@ ${
networkServeElement.addEventListener("change", () => {
fetchPost("/api/system/setNetworkServe", {networkServe: networkServeElement.checked}, () => {
if(networkServeElement.checked){
window.JSAndroid?.requestPermissionActivity("Battery","注意:后台稳定伺服会消耗额外电量","coldRestart");
window.JSAndroid?.requestPermissionActivity("Battery","注意:后台稳定伺服会消耗额外电量", "androidReboot");
} else {
window.Sillot?.androidRestartSiYuan();
window.JSAndroid?.androidReboot();
}
});
});
Expand Down
10 changes: 0 additions & 10 deletions app/src/mobile/settings/devOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ export const initDevOptions = () => {
event.stopPropagation();
break;
}
// if (target.id === "JSAndroid_androidReboot") {
// window.JSAndroid?.androidReboot();
// event.preventDefault();
// event.stopPropagation();
// break;
// }
}
})
}
Expand Down Expand Up @@ -72,10 +66,6 @@ function genHTML() {
androidReboot
</button>
<div class="fn__hr"></div>
<button class="b3-button b3-button--outline fn__block" id="JSAndroid_restartSillotAndroid">
restartSillotAndroid
</button>
<div class="fn__hr"></div>
<button class="b3-button b3-button--outline fn__block" id="JSAndroid_exitSillotAndroid">
exitSillotAndroid
</button>
Expand Down
2 changes: 0 additions & 2 deletions app/src/mobile/util/MobileBackFoward.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ export const goForward = () => {
}
if (window.JSAndroid && forwardStack.length < 2) {
window.location.href = 'siyuan://api/system/exit';
// window.JSAndroid.exitSillotAndroid();
return;
}
if (forwardStack.length < 2) {
Expand Down Expand Up @@ -176,7 +175,6 @@ export const goBack = () => {
if (window.JSAndroid && window.siyuan.backStack.length < 1) {
if (document.querySelector('#message [data-id="exitTip"]')) {
window.location.href = 'siyuan://api/system/exit';
// window.JSAndroid.exitSillotAndroid();
} else {
showMessage(window.siyuan.languages.exitSillotAndroid, 3000, "info", "exitTip");
}
Expand Down
133 changes: 66 additions & 67 deletions app/src/sillot/index.ts
Original file line number Diff line number Diff line change
@@ -1,67 +1,66 @@
import { highlightRender } from "../protyle/render/highlightRender";
const lodash = require("lodash");
import { exAce } from "./ace";
import { Toastify } from "./react-toastify";
import { HotToast } from "./react-hot-toast";
import * as React from "react"; // 兼容性好
import * as ReactDOM from "react-dom"; // 兼容性好
import Swal from "sweetalert2";
import {sout} from 'sofill/core'
import { MusicPlayer } from "./react-music-player";
import VConsole from 'vconsole';
import {
focusBlock,
focusByOffset,
focusSideBlock,
focusByRange,
} from "../protyle/util/selection";
import { bS } from "./bridge";

export class SillotEnv {
constructor() {
window.sout = sout();
window.Sillot = {
status: { IDBloaded: false, disableDocSetPadding: false },
funs: { hljsRender: highlightRender },
lute: null,
androidRestartSiYuan: null,
};
window.__ = {
ace: null,
Swal: Swal,
toastify: new Toastify({ id: "app1", limit: 5, theme: "colored" }),
hottt: new HotToast({ id: "app3" }),
};
window._ = lodash;
window.React = React;
window.ReactDOM = ReactDOM;
exAce();
// new MusicPlayer({id: 'app4'})
window.nodebugger = {
focusBlock: focusBlock,
focusByOffset: focusByOffset,
focusSideBlock: focusSideBlock,
focusByRange: focusByRange,
/// #if !BROWSER
bS: new bS(),
///#endif
};
window.vConsole = new VConsole({ theme: 'dark' });
window.vConsole.hideSwitch();

// 接下来即可照常使用 `console` 等方法
console.log(window.vConsole.version);
document.querySelector("#toolbarConsole")?.addEventListener("click", () => {
if (document.querySelector("#toolbarConsole")?.getAttribute("data-mode") === "0") {
window.vConsole?.showSwitch();
document.querySelector("#toolbarConsole")?.setAttribute("data-mode", "1");
} else {
window.vConsole?.hideSwitch();
document.querySelector("#toolbarConsole")?.setAttribute("data-mode", "0");
}
});
// 结束调试后,可移除掉
// window.vConsole.destroy();

}
}
import { highlightRender } from "../protyle/render/highlightRender";
const lodash = require("lodash");
import { exAce } from "./ace";
import { Toastify } from "./react-toastify";
import { HotToast } from "./react-hot-toast";
import * as React from "react"; // 兼容性好
import * as ReactDOM from "react-dom"; // 兼容性好
import Swal from "sweetalert2";
import {sout} from 'sofill/core'
import { MusicPlayer } from "./react-music-player";
import VConsole from 'vconsole';
import {
focusBlock,
focusByOffset,
focusSideBlock,
focusByRange,
} from "../protyle/util/selection";
import { bS } from "./bridge";

export class SillotEnv {
constructor() {
window.sout = sout();
window.Sillot = {
status: { IDBloaded: false, disableDocSetPadding: false },
funs: { hljsRender: highlightRender },
lute: null,
};
window.__ = {
ace: null,
Swal: Swal,
toastify: new Toastify({ id: "app1", limit: 5, theme: "colored" }),
hottt: new HotToast({ id: "app3" }),
};
window._ = lodash;
window.React = React;
window.ReactDOM = ReactDOM;
exAce();
// new MusicPlayer({id: 'app4'})
window.nodebugger = {
focusBlock: focusBlock,
focusByOffset: focusByOffset,
focusSideBlock: focusSideBlock,
focusByRange: focusByRange,
/// #if !BROWSER
bS: new bS(),
///#endif
};
window.vConsole = new VConsole({ theme: 'dark' });
window.vConsole.hideSwitch();

// 接下来即可照常使用 `console` 等方法
console.log(window.vConsole.version);
document.querySelector("#toolbarConsole")?.addEventListener("click", () => {
if (document.querySelector("#toolbarConsole")?.getAttribute("data-mode") === "0") {
window.vConsole?.showSwitch();
document.querySelector("#toolbarConsole")?.setAttribute("data-mode", "1");
} else {
window.vConsole?.hideSwitch();
document.querySelector("#toolbarConsole")?.setAttribute("data-mode", "0");
}
});
// 结束调试后,可移除掉
// window.vConsole.destroy();

}
}
1 change: 0 additions & 1 deletion app/src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ interface Window {
requestPermissionActivity(id: string, Msg: string, cb: string): boolean
requestPermission(id: string, Msg: string): boolean
exitSillotAndroid(): void
restartSillotAndroid(): void
androidReboot(): void
savePictureByURL(uri: string): void
// sillot extend end
Expand Down
109 changes: 54 additions & 55 deletions app/src/types/sillot.d.ts
Original file line number Diff line number Diff line change
@@ -1,55 +1,54 @@
// declare module 'react-dom'
declare module "monaco-editor-nls/locale/zh-hans";
declare module "*.jsx";
declare module "*.js";

// REF https://www.tslang.cn/docs/handbook/declaration-merging.html
interface Window {
// Sillot extend
Sillot: ISillot;
nodebugger: any;
_: any;
__: ISillotDoubleUnderline;
sout: ISout;
React: any;
ReactDOM: any;
vConsole: any;
}

interface ISillot {
status: {
IDBloaded: boolean;
disableDocSetPadding: boolean;
};
funs: {
hljsRender: any;
};
lute: Lute;
androidRestartSiYuan: ()=>void;
}

interface ISout {
debug: boolean;
showAll(): void;
log(m: any): void;
slog(m: any): void;
print(m: any, head?: string): void;
info(m: any, head?: string): void;
success(m: any, head?: string): void;
warn(m: any, head?: string): void;
unsure(m: any, head?: string): void;
ops(m: any, head?: string): void;
error(m: any, head?: string): void;
good(m: any, head?: string): void;
wink(m: any, head?: string): void;
bad(m: any, head?: string): void;
tracker(m: any, ...additionalMessages: any[]): void;
table(m: Array<object>): void;
}

interface ISillotDoubleUnderline {
ace: any;
Swal: any;
toastify: any;
hottt: any;
}
// declare module 'react-dom'
declare module "monaco-editor-nls/locale/zh-hans";
declare module "*.jsx";
declare module "*.js";

// REF https://www.tslang.cn/docs/handbook/declaration-merging.html
interface Window {
// Sillot extend
Sillot: ISillot;
nodebugger: any;
_: any;
__: ISillotDoubleUnderline;
sout: ISout;
React: any;
ReactDOM: any;
vConsole: any;
}

interface ISillot {
status: {
IDBloaded: boolean;
disableDocSetPadding: boolean;
};
funs: {
hljsRender: any;
};
lute: Lute;
}

interface ISout {
debug: boolean;
showAll(): void;
log(m: any): void;
slog(m: any): void;
print(m: any, head?: string): void;
info(m: any, head?: string): void;
success(m: any, head?: string): void;
warn(m: any, head?: string): void;
unsure(m: any, head?: string): void;
ops(m: any, head?: string): void;
error(m: any, head?: string): void;
good(m: any, head?: string): void;
wink(m: any, head?: string): void;
bad(m: any, head?: string): void;
tracker(m: any, ...additionalMessages: any[]): void;
table(m: Array<object>): void;
}

interface ISillotDoubleUnderline {
ace: any;
Swal: any;
toastify: any;
hottt: any;
}
Loading

0 comments on commit 0fe46c5

Please sign in to comment.