mirror of
https://git-qiuchenly.yltfspace.com/QiuChenly/corepatch
synced 2025-11-25 05:40:27 +08:00
add StarUML
This commit is contained in:
175
tool/StarUML/license-manager.js
Normal file
175
tool/StarUML/license-manager.js
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013-2014 Minkyu Lee. All rights reserved.
|
||||||
|
*
|
||||||
|
* NOTICE: All information contained herein is, and remains the
|
||||||
|
* property of Minkyu Lee. The intellectual and technical concepts
|
||||||
|
* contained herein are proprietary to Minkyu Lee and may be covered
|
||||||
|
* by Republic of Korea and Foreign Patents, patents in process,
|
||||||
|
* and are protected by trade secret or copyright law.
|
||||||
|
* Dissemination of this information or reproduction of this material
|
||||||
|
* is strictly forbidden unless prior written permission is obtained
|
||||||
|
* from Minkyu Lee (niklaus.lee@gmail.com).
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
const { EventEmitter } = require("events");
|
||||||
|
const fs = require("fs");
|
||||||
|
const path = require("path");
|
||||||
|
const crypto = require("crypto");
|
||||||
|
const UnregisteredDialog = require("../dialogs/unregistered-dialog");
|
||||||
|
const SK = "DF9B72CC966FBE3A46F99858C5AEE";
|
||||||
|
const packageJSON = require("../../package.json");
|
||||||
|
|
||||||
|
// Check License When File Save
|
||||||
|
const LICENSE_CHECK_PROBABILITY = 0.3;
|
||||||
|
|
||||||
|
const PRO_DIAGRAM_TYPES = [
|
||||||
|
"SysMLRequirementDiagram",
|
||||||
|
"SysMLBlockDefinitionDiagram",
|
||||||
|
"SysMLInternalBlockDiagram",
|
||||||
|
"SysMLParametricDiagram",
|
||||||
|
"BPMNDiagram",
|
||||||
|
"WFWireframeDiagram",
|
||||||
|
"AWSDiagram",
|
||||||
|
"GCPDiagram",
|
||||||
|
];
|
||||||
|
|
||||||
|
var status = false;
|
||||||
|
var licenseInfo = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Registration Status
|
||||||
|
* This function is out of LicenseManager class for the security reason
|
||||||
|
* (To disable changing License status by API)
|
||||||
|
* @private
|
||||||
|
* @param {boolean} newStat
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
function setStatus(licenseManager, newStat) {
|
||||||
|
if (status !== newStat) {
|
||||||
|
status = newStat;
|
||||||
|
licenseManager.emit("statusChanged", status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
class LicenseManager extends EventEmitter {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.projectManager = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
isProDiagram(diagramType) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Registration Status
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get License Infomation
|
||||||
|
* @return {Object}
|
||||||
|
*/
|
||||||
|
getLicenseInfo() {
|
||||||
|
return licenseInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
findLicense() {
|
||||||
|
var licensePath = path.join(app.getUserPath(), "/license.key");
|
||||||
|
if (!fs.existsSync(licensePath)) {
|
||||||
|
licensePath = path.join(app.getAppPath(), "../license.key");
|
||||||
|
}
|
||||||
|
if (fs.existsSync(licensePath)) {
|
||||||
|
return licensePath;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check license validity
|
||||||
|
*
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
validate() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
try {
|
||||||
|
// Local check
|
||||||
|
var file = this.findLicense();
|
||||||
|
if (!file) {
|
||||||
|
reject("License key not found");
|
||||||
|
} else {
|
||||||
|
var data = fs.readFileSync(file, "utf8");
|
||||||
|
licenseInfo = JSON.parse(data);
|
||||||
|
resolve(licenseInfo);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
reject(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
checkLicenseValidity() {
|
||||||
|
if (packageJSON.config.setappBuild) {
|
||||||
|
setStatus(this, true);
|
||||||
|
} else {
|
||||||
|
this.validate().then(
|
||||||
|
() => {
|
||||||
|
setStatus(this, true);
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
setStatus(this, false);
|
||||||
|
UnregisteredDialog.showDialog();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check the license key in server and store it as license.key file in local
|
||||||
|
*
|
||||||
|
* @param {string} licenseKey
|
||||||
|
*/
|
||||||
|
register(licenseKey) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
var data = {
|
||||||
|
name: "QiuChenlyTeam",
|
||||||
|
product: "STARUML.V6",
|
||||||
|
licenseType: "PRO",
|
||||||
|
quantity: "99999",
|
||||||
|
timestamp: "1575275098",
|
||||||
|
licenseKey: "88888888888888",
|
||||||
|
crackedAuthor: "BilZzard"
|
||||||
|
}
|
||||||
|
if (data.product === packageJSON.config.product_id) {
|
||||||
|
var file = path.join(app.getUserPath(), "/license.key");
|
||||||
|
fs.writeFileSync(file, JSON.stringify(data, 2));
|
||||||
|
licenseInfo = data;
|
||||||
|
setStatus(this, true);
|
||||||
|
resolve(data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
htmlReady() {
|
||||||
|
this.projectManager.on("projectSaved", (filename, project) => {
|
||||||
|
var val = Math.floor(Math.random() * (1.0 / LICENSE_CHECK_PROBABILITY));
|
||||||
|
if (val === 0) {
|
||||||
|
this.checkLicenseValidity();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
appReady() {
|
||||||
|
this.checkLicenseValidity();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = LicenseManager;
|
||||||
43
tool/StarUML/main.py
Normal file
43
tool/StarUML/main.py
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
# 检查是否安装了 asar 命令
|
||||||
|
def check_asar_command():
|
||||||
|
return os.system("command -v asar > /dev/null 2>&1") == 0
|
||||||
|
|
||||||
|
if not check_asar_command():
|
||||||
|
print("草泥马,先安装asar。")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
# 获取用户输入的用户名
|
||||||
|
username = input("请输入用户名: ")
|
||||||
|
# 执行bash命令
|
||||||
|
bash_extract = """
|
||||||
|
cd /Applications/StarUML.app/Contents/Resources && asar extract app.asar app
|
||||||
|
"""
|
||||||
|
os.system(bash_extract)
|
||||||
|
|
||||||
|
# 复制license-manager.js文件到目标位置
|
||||||
|
destination_path = "/Applications/StarUML.app/Contents/Resources/app/src/engine/"
|
||||||
|
os.system("cp -f license-manager.js {}".format(destination_path))
|
||||||
|
|
||||||
|
|
||||||
|
# 将字符串中的"BilZzard"替换为用户输入的文本
|
||||||
|
with open(destination_path + "license-manager.js", 'r') as file:
|
||||||
|
js_content = file.read()
|
||||||
|
new_js_content = js_content.replace('QiuChenlyTeam', username)
|
||||||
|
|
||||||
|
# 将替换后的内容写回到js文件
|
||||||
|
with open(destination_path + "license-manager.js", 'w') as file:
|
||||||
|
file.write(new_js_content)
|
||||||
|
|
||||||
|
# 执行bash命令
|
||||||
|
print("需要修复app,看到提示后输入root密码。")
|
||||||
|
|
||||||
|
bash_pack = """
|
||||||
|
cd /Applications/StarUML.app/Contents/Resources &&
|
||||||
|
asar pack app app.asar &&
|
||||||
|
rm -rf app && sudo xattr -r -d com.apple.quarantine /Applications/StarUML.app
|
||||||
|
"""
|
||||||
|
os.system(bash_pack)
|
||||||
|
|
||||||
|
print("脚本执行完成。请打开后从设置-隐私与安全中打开!之后随便输入激活码即可激活!")
|
||||||
Reference in New Issue
Block a user