Skip to content

Commit

Permalink
feat: support win
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfstark committed Sep 9, 2020
1 parent 5fabb3d commit 26a3ee8
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 11 deletions.
File renamed without changes
12 changes: 8 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
var nativefier = require("nativefier").default;
var package = require("./package.json");

const { PLATFORM } = process.env;
// @ts-check
console.log("PLATFORM", PLATFORM);

/**
* @type {import("nativefier/lib/options/model").NativefierOptions}
*/
var options = {
name: "wolai", // will be inferred if not specified
targetUrl: "https://www.wolai.com", // required
version: "1.0.1",
version: package.version,
out: "./dist",
zoom: 1.0,
platform: PLATFORM,
showMenuBar: false,
disableContextMenu: true,
icon: "./PNG/wolai_icon_512.png",
inject: ["./src/customjs.js"],
icon: "./assets/wolai_icon_512.png",
inject: [`./src/${PLATFORM}.js`],
titleBarStyle: "hiddenInset",
internalUrls: '.*?\.wolai\.*?',
internalUrls: ".*?.wolai.*?",
};
nativefier(options, function (error, appPath) {
if (error) {
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{
"name": "wolai",
"version": "1.0.0",
"version": "1.0.3",
"main": "index.js",
"homepage": "https://github.com/wolfstark/wolai-client",
"scripts": {
"build": "node index.js"
"build:osx": "cross-env PLATFORM=osx node index.js",
"build:win": "cross-env PLATFORM=windows node index.js"
},
"license": "MIT",
"dependencies": {
"cross-env": "^7.0.2",
"nativefier": "^10.1.0"
}
}
7 changes: 2 additions & 5 deletions src/customjs.js → src/osx.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function addStylesheetRules(rules) {
const addStylesheetRules = (rules) => {
const styleEl = document.createElement("style");

document.head.appendChild(styleEl);
Expand All @@ -23,7 +23,7 @@ function addStylesheetRules(rules) {
styleSheet.cssRules.length
);
}
}
};

addStylesheetRules({
"._3S0Sh": {
Expand Down Expand Up @@ -108,7 +108,4 @@ addStylesheetRules({
".cEs8w._3sa-7 ~ ._3G4KQ ._3xxlZ,._3G4KQ:first-child ._3xxlZ": {
"padding-left": "71px",
},
// "_3G4KQ:first-child ._3xxlZ": {
// "padding-left": "71px",
// },
});
98 changes: 98 additions & 0 deletions src/windows.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
const addStylesheetRules = (rules) => {
const styleEl = document.createElement("style");

document.head.appendChild(styleEl);

const styleSheet = styleEl.sheet;

const selectors = Object.keys(rules);

for (let i = 0; i < selectors.length; i++) {
const selector = selectors[i];
const rule = rules[selector];
const props = Object.keys(rule);
let propStr = "";

for (let j = 0; j < props.length; j++) {
const prop = props[j];
propStr += `${prop}: ${rule[prop]};\n`;
}

styleSheet.insertRule(
`${selector}{${propStr}}`,
styleSheet.cssRules.length
);
}
};

addStylesheetRules({
"._3S0Sh": {
transform: "none",
},
".modal-dialog-wrapper.text-action-bar-wrapper": {
position: "absolute !important",
},
".modal-dialog-wrapper.text-action-bar-wrapper > div": {
position: "absolute !important",
},
":root": {
"--wolai-editor-color": "rgb(59, 69, 78)",
"--wolai-caret-color": "#3b454e",
"--wolai-link-node-color": "#cf5659",
"--wolai-link-node-hover-color": "#c15b50",
"--wolai-header-page-title-color": "rgb(55, 53, 47)",
"--wolai-workspace-name-color": "rgb(55, 53, 47)",
"--wolai-sidebar-bg": "rgb(247, 246, 243)",
"--wolai-bg": "rgb(252, 249, 245)",
"--wolai-editor-bg": "rgb(252, 249, 245)",
},
"._2VNwp": {
"line-height": "1.625",
},
'.content-wrapper[data-block-type="text"]': {
padding: "8px 2px",
},

"html body": {
background: "rgb(252, 249, 245) !important",
"font-family":
'"zh quote", -apple-system, BlinkMacSystemFont, "Noto Sans", "Noto Sans CJK SC", "更纱黑体 UI SC","Microsoft YaHei", 微软雅黑, sans-serif, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',
},

'html[theme="dark"] body': {
background: "#252528 !important",
},

/* 编辑区icon */
"._3DZG7 path, ._3-gMw path": {
fill: "currentcolor",
color: "rgba(55, 53, 47, 0.8)",
},
"._2XCma path": {
color: "var(--wolai-svg-CF5659)",
},

'html[theme="dark"] ._3DZG7 path,html[theme="dark"] ._3-gMw path': {
color: "inherit",
},

/* 侧边栏 空间*/
"._3aHCs .xANBS": {
"font-weight": 500,
},

"._3aHCs .yMHfV": {
width: "20px",
height: "20px",
},

".gJqt_": {
"--wolai-svg-icon-312727": "rgba(55, 53, 47, 0.4)",
"--wolai-title-color": "rgba(25, 23, 17, 0.6)",
},

'html[theme="dark"] .gJqt_': {
"--wolai-svg-icon-312727": "inherit",
"--wolai-title-color": "inherit",
},
});
45 changes: 45 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,22 @@ [email protected], core-util-is@~1.0.0:
resolved "https://registry.npm.taobao.org/core-util-is/download/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=

cross-env@^7.0.2:
version "7.0.2"
resolved "https://registry.npm.taobao.org/cross-env/download/cross-env-7.0.2.tgz#bd5ed31339a93a3418ac4f3ca9ca3403082ae5f9"
integrity sha1-vV7TEzmpOjQYrE88qco0Awgq5fk=
dependencies:
cross-spawn "^7.0.1"

cross-spawn@^7.0.1:
version "7.0.3"
resolved "https://registry.npm.taobao.org/cross-spawn/download/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
integrity sha1-9zqFudXUHQRVUcF34ogtSshXKKY=
dependencies:
path-key "^3.1.0"
shebang-command "^2.0.0"
which "^2.0.1"

css-select@~1.2.0:
version "1.2.0"
resolved "https://registry.npm.taobao.org/css-select/download/css-select-1.2.0.tgz#2b3a110539c5355f1cd8d314623e870b121ec858"
Expand Down Expand Up @@ -1015,6 +1031,11 @@ isbinaryfile@^3.0.2:
dependencies:
buffer-alloc "^1.2.0"

isexe@^2.0.0:
version "2.0.0"
resolved "https://registry.npm.taobao.org/isexe/download/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=

isstream@~0.1.2:
version "0.1.2"
resolved "https://registry.npm.taobao.org/isstream/download/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a"
Expand Down Expand Up @@ -1367,6 +1388,11 @@ path-is-absolute@^1.0.0:
resolved "https://registry.npm.taobao.org/path-is-absolute/download/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18=

path-key@^3.1.0:
version "3.1.1"
resolved "https://registry.npm.taobao.org/path-key/download/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375"
integrity sha1-WB9q3mWMu6ZaDTOA3ndTKVBU83U=

path-parse@^1.0.6:
version "1.0.6"
resolved "https://registry.npm.taobao.org/path-parse/download/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c"
Expand Down Expand Up @@ -1602,6 +1628,18 @@ serialize-error@^7.0.1:
dependencies:
type-fest "^0.13.1"

shebang-command@^2.0.0:
version "2.0.0"
resolved "https://registry.npm.taobao.org/shebang-command/download/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea"
integrity sha1-zNCvT4g1+9wmW4JGGq8MNmY/NOo=
dependencies:
shebang-regex "^3.0.0"

shebang-regex@^3.0.0:
version "3.0.0"
resolved "https://registry.npm.taobao.org/shebang-regex/download/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172"
integrity sha1-rhbxZE2HPsrYQ7AwexQzYtTEIXI=

[email protected]:
version "0.8.4"
resolved "https://registry.npm.taobao.org/shelljs/download/shelljs-0.8.4.tgz#de7684feeb767f8716b326078a8a00875890e3c2"
Expand Down Expand Up @@ -1859,6 +1897,13 @@ whatwg-url-compat@~0.6.5:
dependencies:
tr46 "~0.0.1"

which@^2.0.1:
version "2.0.2"
resolved "https://registry.npm.taobao.org/which/download/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1"
integrity sha1-fGqN0KY2oDJ+ELWckobu6T8/UbE=
dependencies:
isexe "^2.0.0"

word-wrap@~1.2.3:
version "1.2.3"
resolved "https://registry.npm.taobao.org/word-wrap/download/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c"
Expand Down

0 comments on commit 26a3ee8

Please sign in to comment.