如下弹窗
方法
1、在StarUML\resources 路径中找到app.asar文件,然后找到里面的 license-manager.js文件 2、打开license-manager.js文件,将文件内容替换为以下内容。
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')
const LICENSE_CHECK_PROBABILITY = 0.3
var status = false
var licenseInfo = null
function setStatus (licenseManager, newStat) {
if (status !== newStat) {
status = newStat
licenseManager.emit('statusChanged', status)
}
}
class LicenseManager extends EventEmitter {
constructor () {
super()
this.projectManager = null
}
getStatus () {
return status
}
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
}
}
validate () {
return new Promise((resolve, reject) => {
try {
var file = this.findLicense()
if (!file) {
reject('License key not found')
} else {
var data = fs.readFileSync(file, 'utf8')
licenseInfo = JSON.parse(data)
var base = SK + licenseInfo.name +
SK + licenseInfo.product + '-' + licenseInfo.licenseType +
SK + licenseInfo.quantity +
SK + licenseInfo.timestamp + SK
var _key = crypto.createHash('sha1').update(base).digest('hex').toUpperCase()
if (_key !== licenseInfo.licenseKey) {
reject('Invalid license key')
} else {
$.post(app.config.validation_url, {licenseKey: licenseInfo.licenseKey})
.done(data => {
resolve(data)
})
.fail(err => {
if (err && err.status === 499) {
reject(err)
} else {
resolve(licenseInfo)
}
})
}
}
} catch (err) {
reject(err)
}
})
}
checkLicenseValidity () {
this.validate().then(() => {
setStatus(this, true)
}, () => {
setStatus(this, true)
})
}
register (licenseKey) {
return new Promise((resolve, reject) => {
$.post(app.config.validation_url, {licenseKey: licenseKey})
.done(data => {
var file = path.join(app.getUserPath(), '/license.key')
fs.writeFileSync(file, JSON.stringify(data, 2))
licenseInfo = data
setStatus(this, true)
resolve(data)
})
.fail(err => {
setStatus(this, false)
if (err.status === 499) {
reject('invalid')
} else {
reject()
}
})
})
}
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
3、保存退出重新打开StartUML便无弹窗。
附录
在打开 app.asar 文件时会用到 WinAsar软件可从此处下载 https://download.csdn.net/download/weixin_43671437/85195007 软件使用方法简介:
|