feat(search): 系统/用户app增加中文和拼音搜索

This commit is contained in:
徐志鹏 2021-07-27 21:29:53 +08:00
parent 129f19bf39
commit ae87a9bd5a
7 changed files with 542 additions and 379 deletions

243
package-lock.json generated
View File

@ -283,6 +283,55 @@
} }
} }
}, },
"@mapbox/node-pre-gyp": {
"version": "1.0.5",
"resolved": "https://registry.nlark.com/@mapbox/node-pre-gyp/download/@mapbox/node-pre-gyp-1.0.5.tgz",
"integrity": "sha1-Kgsy/LQW+z8iUP0kyyqBQhpPWVA=",
"dev": true,
"optional": true,
"requires": {
"detect-libc": "^1.0.3",
"https-proxy-agent": "^5.0.0",
"make-dir": "^3.1.0",
"node-fetch": "^2.6.1",
"nopt": "^5.0.0",
"npmlog": "^4.1.2",
"rimraf": "^3.0.2",
"semver": "^7.3.4",
"tar": "^6.1.0"
},
"dependencies": {
"make-dir": {
"version": "3.1.0",
"resolved": "https://registry.npm.taobao.org/make-dir/download/make-dir-3.1.0.tgz",
"integrity": "sha1-QV6WcEazp/HRhSd9hKpYIDcmoT8=",
"dev": true,
"optional": true,
"requires": {
"semver": "^6.0.0"
},
"dependencies": {
"semver": {
"version": "6.3.0",
"resolved": "https://registry.npm.taobao.org/semver/download/semver-6.3.0.tgz?cache=0&sync_timestamp=1616463641178&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsemver%2Fdownload%2Fsemver-6.3.0.tgz",
"integrity": "sha1-7gpkyK9ejO6mdoexM3YeG+y9HT0=",
"dev": true,
"optional": true
}
}
},
"nopt": {
"version": "5.0.0",
"resolved": "https://registry.npm.taobao.org/nopt/download/nopt-5.0.0.tgz?cache=0&sync_timestamp=1597649942437&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fnopt%2Fdownload%2Fnopt-5.0.0.tgz",
"integrity": "sha1-UwlCu1ilEvzK/lP+IQ8TolNV3Ig=",
"dev": true,
"optional": true,
"requires": {
"abbrev": "1"
}
}
}
},
"@samverschueren/stream-to-observable": { "@samverschueren/stream-to-observable": {
"version": "0.3.1", "version": "0.3.1",
"resolved": "http://npmreg.qa.91jkys.com/@samverschueren%2fstream-to-observable/-/stream-to-observable-0.3.1.tgz", "resolved": "http://npmreg.qa.91jkys.com/@samverschueren%2fstream-to-observable/-/stream-to-observable-0.3.1.tgz",
@ -939,7 +988,8 @@
"ansi-regex": { "ansi-regex": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "http://npmreg.qa.91jkys.com/ansi-regex/-/ansi-regex-3.0.0.tgz", "resolved": "http://npmreg.qa.91jkys.com/ansi-regex/-/ansi-regex-3.0.0.tgz",
"integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=" "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=",
"dev": true
}, },
"ansi-styles": { "ansi-styles": {
"version": "3.2.1", "version": "3.2.1",
@ -1136,7 +1186,8 @@
"aproba": { "aproba": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "http://npmreg.qa.91jkys.com/aproba/-/aproba-1.2.0.tgz", "resolved": "http://npmreg.qa.91jkys.com/aproba/-/aproba-1.2.0.tgz",
"integrity": "sha1-aALmJk79GMeQobDVF/DyYnvyyUo=" "integrity": "sha1-aALmJk79GMeQobDVF/DyYnvyyUo=",
"dev": true
}, },
"archive-type": { "archive-type": {
"version": "4.0.0", "version": "4.0.0",
@ -1157,6 +1208,7 @@
"version": "1.1.5", "version": "1.1.5",
"resolved": "http://npmreg.qa.91jkys.com/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz", "resolved": "http://npmreg.qa.91jkys.com/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz",
"integrity": "sha1-SzXClE8GKov82mZBB2A1D+nd/CE=", "integrity": "sha1-SzXClE8GKov82mZBB2A1D+nd/CE=",
"dev": true,
"requires": { "requires": {
"delegates": "^1.0.0", "delegates": "^1.0.0",
"readable-stream": "^2.0.6" "readable-stream": "^2.0.6"
@ -2640,6 +2692,11 @@
"tweetnacl": "^0.14.3" "tweetnacl": "^0.14.3"
} }
}, },
"big-integer": {
"version": "1.6.48",
"resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.48.tgz",
"integrity": "sha512-j51egjPa7/i+RdiRuJbPdJ2FIUYYPhvYLjzoYbcMMm62ooO6F94fETG4MTs46zPAF9Brs04OajboA/qTGuz78w=="
},
"big.js": { "big.js": {
"version": "5.2.2", "version": "5.2.2",
"resolved": "http://npmreg.qa.91jkys.com/big.js/-/big.js-5.2.2.tgz", "resolved": "http://npmreg.qa.91jkys.com/big.js/-/big.js-5.2.2.tgz",
@ -2888,6 +2945,14 @@
} }
} }
}, },
"bplist-parser": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.3.0.tgz",
"integrity": "sha512-zgmaRvT6AN1JpPPV+S0a1/FAtoxSreYDccZGIqEMSvZl9DMe70mJ7MFzpxa1X+gHVdkToE2haRUHHMiW1OdejA==",
"requires": {
"big-integer": "1.6.x"
}
},
"brace-expansion": { "brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"resolved": "http://npmreg.qa.91jkys.com/brace-expansion/-/brace-expansion-1.1.11.tgz", "resolved": "http://npmreg.qa.91jkys.com/brace-expansion/-/brace-expansion-1.1.11.tgz",
@ -4220,7 +4285,8 @@
"console-control-strings": { "console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "http://npmreg.qa.91jkys.com/console-control-strings/-/console-control-strings-1.1.0.tgz", "resolved": "http://npmreg.qa.91jkys.com/console-control-strings/-/console-control-strings-1.1.0.tgz",
"integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=",
"dev": true
}, },
"consolidate": { "consolidate": {
"version": "0.15.1", "version": "0.15.1",
@ -4951,7 +5017,8 @@
"delegates": { "delegates": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "http://npmreg.qa.91jkys.com/delegates/-/delegates-1.0.0.tgz", "resolved": "http://npmreg.qa.91jkys.com/delegates/-/delegates-1.0.0.tgz",
"integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=" "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=",
"dev": true
}, },
"depd": { "depd": {
"version": "1.1.2", "version": "1.1.2",
@ -4993,7 +5060,8 @@
"detect-libc": { "detect-libc": {
"version": "1.0.3", "version": "1.0.3",
"resolved": "http://npmreg.qa.91jkys.com/detect-libc/-/detect-libc-1.0.3.tgz", "resolved": "http://npmreg.qa.91jkys.com/detect-libc/-/detect-libc-1.0.3.tgz",
"integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=" "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=",
"dev": true
}, },
"detect-node": { "detect-node": {
"version": "2.1.0", "version": "2.1.0",
@ -6550,11 +6618,6 @@
} }
} }
}, },
"expand-template": {
"version": "2.0.3",
"resolved": "http://npmreg.qa.91jkys.com/expand-template/-/expand-template-2.0.3.tgz",
"integrity": "sha1-bhSz/O4POmNA7LV9LokYaSBSpHw="
},
"expand-tilde": { "expand-tilde": {
"version": "2.0.2", "version": "2.0.2",
"resolved": "http://npmreg.qa.91jkys.com/expand-tilde/-/expand-tilde-2.0.2.tgz", "resolved": "http://npmreg.qa.91jkys.com/expand-tilde/-/expand-tilde-2.0.2.tgz",
@ -7041,6 +7104,7 @@
"version": "2.7.4", "version": "2.7.4",
"resolved": "http://npmreg.qa.91jkys.com/gauge/-/gauge-2.7.4.tgz", "resolved": "http://npmreg.qa.91jkys.com/gauge/-/gauge-2.7.4.tgz",
"integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=",
"dev": true,
"requires": { "requires": {
"aproba": "^1.0.3", "aproba": "^1.0.3",
"console-control-strings": "^1.0.0", "console-control-strings": "^1.0.0",
@ -7055,12 +7119,14 @@
"ansi-regex": { "ansi-regex": {
"version": "2.1.1", "version": "2.1.1",
"resolved": "http://npmreg.qa.91jkys.com/ansi-regex/-/ansi-regex-2.1.1.tgz", "resolved": "http://npmreg.qa.91jkys.com/ansi-regex/-/ansi-regex-2.1.1.tgz",
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
"dev": true
}, },
"is-fullwidth-code-point": { "is-fullwidth-code-point": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "http://npmreg.qa.91jkys.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", "resolved": "http://npmreg.qa.91jkys.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz",
"integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=",
"dev": true,
"requires": { "requires": {
"number-is-nan": "^1.0.0" "number-is-nan": "^1.0.0"
} }
@ -7069,6 +7135,7 @@
"version": "1.0.2", "version": "1.0.2",
"resolved": "http://npmreg.qa.91jkys.com/string-width/-/string-width-1.0.2.tgz", "resolved": "http://npmreg.qa.91jkys.com/string-width/-/string-width-1.0.2.tgz",
"integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=",
"dev": true,
"requires": { "requires": {
"code-point-at": "^1.0.0", "code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0", "is-fullwidth-code-point": "^1.0.0",
@ -7079,6 +7146,7 @@
"version": "3.0.1", "version": "3.0.1",
"resolved": "http://npmreg.qa.91jkys.com/strip-ansi/-/strip-ansi-3.0.1.tgz", "resolved": "http://npmreg.qa.91jkys.com/strip-ansi/-/strip-ansi-3.0.1.tgz",
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
"dev": true,
"requires": { "requires": {
"ansi-regex": "^2.0.0" "ansi-regex": "^2.0.0"
} }
@ -7158,11 +7226,6 @@
"resolved": "http://npmreg.qa.91jkys.com/git-clone/-/git-clone-0.1.0.tgz", "resolved": "http://npmreg.qa.91jkys.com/git-clone/-/git-clone-0.1.0.tgz",
"integrity": "sha1-DXYWN3gJOu9/HDAjjyqe8/B6Lrk=" "integrity": "sha1-DXYWN3gJOu9/HDAjjyqe8/B6Lrk="
}, },
"github-from-package": {
"version": "0.0.0",
"resolved": "http://npmreg.qa.91jkys.com/github-from-package/-/github-from-package-0.0.0.tgz",
"integrity": "sha1-l/tdlr/eiXMxPyDoKI75oWf6ZM4="
},
"glob": { "glob": {
"version": "7.1.7", "version": "7.1.7",
"resolved": "http://npmreg.qa.91jkys.com/glob/-/glob-7.1.7.tgz", "resolved": "http://npmreg.qa.91jkys.com/glob/-/glob-7.1.7.tgz",
@ -7433,7 +7496,8 @@
"has-unicode": { "has-unicode": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "http://npmreg.qa.91jkys.com/has-unicode/-/has-unicode-2.0.1.tgz", "resolved": "http://npmreg.qa.91jkys.com/has-unicode/-/has-unicode-2.0.1.tgz",
"integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=" "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=",
"dev": true
}, },
"has-value": { "has-value": {
"version": "1.0.0", "version": "1.0.0",
@ -8244,7 +8308,8 @@
"is-fullwidth-code-point": { "is-fullwidth-code-point": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "http://npmreg.qa.91jkys.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", "resolved": "http://npmreg.qa.91jkys.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz",
"integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=" "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=",
"dev": true
}, },
"is-glob": { "is-glob": {
"version": "4.0.1", "version": "4.0.1",
@ -8667,6 +8732,12 @@
"resolved": "http://npmreg.qa.91jkys.com/keycode/-/keycode-2.2.0.tgz", "resolved": "http://npmreg.qa.91jkys.com/keycode/-/keycode-2.2.0.tgz",
"integrity": "sha1-PQr1bce4uOXLqNCpfxByBO7CKwQ=" "integrity": "sha1-PQr1bce4uOXLqNCpfxByBO7CKwQ="
}, },
"keypress": {
"version": "0.1.0",
"resolved": "https://registry.npm.taobao.org/keypress/download/keypress-0.1.0.tgz",
"integrity": "sha1-SjGI1CkbZrT2XtuZ+AaqmuKTWSo=",
"dev": true
},
"keyv": { "keyv": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "http://npmreg.qa.91jkys.com/keyv/-/keyv-3.0.0.tgz", "resolved": "http://npmreg.qa.91jkys.com/keyv/-/keyv-3.0.0.tgz",
@ -9644,11 +9715,6 @@
"minimist": "^1.2.5" "minimist": "^1.2.5"
} }
}, },
"mkdirp-classic": {
"version": "0.5.3",
"resolved": "http://npmreg.qa.91jkys.com/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz",
"integrity": "sha1-+hDJEVzG2IZb4iG6R+6b7XhgERM="
},
"moment": { "moment": {
"version": "2.29.1", "version": "2.29.1",
"resolved": "http://npmreg.qa.91jkys.com/moment/-/moment-2.29.1.tgz", "resolved": "http://npmreg.qa.91jkys.com/moment/-/moment-2.29.1.tgz",
@ -9864,7 +9930,9 @@
"nan": { "nan": {
"version": "2.14.2", "version": "2.14.2",
"resolved": "http://npmreg.qa.91jkys.com/nan/-/nan-2.14.2.tgz", "resolved": "http://npmreg.qa.91jkys.com/nan/-/nan-2.14.2.tgz",
"integrity": "sha1-9TdkAGlRaPTMaUrJOT0MlYXu6hk=" "integrity": "sha1-9TdkAGlRaPTMaUrJOT0MlYXu6hk=",
"dev": true,
"optional": true
}, },
"nanomatch": { "nanomatch": {
"version": "1.2.13", "version": "1.2.13",
@ -9908,11 +9976,6 @@
"resolved": "http://npmreg.qa.91jkys.com/nanopop/-/nanopop-2.1.0.tgz", "resolved": "http://npmreg.qa.91jkys.com/nanopop/-/nanopop-2.1.0.tgz",
"integrity": "sha1-I0dlE87iQFiIr9LopLVAZrcLnmA=" "integrity": "sha1-I0dlE87iQFiIr9LopLVAZrcLnmA="
}, },
"napi-build-utils": {
"version": "1.0.2",
"resolved": "http://npmreg.qa.91jkys.com/napi-build-utils/-/napi-build-utils-1.0.2.tgz",
"integrity": "sha1-sf3cCyxG44Cgt6dvmE3UfEGhOAY="
},
"natives": { "natives": {
"version": "1.1.6", "version": "1.1.6",
"resolved": "http://npmreg.qa.91jkys.com/natives/-/natives-1.1.6.tgz", "resolved": "http://npmreg.qa.91jkys.com/natives/-/natives-1.1.6.tgz",
@ -9986,6 +10049,7 @@
"version": "2.30.0", "version": "2.30.0",
"resolved": "http://npmreg.qa.91jkys.com/node-abi/-/node-abi-2.30.0.tgz", "resolved": "http://npmreg.qa.91jkys.com/node-abi/-/node-abi-2.30.0.tgz",
"integrity": "sha1-i+U78+eUWjTuoQ4PyaWYJ3bPVQs=", "integrity": "sha1-i+U78+eUWjTuoQ4PyaWYJ3bPVQs=",
"dev": true,
"requires": { "requires": {
"semver": "^5.4.1" "semver": "^5.4.1"
}, },
@ -9993,7 +10057,8 @@
"semver": { "semver": {
"version": "5.7.1", "version": "5.7.1",
"resolved": "http://npmreg.qa.91jkys.com/semver/-/semver-5.7.1.tgz", "resolved": "http://npmreg.qa.91jkys.com/semver/-/semver-5.7.1.tgz",
"integrity": "sha1-qVT5Ma66UI0we78Gnv8MAclhFvc=" "integrity": "sha1-qVT5Ma66UI0we78Gnv8MAclhFvc=",
"dev": true
} }
} }
}, },
@ -10166,6 +10231,26 @@
} }
} }
}, },
"nodejieba": {
"version": "2.5.2",
"resolved": "https://registry.nlark.com/nodejieba/download/nodejieba-2.5.2.tgz?cache=0&sync_timestamp=1619409865538&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fnodejieba%2Fdownload%2Fnodejieba-2.5.2.tgz",
"integrity": "sha1-/JKe4p+Twoxjlpa6wDGbrBFqKWo=",
"dev": true,
"optional": true,
"requires": {
"@mapbox/node-pre-gyp": "^1.0.4",
"node-addon-api": "^3.0.2"
},
"dependencies": {
"node-addon-api": {
"version": "3.2.1",
"resolved": "https://registry.nlark.com/node-addon-api/download/node-addon-api-3.2.1.tgz",
"integrity": "sha1-gTJeCiEXeJwBKNq2Xn448HzroWE=",
"dev": true,
"optional": true
}
}
},
"nopt": { "nopt": {
"version": "4.0.3", "version": "4.0.3",
"resolved": "http://npmreg.qa.91jkys.com/nopt/-/nopt-4.0.3.tgz", "resolved": "http://npmreg.qa.91jkys.com/nopt/-/nopt-4.0.3.tgz",
@ -10284,6 +10369,7 @@
"version": "4.1.2", "version": "4.1.2",
"resolved": "http://npmreg.qa.91jkys.com/npmlog/-/npmlog-4.1.2.tgz", "resolved": "http://npmreg.qa.91jkys.com/npmlog/-/npmlog-4.1.2.tgz",
"integrity": "sha1-CKfyqL9zRgR3mp76StXMcXq7lUs=", "integrity": "sha1-CKfyqL9zRgR3mp76StXMcXq7lUs=",
"dev": true,
"requires": { "requires": {
"are-we-there-yet": "~1.1.2", "are-we-there-yet": "~1.1.2",
"console-control-strings": "~1.1.0", "console-control-strings": "~1.1.0",
@ -11082,6 +11168,28 @@
"pinkie": "^2.0.0" "pinkie": "^2.0.0"
} }
}, },
"pinyin": {
"version": "2.10.2",
"resolved": "https://registry.npm.taobao.org/pinyin/download/pinyin-2.10.2.tgz",
"integrity": "sha1-k+Ozy0QwAJklFjutEMdBd4yFsBM=",
"dev": true,
"requires": {
"commander": "~1.1.1",
"nodejieba": "^2.2.1",
"object-assign": "^4.0.1"
},
"dependencies": {
"commander": {
"version": "1.1.1",
"resolved": "https://registry.nlark.com/commander/download/commander-1.1.1.tgz?cache=0&sync_timestamp=1624609539421&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fcommander%2Fdownload%2Fcommander-1.1.1.tgz",
"integrity": "sha1-UNFlGGiuYOzP8KLZ80WVN2vGsEE=",
"dev": true,
"requires": {
"keypress": "0.1.x"
}
}
}
},
"pkg-dir": { "pkg-dir": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "http://npmreg.qa.91jkys.com/pkg-dir/-/pkg-dir-2.0.0.tgz", "resolved": "http://npmreg.qa.91jkys.com/pkg-dir/-/pkg-dir-2.0.0.tgz",
@ -11701,37 +11809,6 @@
"uniqs": "^2.0.0" "uniqs": "^2.0.0"
} }
}, },
"prebuild-install": {
"version": "6.1.3",
"resolved": "http://npmreg.qa.91jkys.com/prebuild-install/-/prebuild-install-6.1.3.tgz",
"integrity": "sha1-jqH51zhqCzD37yAkfjb4srgoJaI=",
"requires": {
"detect-libc": "^1.0.3",
"expand-template": "^2.0.3",
"github-from-package": "0.0.0",
"minimist": "^1.2.3",
"mkdirp-classic": "^0.5.3",
"napi-build-utils": "^1.0.1",
"node-abi": "^2.21.0",
"npmlog": "^4.0.1",
"pump": "^3.0.0",
"rc": "^1.2.7",
"simple-get": "^3.0.3",
"tar-fs": "^2.0.0",
"tunnel-agent": "^0.6.0"
},
"dependencies": {
"pump": {
"version": "3.0.0",
"resolved": "http://npmreg.qa.91jkys.com/pump/-/pump-3.0.0.tgz",
"integrity": "sha1-tKIRaBW94vTh6mAjVOjHVWUQemQ=",
"requires": {
"end-of-stream": "^1.1.0",
"once": "^1.3.1"
}
}
}
},
"prepend-http": { "prepend-http": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "http://npmreg.qa.91jkys.com/prepend-http/-/prepend-http-2.0.0.tgz", "resolved": "http://npmreg.qa.91jkys.com/prepend-http/-/prepend-http-2.0.0.tgz",
@ -12809,14 +12886,6 @@
} }
} }
}, },
"robotjs": {
"version": "git+ssh://git@github.com/Toinane/robotjs.git#66bf4fe6206d25400eed6090f9e68326faf3c18a",
"from": "git+ssh://git@github.com/Toinane/robotjs.git",
"requires": {
"nan": "^2.14.2",
"prebuild-install": "^6.1.2"
}
},
"run-queue": { "run-queue": {
"version": "1.0.3", "version": "1.0.3",
"resolved": "http://npmreg.qa.91jkys.com/run-queue/-/run-queue-1.0.3.tgz", "resolved": "http://npmreg.qa.91jkys.com/run-queue/-/run-queue-1.0.3.tgz",
@ -13046,7 +13115,8 @@
"set-blocking": { "set-blocking": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "http://npmreg.qa.91jkys.com/set-blocking/-/set-blocking-2.0.0.tgz", "resolved": "http://npmreg.qa.91jkys.com/set-blocking/-/set-blocking-2.0.0.tgz",
"integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=",
"dev": true
}, },
"set-value": { "set-value": {
"version": "2.0.1", "version": "2.0.1",
@ -13122,36 +13192,6 @@
"resolved": "http://npmreg.qa.91jkys.com/signal-exit/-/signal-exit-3.0.3.tgz", "resolved": "http://npmreg.qa.91jkys.com/signal-exit/-/signal-exit-3.0.3.tgz",
"integrity": "sha1-oUEMLt2PB3sItOJTyOrPyvBXRhw=" "integrity": "sha1-oUEMLt2PB3sItOJTyOrPyvBXRhw="
}, },
"simple-concat": {
"version": "1.0.1",
"resolved": "http://npmreg.qa.91jkys.com/simple-concat/-/simple-concat-1.0.1.tgz",
"integrity": "sha1-9Gl2CCujXCJj8cirXt/ibEHJVS8="
},
"simple-get": {
"version": "3.1.0",
"resolved": "http://npmreg.qa.91jkys.com/simple-get/-/simple-get-3.1.0.tgz",
"integrity": "sha1-tFvgYkNeUNFZVAtXYgLO7EC5xrM=",
"requires": {
"decompress-response": "^4.2.0",
"once": "^1.3.1",
"simple-concat": "^1.0.0"
},
"dependencies": {
"decompress-response": {
"version": "4.2.1",
"resolved": "http://npmreg.qa.91jkys.com/decompress-response/-/decompress-response-4.2.1.tgz",
"integrity": "sha1-QUAjzHowLaJc4uyC0NUjjMr9iYY=",
"requires": {
"mimic-response": "^2.0.0"
}
},
"mimic-response": {
"version": "2.1.0",
"resolved": "http://npmreg.qa.91jkys.com/mimic-response/-/mimic-response-2.1.0.tgz",
"integrity": "sha1-0Tdj019hPQnsN+uzC6wEacDuj0M="
}
}
},
"single-line-log": { "single-line-log": {
"version": "1.1.2", "version": "1.1.2",
"resolved": "https://registry.npm.taobao.org/single-line-log/download/single-line-log-1.1.2.tgz", "resolved": "https://registry.npm.taobao.org/single-line-log/download/single-line-log-1.1.2.tgz",
@ -13783,6 +13823,7 @@
"version": "2.1.1", "version": "2.1.1",
"resolved": "http://npmreg.qa.91jkys.com/string-width/-/string-width-2.1.1.tgz", "resolved": "http://npmreg.qa.91jkys.com/string-width/-/string-width-2.1.1.tgz",
"integrity": "sha1-q5Pyeo3BPSjKyBXEYhQ6bZASrp4=", "integrity": "sha1-q5Pyeo3BPSjKyBXEYhQ6bZASrp4=",
"dev": true,
"requires": { "requires": {
"is-fullwidth-code-point": "^2.0.0", "is-fullwidth-code-point": "^2.0.0",
"strip-ansi": "^4.0.0" "strip-ansi": "^4.0.0"
@ -13820,6 +13861,7 @@
"version": "4.0.0", "version": "4.0.0",
"resolved": "http://npmreg.qa.91jkys.com/strip-ansi/-/strip-ansi-4.0.0.tgz", "resolved": "http://npmreg.qa.91jkys.com/strip-ansi/-/strip-ansi-4.0.0.tgz",
"integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=",
"dev": true,
"requires": { "requires": {
"ansi-regex": "^3.0.0" "ansi-regex": "^3.0.0"
} }
@ -16134,6 +16176,7 @@
"version": "1.1.3", "version": "1.1.3",
"resolved": "http://npmreg.qa.91jkys.com/wide-align/-/wide-align-1.1.3.tgz", "resolved": "http://npmreg.qa.91jkys.com/wide-align/-/wide-align-1.1.3.tgz",
"integrity": "sha1-rgdOa9wMFKQx6ATmJFScYzsABFc=", "integrity": "sha1-rgdOa9wMFKQx6ATmJFScYzsABFc=",
"dev": true,
"requires": { "requires": {
"string-width": "^1.0.2 || 2" "string-width": "^1.0.2 || 2"
} }

View File

@ -60,6 +60,7 @@
"dependencies": { "dependencies": {
"ant-design-vue": "^1.7.5", "ant-design-vue": "^1.7.5",
"axios": "^0.18.1", "axios": "^0.18.1",
"bplist-parser": "^0.3.0",
"download": "^8.0.0", "download": "^8.0.0",
"download-git-repo": "^3.0.2", "download-git-repo": "^3.0.2",
"electron-store": "^8.0.0", "electron-store": "^8.0.0",
@ -73,9 +74,9 @@
"puppeteer-core": "^10.0.0", "puppeteer-core": "^10.0.0",
"puppeteer-in-electron": "^3.0.3", "puppeteer-in-electron": "^3.0.3",
"query-string": "^7.0.0", "query-string": "^7.0.0",
"robotjs": "git+https://github.com/Toinane/robotjs.git",
"request": "^2.88.2", "request": "^2.88.2",
"request-promise": "^4.2.6", "request-promise": "^4.2.6",
"robotjs": "git+https://github.com/Toinane/robotjs.git",
"semver": "^7.3.5", "semver": "^7.3.5",
"sudo-prompt": "^9.2.1", "sudo-prompt": "^9.2.1",
"unzip": "^0.1.11", "unzip": "^0.1.11",
@ -109,6 +110,7 @@
"electron-rebuild": "^2.3.5", "electron-rebuild": "^2.3.5",
"file-loader": "^1.1.11", "file-loader": "^1.1.11",
"html-webpack-plugin": "^3.2.0", "html-webpack-plugin": "^3.2.0",
"iconv-lite": "^0.6.3",
"less": "^4.1.1", "less": "^4.1.1",
"less-loader": "^5.0.0", "less-loader": "^5.0.0",
"listr": "^0.14.3", "listr": "^0.14.3",
@ -116,6 +118,7 @@
"multispinner": "^0.2.1", "multispinner": "^0.2.1",
"node-abi": "^2.30.0", "node-abi": "^2.30.0",
"node-loader": "^0.6.0", "node-loader": "^0.6.0",
"pinyin": "^2.10.2",
"react": "^17.0.2", "react": "^17.0.2",
"style-loader": "^0.21.0", "style-loader": "^0.21.0",
"url-loader": "^1.0.1", "url-loader": "^1.0.1",

View File

@ -14,24 +14,39 @@
</div> </div>
<a-input <a-input
id="search" id="search"
:placeholder="subPlaceHolder && selected && selected.key === 'plugin-container' ? subPlaceHolder : 'Hi, Rubick'" :placeholder="
subPlaceHolder && selected && selected.key === 'plugin-container'
? subPlaceHolder
: 'Hi, Rubick'
"
class="main-input" class="main-input"
@change="e => search({value: e.target.value})" @change="(e) => search({ value: e.target.value })"
:value="searchValue" :value="searchValue"
:maxLength="selected && selected.key !== 'plugin-container' ? 0 : 1000" :maxLength="selected && selected.key !== 'plugin-container' ? 0 : 1000"
@keydown.down="(e) => changeCurrent(1)" @keydown.down="(e) => changeCurrent(1)"
@keydown.up="() => changeCurrent(-1)" @keydown.up="() => changeCurrent(-1)"
@keypress.enter="(e) => targetSearch({value: e.target.value, type: 'enter'})" @keypress.enter="
@keypress.space="(e) => targetSearch({value: e.target.value, type: 'space'})" (e) => targetSearch({ value: e.target.value, type: 'enter' })
"
@keypress.space="
(e) => targetSearch({ value: e.target.value, type: 'space' })
"
> >
<div @click="goMenu" class="suffix-tool" slot="suffix"> <div @click="goMenu" class="suffix-tool" slot="suffix">
<a-icon v-show="selected && selected.key === 'plugin-container'" class="icon-more" type="more" /> <a-icon
<img class="icon-tool" v-if="selected && selected.icon" :src="selected.icon" /> v-show="selected && selected.key === 'plugin-container'"
class="icon-more"
type="more"
/>
<img
class="icon-tool"
v-if="selected && selected.icon"
:src="selected.icon"
/>
<div v-else class="rubick-logo"> <div v-else class="rubick-logo">
<img src="./assets/logo.png" /> <img src="./assets/logo.png" />
</div> </div>
</div> </div>
</a-input> </a-input>
<div class="options" v-show="showOptions"> <div class="options" v-show="showOptions">
<a-list item-layout="horizontal" :data-source="options"> <a-list item-layout="horizontal" :data-source="options">
@ -41,13 +56,11 @@
slot="renderItem" slot="renderItem"
slot-scope="item, index" slot-scope="item, index"
> >
<a-list-item-meta <a-list-item-meta :description="item.desc">
:description="item.desc" <span slot="title" v-html="renderTitle(item.name)"></span>
>
<span slot="title" v-html="renderTitle(item.name)" ></span>
<a-avatar <a-avatar
slot="avatar" slot="avatar"
style="border-radius: 0;" style="border-radius: 0"
:src="item.icon" :src="item.icon"
/> />
</a-list-item-meta> </a-list-item-meta>
@ -59,14 +72,28 @@
</div> </div>
<div class="rubick-select-subMenu" v-else> <div class="rubick-select-subMenu" v-else>
<div> <div>
<img class="icon-tool-sub" v-if="pluginInfo.icon" :src="pluginInfo.icon" /> <img
class="icon-tool-sub"
v-if="pluginInfo.icon"
:src="pluginInfo.icon"
/>
<a-input <a-input
:placeholder="subPlaceHolder" :placeholder="subPlaceHolder"
class="sub-input" class="sub-input"
@change="(e) => search({value: e.target.value, searchType: pluginInfo.searchType})" @change="
(e) =>
search({
value: e.target.value,
searchType: pluginInfo.searchType,
})
"
:value="searchValue" :value="searchValue"
@keypress.enter="(e) => targetSearch({value: e.target.value, type: 'enter'})" @keypress.enter="
@keypress.space="(e) => targetSearch({value: e.target.value, type: 'space'})" (e) => targetSearch({ value: e.target.value, type: 'enter' })
"
@keypress.space="
(e) => targetSearch({ value: e.target.value, type: 'space' })
"
></a-input> ></a-input>
</div> </div>
@ -79,11 +106,16 @@
</a-layout> </a-layout>
</template> </template>
<script> <script>
import {mapActions, mapMutations, mapState} from "vuex"; import { mapActions, mapMutations, mapState } from "vuex";
import {ipcRenderer, remote} from "electron"; import { ipcRenderer, remote } from "electron";
import {getWindowHeight, debounce, searchKeyValues, fileLists} from "./assets/common/utils"; import {
const opConfig = remote.getGlobal('opConfig'); getWindowHeight,
const {Menu, MenuItem} = remote; debounce,
searchKeyValues,
fileLists,
} from "./assets/common/utils";
const opConfig = remote.getGlobal("opConfig");
const { Menu, MenuItem } = remote;
export default { export default {
data() { data() {
@ -92,7 +124,7 @@ export default {
searchFn: null, searchFn: null,
config: opConfig.get(), config: opConfig.get(),
currentSelect: 0, currentSelect: 0,
} };
}, },
created() { created() {
@ -100,17 +132,17 @@ export default {
this.commonUpdate({ this.commonUpdate({
pluginInfo: pluginInfo, pluginInfo: pluginInfo,
}); });
} };
}, },
mounted() { mounted() {
ipcRenderer.on('init-rubick', this.closeTag); ipcRenderer.on("init-rubick", this.closeTag);
ipcRenderer.on('new-window', this.newWindow); ipcRenderer.on("new-window", this.newWindow);
// //
ipcRenderer.on('superPanel-openPlugin', (e, args) => { ipcRenderer.on("superPanel-openPlugin", (e, args) => {
this.closeTag(); this.closeTag();
ipcRenderer.send('msg-trigger', { ipcRenderer.send("msg-trigger", {
type: 'showMainWindow', type: "showMainWindow",
}); });
this.openPlugin({ this.openPlugin({
cmd: args.cmd, cmd: args.cmd,
@ -118,45 +150,47 @@ export default {
feature: args.feature, feature: args.feature,
router: this.$router, router: this.$router,
payload: args.data, payload: args.data,
})
}); });
ipcRenderer.on('global-short-key', (e, args) => { });
ipcRenderer.on("global-short-key", (e, args) => {
let config; let config;
this.devPlugins.forEach((plugin) => { this.devPlugins.forEach((plugin) => {
// dev // dev
if (plugin.type === 'dev' && !plugin.status) return; if (plugin.type === "dev" && !plugin.status) return;
const feature = plugin.features; const feature = plugin.features;
feature.forEach(fe => { feature.forEach((fe) => {
const cmd = searchKeyValues(fe.cmds, args)[0]; const cmd = searchKeyValues(fe.cmds, args)[0];
const systemPlugin = fileLists.filter(plugin => plugin.name.indexOf(args) >= 0)[0]; const systemPlugin = fileLists.filter(
(plugin) => plugin.name.indexOf(args) >= 0
)[0];
if (cmd) { if (cmd) {
config = { config = {
cmd: cmd, cmd: cmd,
plugin: plugin, plugin: plugin,
feature: fe, feature: fe,
router: this.$router router: this.$router,
} };
} else if (systemPlugin) { } else if (systemPlugin) {
config = { config = {
plugin: systemPlugin, plugin: systemPlugin,
router: this.$router router: this.$router,
};
} }
} });
})
}); });
config && this.openPlugin(config); config && this.openPlugin(config);
}); });
// //
ipcRenderer.on('tray-setting', () => { ipcRenderer.on("tray-setting", () => {
this.showMainUI(); this.showMainUI();
this.changePath({key: 'settings'}); this.changePath({ key: "settings" });
}); });
const searchNd = document.getElementById('search'); const searchNd = document.getElementById("search");
searchNd && searchNd.addEventListener('keydown', this.checkNeedInit) searchNd && searchNd.addEventListener("keydown", this.checkNeedInit);
}, },
methods: { methods: {
...mapActions('main', ['onSearch', 'showMainUI', 'openPlugin']), ...mapActions("main", ["onSearch", "showMainUI", "openPlugin"]),
...mapMutations('main', ['commonUpdate']), ...mapMutations("main", ["commonUpdate"]),
search(v) { search(v) {
if (!this.searchFn) { if (!this.searchFn) {
this.searchFn = debounce(this.onSearch, 200); this.searchFn = debounce(this.onSearch, 200);
@ -165,44 +199,55 @@ export default {
}, },
targetSearch(action) { targetSearch(action) {
// //
if((this.selected && this.selected.key === 'plugin-container') || this.searchType === 'subWindow') { if (
const webview = document.getElementById('webview'); (this.selected && this.selected.key === "plugin-container") ||
if (action.type === 'space') { this.searchType === "subWindow"
) {
const webview = document.getElementById("webview");
if (action.type === "space") {
if (this.config.perf.common.space) { if (this.config.perf.common.space) {
webview.send('msg-back-setSubInput', this.searchValue); webview.send("msg-back-setSubInput", this.searchValue);
} }
return; return;
} }
webview.send('msg-back-setSubInput', this.searchValue); webview.send("msg-back-setSubInput", this.searchValue);
} else if (this.showOptions) { } else if (this.showOptions) {
const item = this.options[this.currentSelect] const item = this.options[this.currentSelect];
item.click(this.$router); item.click(this.$router);
} }
}, },
changeCurrent(index) { changeCurrent(index) {
const webview = document.getElementById('webview'); const webview = document.getElementById("webview");
webview && webview.send('changeCurrent', index); webview && webview.send("changeCurrent", index);
if (!this.options) return; if (!this.options) return;
if (this.currentSelect + index > this.options.length - 1 || this.currentSelect + index < 0) return; if (
this.currentSelect + index > this.options.length - 1 ||
this.currentSelect + index < 0
)
return;
this.currentSelect = this.currentSelect + index; this.currentSelect = this.currentSelect + index;
}, },
renderTitle(title) { renderTitle(title) {
if (typeof title !== 'string') return; if (typeof title !== "string") return;
const result = title.split(this.searchValue); const result = title.split(this.searchValue);
return `<div>${result[0]}<span style="color: red">${this.searchValue}</span>${result[1]}</div>` if (result && result.length > 1) {
return `<div>${result[0]}<span style="color: red">${this.searchValue}</span>${result[1]}</div>`;
} else {
return `<div>${result[0]}</div>`;
}
}, },
checkNeedInit(e) { checkNeedInit(e) {
// tag // tag
if (this.searchValue === '' && e.keyCode === 8) { if (this.searchValue === "" && e.keyCode === 8) {
this.closeTag(); this.closeTag();
} }
}, },
changePath({key}) { changePath({ key }) {
this.$router.push({path: `/home/${key}`}); this.$router.push({ path: `/home/${key}` });
this.commonUpdate({ this.commonUpdate({
current: [key] current: [key],
}) });
}, },
closeTag(v) { closeTag(v) {
this.commonUpdate({ this.commonUpdate({
@ -210,60 +255,72 @@ export default {
showMain: false, showMain: false,
options: [], options: [],
}); });
ipcRenderer.send('changeWindowSize-rubick', { ipcRenderer.send("changeWindowSize-rubick", {
height: getWindowHeight([]), height: getWindowHeight([]),
}); });
this.$router.push({ this.$router.push({
path: '/home', path: "/home",
}); });
}, },
newWindow() { newWindow() {
ipcRenderer.send('new-window', { ipcRenderer.send("new-window", {
...this.pluginInfo ...this.pluginInfo,
}); });
this.closeTag(); this.closeTag();
}, },
goMenu(type) { goMenu(type) {
if ((this.selected && this.selected.key === 'plugin-container') || type === 'separate') { if (
(this.selected && this.selected.key === "plugin-container") ||
type === "separate"
) {
const pluginMenu = [ const pluginMenu = [
{ {
label: '开发者工具', label: "开发者工具",
click: () => { click: () => {
const webview = document.getElementById('webview'); const webview = document.getElementById("webview");
webview.openDevTools() webview.openDevTools();
} },
}, },
{ {
label: '当前插件信息', label: "当前插件信息",
submenu: [ submenu: [
{ {
label: '简介', label: "简介",
}, },
{ {
label: '功能' label: "功能",
} },
] ],
}, },
{ {
label: '隐藏插件', label: "隐藏插件",
}, },
]; ];
if (type !== 'separate') { if (type !== "separate") {
pluginMenu.unshift({ pluginMenu.unshift({
label: '分离窗口', label: "分离窗口",
click: this.newWindow click: this.newWindow,
}) });
} }
let menu = Menu.buildFromTemplate(pluginMenu); let menu = Menu.buildFromTemplate(pluginMenu);
menu.popup(); menu.popup();
return; return;
} }
this.showMainUI(); this.showMainUI();
this.changePath({key: 'market'}) this.changePath({ key: "market" });
}, },
}, },
computed: { computed: {
...mapState('main', ['showMain', 'devPlugins', 'current', 'options', 'selected', 'searchValue', 'subPlaceHolder', 'pluginInfo']), ...mapState("main", [
"showMain",
"devPlugins",
"current",
"options",
"selected",
"searchValue",
"subPlaceHolder",
"pluginInfo",
]),
showOptions() { showOptions() {
// //
if (this.options.length && !this.showMain) { if (this.options.length && !this.showMain) {
@ -271,9 +328,9 @@ export default {
} }
}, },
searchType() { searchType() {
return this.pluginInfo.searchType ? 'subWindow' : '' return this.pluginInfo.searchType ? "subWindow" : "";
} },
} },
}; };
</script> </script>
<style lang="less"> <style lang="less">
@ -289,7 +346,8 @@ export default {
width: 0; width: 0;
} }
} }
.rubick-select, .rubick-select-subMenu { .rubick-select,
.rubick-select-subMenu {
display: flex; display: flex;
padding-left: 10px; padding-left: 10px;
background: #fff; background: #fff;
@ -333,7 +391,7 @@ export default {
left: 0; left: 0;
width: 100%; width: 100%;
z-index: 99; z-index: 99;
max-height: calc(~'100vh - 60px'); max-height: calc(~"100vh - 60px");
overflow: auto; overflow: auto;
.op-item { .op-item {
padding: 0 10px; padding: 0 10px;
@ -343,7 +401,7 @@ export default {
overflow: auto; overflow: auto;
background: #fafafa; background: #fafafa;
&.active { &.active {
background: #DEE2E8; background: #dee2e8;
} }
} }
} }

View File

@ -1,4 +1,4 @@
export default { export default {
development: 'http://118.195.176.247:8080', development: 'http://118.195.176.247:8080',
production: 'http://118.195.176.247:8080', production: 'http://118.195.176.247:8080'
}; };

View File

@ -4,65 +4,55 @@ const PRE_ITEM_HEIGHT = 60;
const SYSTEM_PLUGINS = [ const SYSTEM_PLUGINS = [
{ {
"pluginName": "rubick 帮助文档", pluginName: 'rubick 帮助文档',
"logo": require('../imgs/help.png'), logo: require('../imgs/help.png'),
"features": [ features: [
{ {
"code": "help", code: 'help',
"explain": "rubick 帮助文档", explain: 'rubick 帮助文档',
"cmds": [ "Help", "帮助" ] cmds: ['Help', '帮助']
}, }
], ],
"tag": 'rubick-help', tag: 'rubick-help'
}, },
{ {
"pluginName": "屏幕颜色拾取", pluginName: '屏幕颜色拾取',
"logo": require('../imgs/picker.png'), logo: require('../imgs/picker.png'),
"features": [ features: [
{ {
"code": "pick", code: 'pick',
"explain": "rubick 帮助文档", explain: 'rubick 帮助文档',
"cmds": [ "取色", "拾色", 'Pick color' ] cmds: ['取色', '拾色', 'Pick color']
}, }
], ],
"tag": 'rubick-color', tag: 'rubick-color'
}, },
{ {
"pluginName": "截屏", pluginName: '截屏',
"logo": require('../imgs/screenshot.png'), logo: require('../imgs/screenshot.png'),
"features": [ features: [
{ {
"code": "shortCut", code: 'shortCut',
"explain": "rubick 屏幕截取", explain: 'rubick 屏幕截取',
"cmds": [ "截屏", "shortCut" ] cmds: ['截屏', 'shortCut']
}, }
], ],
"tag": 'rubick-screen-short-cut', tag: 'rubick-screen-short-cut'
}, },
{ {
"pluginName": "锁屏", pluginName: '锁屏',
"logo": require('../imgs/lock.png'), logo: require('../imgs/lock.png'),
"features": [ features: [
{ {
"code": "lock", code: 'lock',
"explain": "锁屏", explain: '锁屏',
"cmds": [ "锁屏", "lock screen" ] cmds: ['锁屏', 'lock screen']
}, }
], ],
"tag": 'rubick-lock', tag: 'rubick-lock'
} }
]; ];
const APP_FINDER_PATH = [ const APP_FINDER_PATH = ['/System/Applications', '/Applications', '/System/Library/PreferencePanes'];
'/System/Applications',
'/Applications',
'/System/Library/PreferencePanes',
];
export { export { WINDOW_MAX_HEIGHT, WINDOW_MIN_HEIGHT, PRE_ITEM_HEIGHT, SYSTEM_PLUGINS, APP_FINDER_PATH };
WINDOW_MAX_HEIGHT,
WINDOW_MIN_HEIGHT,
PRE_ITEM_HEIGHT,
SYSTEM_PLUGINS,
APP_FINDER_PATH,
}

View File

@ -1,26 +1,31 @@
import {WINDOW_MAX_HEIGHT, WINDOW_MIN_HEIGHT, PRE_ITEM_HEIGHT, SYSTEM_PLUGINS} from './constans'; import { WINDOW_MAX_HEIGHT, WINDOW_MIN_HEIGHT, PRE_ITEM_HEIGHT, SYSTEM_PLUGINS } from './constans';
import path from 'path'; import path from 'path';
import fs from 'fs'; import fs from 'fs';
import process from 'child_process'; import process from 'child_process';
import Store from 'electron-store'; import Store from 'electron-store';
import downloadFile from 'download'; import downloadFile from 'download';
import {nativeImage, ipcRenderer} from 'electron'; import { nativeImage, ipcRenderer } from 'electron';
import {APP_FINDER_PATH} from './constans'; import { APP_FINDER_PATH } from './constans';
import {getlocalDataFile} from "../../../main/common/utils"; import { getlocalDataFile } from '../../../main/common/utils';
import iconvLite from 'iconv-lite';
import bpList from 'bplist-parser';
import pinyin from 'pinyin';
const store = new Store(); const store = new Store();
function getWindowHeight(searchList) { function getWindowHeight(searchList) {
if (!searchList) return WINDOW_MAX_HEIGHT; if (!searchList) return WINDOW_MAX_HEIGHT;
if (!searchList.length) return WINDOW_MIN_HEIGHT; if (!searchList.length) return WINDOW_MIN_HEIGHT;
return searchList.length * PRE_ITEM_HEIGHT + WINDOW_MIN_HEIGHT + 5 > WINDOW_MAX_HEIGHT ? WINDOW_MAX_HEIGHT : searchList.length * PRE_ITEM_HEIGHT + WINDOW_MIN_HEIGHT + 5; return searchList.length * PRE_ITEM_HEIGHT + WINDOW_MIN_HEIGHT + 5 > WINDOW_MAX_HEIGHT
? WINDOW_MAX_HEIGHT
: searchList.length * PRE_ITEM_HEIGHT + WINDOW_MIN_HEIGHT + 5;
} }
function searchKeyValues(lists, value){ function searchKeyValues(lists, value) {
return lists.filter(item => { return lists.filter((item) => {
if (typeof item === 'string') return item.indexOf(value) >= 0; if (typeof item === 'string') return item.indexOf(value) >= 0;
return item.type.indexOf(value) >= 0; return item.type.indexOf(value) >= 0;
}) });
} }
function existOrNot(path) { function existOrNot(path) {
@ -47,7 +52,7 @@ async function downloadZip(downloadRepoUrl, name) {
await process.execSync(`rm -rf ${temp_dest}`); await process.execSync(`rm -rf ${temp_dest}`);
} }
await downloadFile(downloadRepoUrl, plugin_path,{extract: true}); await downloadFile(downloadRepoUrl, plugin_path, { extract: true });
return temp_dest; return temp_dest;
} catch (e) { } catch (e) {
@ -60,12 +65,12 @@ const sysFile = {
ipcRenderer.send('optionPlugin', { ipcRenderer.send('optionPlugin', {
plugins: plugins.filter((plugin) => { plugins: plugins.filter((plugin) => {
let hasOption = false; let hasOption = false;
plugin.features.forEach(fe => { plugin.features.forEach((fe) => {
fe.cmds.forEach(cmd => { fe.cmds.forEach((cmd) => {
if (cmd.type) { if (cmd.type) {
hasOption = true; hasOption = true;
} }
}) });
}); });
return hasOption; return hasOption;
}) })
@ -76,26 +81,26 @@ const sysFile = {
try { try {
return store.get('user-plugins'); return store.get('user-plugins');
} catch (e) { } catch (e) {
return [] return [];
} }
}, },
removeAllPlugins() { removeAllPlugins() {
store.delete('user-plugins'); store.delete('user-plugins');
} }
} };
function mergePlugins(plugins) { function mergePlugins(plugins) {
const result = [ const result = [
...plugins, ...plugins,
...SYSTEM_PLUGINS.map(plugin => { ...SYSTEM_PLUGINS.map((plugin) => {
return { return {
...plugin, ...plugin,
status: true, status: true,
sourceFile: '', sourceFile: '',
type: 'system', type: 'system'
} };
}) })
] ];
const target = []; const target = [];
@ -103,28 +108,29 @@ function mergePlugins(plugins) {
let targetIndex = -1; let targetIndex = -1;
target.forEach((tg, j) => { target.forEach((tg, j) => {
if (tg.tag === item.tag && tg.type === 'system') { if (tg.tag === item.tag && tg.type === 'system') {
targetIndex = j targetIndex = j;
} }
}); });
if (targetIndex === -1) { if (targetIndex === -1) {
target.push(item) target.push(item);
} }
}); });
ipcRenderer && ipcRenderer.send('optionPlugin', { ipcRenderer &&
ipcRenderer.send('optionPlugin', {
plugins: target.filter((plugin) => { plugins: target.filter((plugin) => {
let hasOption = false; let hasOption = false;
plugin.features.forEach(fe => { plugin.features.forEach((fe) => {
fe.cmds.forEach(cmd => { fe.cmds.forEach((cmd) => {
if (cmd.type) { if (cmd.type) {
hasOption = true; hasOption = true;
} }
}) });
}); });
return hasOption; return hasOption;
}) })
}); });
return target return target;
} }
function find(p, target = 'plugin.json') { function find(p, target = 'plugin.json') {
@ -132,7 +138,7 @@ function find(p, target = 'plugin.json') {
let result; let result;
const fileList = fs.readdirSync(p); const fileList = fs.readdirSync(p);
for (let i = 0; i < fileList.length; i++) { for (let i = 0; i < fileList.length; i++) {
let thisPath = p + "/" + fileList[i]; let thisPath = p + '/' + fileList[i];
const data = fs.statSync(thisPath); const data = fs.statSync(thisPath);
if (data.isFile() && fileList[i] === target) { if (data.isFile() && fileList[i] === target) {
@ -150,14 +156,50 @@ function find(p, target = 'plugin.json') {
} }
const fileLists = []; const fileLists = [];
// 默认搜索目录 // 默认搜索目录
APP_FINDER_PATH.forEach((searchPath) => { const isZhRegex = /[\u4e00-\u9fa5]/;
const getDisplayNameRegex = /\"(?:CFBundleDisplayName)\"\s\=\s\"(.*)\"/;
async function getAppZhName(rootPath, appName) {
try {
const ERROR_RESULT = '';
const systemPath = path.join(rootPath, `${appName}/Contents/Resources/zh_CN.lproj/InfoPlist.strings`);
const customizePath = path.join(rootPath, `${appName}/Contents/Resources/zh-Hans.lproj/InfoPlist.strings`);
let appInfoPath = '';
if (fs.existsSync(systemPath)) {
appInfoPath = systemPath;
} else if (fs.existsSync(customizePath)) {
appInfoPath = customizePath;
} else {
return ERROR_RESULT;
}
let appZhName = '';
if (rootPath == '/Applications') {
const container = iconvLite.decode(fs.readFileSync(appInfoPath), 'utf-16');
if (container) {
const res = container.match(getDisplayNameRegex);
appZhName = res && res[1];
} else {
return ERROR_RESULT;
}
} else {
const [{ CFBundleDisplayName = '', CFBundleName = '' }] = await bpList.parseFile(appInfoPath);
appZhName = CFBundleDisplayName || CFBundleName;
}
return appZhName;
} catch (error) {
return ERROR_RESULT;
}
}
APP_FINDER_PATH.forEach((searchPath, index) => {
fs.readdir(searchPath, async (err, files) => { fs.readdir(searchPath, async (err, files) => {
try { try {
for (let i = 0; i < files.length; i++) { for (let i = 0; i < files.length; i++) {
const appName = files[i]; const appName = files[i];
const extname = path.extname(appName); const extname = path.extname(appName);
const appSubStr = appName.split(extname)[0]; const appSubStr = appName.split(extname)[0];
if ((extname === '.app' || extname === '.prefPane') >= 0 ) { if ((extname === '.app' || extname === '.prefPane') >= 0) {
try { try {
const path1 = path.join(searchPath, `${appName}/Contents/Resources/App.icns`); const path1 = path.join(searchPath, `${appName}/Contents/Resources/App.icns`);
const path2 = path.join(searchPath, `${appName}/Contents/Resources/AppIcon.icns`); const path2 = path.join(searchPath, `${appName}/Contents/Resources/AppIcon.icns`);
@ -175,21 +217,45 @@ APP_FINDER_PATH.forEach((searchPath) => {
} else { } else {
// 性能最低的方式 // 性能最低的方式
const resourceList = fs.readdirSync(path.join(searchPath, `${appName}/Contents/Resources`)); const resourceList = fs.readdirSync(path.join(searchPath, `${appName}/Contents/Resources`));
const iconName = resourceList.filter(file => path.extname(file) === '.icns')[0]; const iconName = resourceList.filter((file) => path.extname(file) === '.icns')[0];
iconPath = path.join(searchPath, `${appName}/Contents/Resources/${iconName}`); iconPath = path.join(searchPath, `${appName}/Contents/Resources/${iconName}`);
} }
const img = await nativeImage.createThumbnailFromPath(iconPath, {width: 64, height: 64}); const img = await nativeImage.createThumbnailFromPath(iconPath, { width: 64, height: 64 });
fileLists.push({
name: appSubStr, const appZhName = await getAppZhName(searchPath, appName);
const fileOptions = {
value: 'plugin', value: 'plugin',
icon: img.toDataURL(), icon: img.toDataURL(),
desc: path.join(searchPath, appName), desc: path.join(searchPath, appName),
type: 'app', type: 'app',
action: `open ${path.join(searchPath, appName).replace(' ', '\\ ')}` action: `open ${path.join(searchPath, appName).replace(' ', '\\ ')}`
}) };
} catch (e) {
}
fileLists.push({
...fileOptions,
name: appSubStr,
keyWord: appSubStr
});
if (appZhName && isZhRegex.test(appZhName)) {
let cmds = [];
const pinyinArr = pinyin(appZhName, { style: pinyin.STYLE_NORMAL });
// pinyinArr = [['pin'], ['yin']]
const firstLetterArr = pinyinArr.map((str) => str[0][0]);
cmds.push(appZhName);
cmds.push(pinyinArr.join(''));
cmds.push(firstLetterArr.join(''));
cmds.forEach((cmd) => {
fileLists.push({
...fileOptions,
name: appZhName,
keyWord: cmd
});
});
}
} catch (e) {}
} }
} }
} catch (e) { } catch (e) {
@ -198,27 +264,17 @@ APP_FINDER_PATH.forEach((searchPath) => {
}); });
}); });
function debounce(fn, delay) { function debounce(fn, delay) {
let timer let timer;
return function () { return function() {
const context = this const context = this;
const args = arguments const args = arguments;
clearTimeout(timer) clearTimeout(timer);
timer = setTimeout(function () { timer = setTimeout(function() {
fn.apply(context, args) fn.apply(context, args);
}, delay) }, delay);
} };
} }
export { export { getWindowHeight, searchKeyValues, sysFile, mergePlugins, find, downloadZip, fileLists, debounce };
getWindowHeight,
searchKeyValues,
sysFile,
mergePlugins,
find,
downloadZip,
fileLists,
debounce,
}

View File

@ -1,4 +1,4 @@
import {clipboard, ipcRenderer, remote} from "electron"; import { clipboard, ipcRenderer, remote } from 'electron';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import { import {
getWindowHeight, getWindowHeight,
@ -7,12 +7,12 @@ import {
mergePlugins, mergePlugins,
find, find,
downloadZip, downloadZip,
fileLists, fileLists
} from '../../assets/common/utils'; } from '../../assets/common/utils';
import systemMethod from '../../assets/common/system'; import systemMethod from '../../assets/common/system';
import fs from "fs"; import fs from 'fs';
import path from 'path'; import path from 'path';
import {execSync} from 'child_process'; import { execSync } from 'child_process';
const state = { const state = {
selected: null, selected: null,
@ -25,17 +25,17 @@ const state = {
pluginInfo: (() => { pluginInfo: (() => {
try { try {
console.log(window.pluginInfo); console.log(window.pluginInfo);
return window.pluginInfo || {} return window.pluginInfo || {};
} catch (e) {} } catch (e) {}
})(), })()
} };
const mutations = { const mutations = {
commonUpdate (state, payload) { commonUpdate(state, payload) {
Object.keys(payload).forEach((key) => { Object.keys(payload).forEach((key) => {
state[key] = payload[key]; state[key] = payload[key];
if (key === 'devPlugins') { if (key === 'devPlugins') {
sysFile.savePlugins(payload[key]) sysFile.savePlugins(payload[key]);
} }
}); });
}, },
@ -43,16 +43,16 @@ const mutations = {
state.subPlaceHolder = payload; state.subPlaceHolder = payload;
}, },
deleteDevPlugin(state, payload) { deleteDevPlugin(state, payload) {
state.devPlugins = state.devPlugins.filter(plugin => plugin.name !== payload.name); state.devPlugins = state.devPlugins.filter((plugin) => plugin.name !== payload.name);
sysFile.savePlugins(state.devPlugins); sysFile.savePlugins(state.devPlugins);
}, },
deleteProdPlugin(state, payload) { deleteProdPlugin(state, payload) {
state.devPlugins = state.devPlugins.filter(plugin => plugin.id !== payload.id); state.devPlugins = state.devPlugins.filter((plugin) => plugin.id !== payload.id);
sysFile.savePlugins(state.devPlugins); sysFile.savePlugins(state.devPlugins);
// todo 删除 static 目录下的对应插件 // todo 删除 static 目录下的对应插件
}, },
devPluginStatusChange(state, payload) { devPluginStatusChange(state, payload) {
state.devPlugins.forEach(plugin => { state.devPlugins.forEach((plugin) => {
if (plugin.name === payload.name) { if (plugin.name === payload.name) {
plugin.status = !plugin.status; plugin.status = !plugin.status;
} }
@ -60,12 +60,12 @@ const mutations = {
state.devPlugins = [...state.devPlugins]; state.devPlugins = [...state.devPlugins];
sysFile.savePlugins(state.devPlugins); sysFile.savePlugins(state.devPlugins);
} }
} };
const actions = { const actions = {
showMainUI ({ commit, state }, paylpad) { showMainUI({ commit, state }, paylpad) {
ipcRenderer.send('changeWindowSize-rubick', { ipcRenderer.send('changeWindowSize-rubick', {
height: getWindowHeight(), height: getWindowHeight()
}); });
setTimeout(() => { setTimeout(() => {
commit('commonUpdate', { commit('commonUpdate', {
@ -81,34 +81,34 @@ const actions = {
const config = JSON.parse(fs.readFileSync(path.join(payload.sourceFile, '../plugin.json'), 'utf-8')); const config = JSON.parse(fs.readFileSync(path.join(payload.sourceFile, '../plugin.json'), 'utf-8'));
const pluginConfig = { const pluginConfig = {
...config, ...config,
sourceFile: path.join(payload.sourceFile, `../${config.main}`), sourceFile: path.join(payload.sourceFile, `../${config.main}`)
}; };
const devPlugins = [...state.devPlugins]; const devPlugins = [...state.devPlugins];
commit('commonUpdate', { commit('commonUpdate', {
devPlugins: devPlugins.map(plugin => { devPlugins: devPlugins.map((plugin) => {
if (plugin.name === payload.name) { if (plugin.name === payload.name) {
return { return {
...plugin, ...plugin,
...pluginConfig, ...pluginConfig
} };
} }
return plugin; return plugin;
}) })
}) });
}, },
async onSearch ({ commit }, paylpad) { async onSearch({ commit }, paylpad) {
if (state.selected && state.selected.key !== 'plugin-container') { if (state.selected && state.selected.key !== 'plugin-container') {
commit('commonUpdate', {searchValue: ''}); commit('commonUpdate', { searchValue: '' });
return; return;
} }
const value = paylpad.value; const value = paylpad.value;
// 在插件界面不触发其他功能 // 在插件界面不触发其他功能
if((state.selected && state.selected.key === 'plugin-container') || paylpad.searchType === 'subWindow') { if ((state.selected && state.selected.key === 'plugin-container') || paylpad.searchType === 'subWindow') {
commit('commonUpdate', {searchValue: value}); commit('commonUpdate', { searchValue: value });
return; return;
} }
const fileUrl = clipboard.read('public.file-url').replace('file://', ''); const fileUrl = clipboard.read('public.file-url').replace('file://', '');
commit('commonUpdate', {searchValue: value}) commit('commonUpdate', { searchValue: value });
// 复制文件 // 复制文件
if (fileUrl && value === 'plugin.json') { if (fileUrl && value === 'plugin.json') {
const config = JSON.parse(fs.readFileSync(fileUrl, 'utf-8')); const config = JSON.parse(fs.readFileSync(fileUrl, 'utf-8'));
@ -121,7 +121,7 @@ const actions = {
icon: 'image://' + path.join(fileUrl, `../${config.logo}`), icon: 'image://' + path.join(fileUrl, `../${config.logo}`),
subType: (() => { subType: (() => {
if (config.main) { if (config.main) {
return '' return '';
} }
return 'template'; return 'template';
})() })()
@ -146,12 +146,12 @@ const actions = {
key: 'plugin', key: 'plugin',
name: '新建rubick开发插件' name: '新建rubick开发插件'
}, },
current: ['dev'], current: ['dev']
}); });
ipcRenderer.send('changeWindowSize-rubick', { ipcRenderer.send('changeWindowSize-rubick', {
height: getWindowHeight(), height: getWindowHeight()
}); });
router.push('/home/dev') router.push('/home/dev');
} }
}, },
{ {
@ -164,10 +164,10 @@ const actions = {
commit('commonUpdate', { commit('commonUpdate', {
showMain: false, showMain: false,
selected: null, selected: null,
options: [], options: []
}); });
ipcRenderer.send('changeWindowSize-rubick', { ipcRenderer.send('changeWindowSize-rubick', {
height: getWindowHeight([]), height: getWindowHeight([])
}); });
remote.Notification('Rubick 通知', { body: '复制成功' }); remote.Notification('Rubick 通知', { body: '复制成功' });
} }
@ -176,9 +176,9 @@ const actions = {
}); });
// 调整窗口大小 // 调整窗口大小
ipcRenderer.send('changeWindowSize-rubick', { ipcRenderer.send('changeWindowSize-rubick', {
height: getWindowHeight(state.options), height: getWindowHeight(state.options)
}); });
return return;
} }
let options = []; let options = [];
@ -189,7 +189,7 @@ const actions = {
// dev 插件未开启 // dev 插件未开启
if (plugin.type === 'dev' && !plugin.status) return; if (plugin.type === 'dev' && !plugin.status) return;
const feature = plugin.features; const feature = plugin.features;
feature.forEach(fe => { feature.forEach((fe) => {
const cmds = searchKeyValues(fe.cmds, value); const cmds = searchKeyValues(fe.cmds, value);
options = [ options = [
...options, ...options,
@ -200,31 +200,44 @@ const actions = {
desc: fe.explain, desc: fe.explain,
type: plugin.type, type: plugin.type,
click: (router) => { click: (router) => {
actions.openPlugin({commit}, {cmd, plugin, feature: fe, router}); actions.openPlugin({ commit }, { cmd, plugin, feature: fe, router });
} }
})) }))
] ];
})
}); });
});
let descMap = new Map();
options = [ options = [
...options, ...options,
...(fileLists.filter(plugin => plugin.name.indexOf(value) >= 0)).map(plugin => { ...fileLists
plugin.click = () => { .filter((plugin) => {
actions.openPlugin({commit}, {plugin}); if (!descMap.get(plugin)) {
descMap.set(plugin, true);
return plugin.keyWord.toLocaleUpperCase().indexOf(value.toLocaleUpperCase()) >= 0;
} else {
return false;
} }
return plugin })
}), .map((plugin) => {
] plugin.click = () => {
actions.openPlugin({ commit }, { plugin });
};
return plugin;
})
];
descMap = null;
} }
commit('commonUpdate', { commit('commonUpdate', {
options options
}); });
ipcRenderer.send('changeWindowSize-rubick', { ipcRenderer.send('changeWindowSize-rubick', {
height: getWindowHeight(state.options), height: getWindowHeight(state.options)
}); });
}, },
async downloadPlugin({commit}, payload) { async downloadPlugin({ commit }, payload) {
const distUrl = await downloadZip(payload.downloadUrl, payload.name); const distUrl = await downloadZip(payload.downloadUrl, payload.name);
const fileUrl = find(distUrl); const fileUrl = find(distUrl);
@ -238,26 +251,26 @@ const actions = {
icon: payload.logo, icon: payload.logo,
subType: (() => { subType: (() => {
if (config.main) { if (config.main) {
return '' return '';
} }
return 'template'; return 'template';
})() })()
}; };
commit('commonUpdate', { commit('commonUpdate', {
devPlugins: [pluginConfig, ...state.devPlugins], devPlugins: [pluginConfig, ...state.devPlugins]
}); });
}, },
openPlugin({commit}, {cmd, plugin, feature, router, payload}) { openPlugin({ commit }, { cmd, plugin, feature, router, payload }) {
if (plugin.type === 'app') { if (plugin.type === 'app') {
execSync(plugin.action); execSync(plugin.action);
commit('commonUpdate', { commit('commonUpdate', {
selected: null, selected: null,
showMain: false, showMain: false,
options: [], options: [],
searchValue: '', searchValue: ''
}); });
ipcRenderer.send('changeWindowSize-rubick', { ipcRenderer.send('changeWindowSize-rubick', {
height: getWindowHeight([]), height: getWindowHeight([])
}); });
return; return;
} }
@ -265,26 +278,26 @@ const actions = {
selected: { selected: {
key: 'plugin-container', key: 'plugin-container',
name: cmd.label ? cmd.label : cmd, name: cmd.label ? cmd.label : cmd,
icon: 'image://' + path.join(plugin.sourceFile, `../${plugin.logo}`), icon: 'image://' + path.join(plugin.sourceFile, `../${plugin.logo}`)
}, },
searchValue: '', searchValue: '',
showMain: true showMain: true
}); });
ipcRenderer.send('changeWindowSize-rubick', { ipcRenderer.send('changeWindowSize-rubick', {
height: getWindowHeight(), height: getWindowHeight()
}); });
if (plugin.type === 'system') { if (plugin.type === 'system') {
systemMethod[plugin.tag][feature.code]() systemMethod[plugin.tag][feature.code]();
commit('commonUpdate', { commit('commonUpdate', {
selected: null, selected: null,
showMain: false, showMain: false,
options: [], options: []
}); });
ipcRenderer.send('changeWindowSize-rubick', { ipcRenderer.send('changeWindowSize-rubick', {
height: getWindowHeight([]), height: getWindowHeight([])
}); });
router.push({ router.push({
path: '/home', path: '/home'
}); });
return; return;
} }
@ -293,7 +306,7 @@ const actions = {
cmd, cmd,
...plugin, ...plugin,
detail: feature, detail: feature,
payload, payload
} }
}); });
@ -303,14 +316,14 @@ const actions = {
...plugin, ...plugin,
_modify: Date.now(), _modify: Date.now(),
detail: JSON.stringify(feature) detail: JSON.stringify(feature)
},
})
} }
} });
}
};
export default { export default {
namespaced: true, namespaced: true,
state, state,
mutations, mutations,
actions actions
} };