Skip to content

Commit 46096a6

Browse files
committed
Merge branch 'release/3.62.2'
2 parents eb12d89 + 0aecf31 commit 46096a6

6 files changed

Lines changed: 36 additions & 14 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ For more information on how to use the following functions, please see [characte
7676

7777
## Changelogs
7878

79-
### [v3.62.1](https://github.com/purocean/yn/releases/tag/v3.62.1) 2023-10-08
79+
### [v3.62.2](https://github.com/purocean/yn/releases/tag/v3.62.2) 2023-10-08
8080

81-
[Windows](https://github.com/purocean/yn/releases/download/v3.62.1/Yank-Note-win-x64-3.62.1.exe) | [macOS arm64](https://github.com/purocean/yn/releases/download/v3.62.1/Yank-Note-mac-arm64-3.62.1.dmg) | [macOS x64](https://github.com/purocean/yn/releases/download/v3.62.1/Yank-Note-mac-x64-3.62.1.dmg) | [Linux AppImage](https://github.com/purocean/yn/releases/download/v3.62.1/Yank-Note-linux-x86_64-3.62.1.AppImage) | [Linux deb](https://github.com/purocean/yn/releases/download/v3.62.1/Yank-Note-linux-amd64-3.62.1.deb)
81+
[Windows](https://github.com/purocean/yn/releases/download/v3.62.2/Yank-Note-win-x64-3.62.2.exe) | [macOS arm64](https://github.com/purocean/yn/releases/download/v3.62.2/Yank-Note-mac-arm64-3.62.2.dmg) | [macOS x64](https://github.com/purocean/yn/releases/download/v3.62.2/Yank-Note-mac-x64-3.62.2.dmg) | [Linux AppImage](https://github.com/purocean/yn/releases/download/v3.62.2/Yank-Note-linux-x86_64-3.62.2.AppImage) | [Linux deb](https://github.com/purocean/yn/releases/download/v3.62.2/Yank-Note-linux-amd64-3.62.2.deb)
8282

8383
1. feat: sidebar document outline supports folding and expansion
8484
2. feat: supports offline activation of premium version

README_ZH-CN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@
7676

7777
## 更新日志
7878

79-
### [v3.62.1](https://github.com/purocean/yn/releases/tag/v3.62.1) 2023-10-08
79+
### [v3.62.2](https://github.com/purocean/yn/releases/tag/v3.62.2) 2023-10-08
8080

81-
[Windows](https://github.com/purocean/yn/releases/download/v3.62.1/Yank-Note-win-x64-3.62.1.exe) | [macOS arm64](https://github.com/purocean/yn/releases/download/v3.62.1/Yank-Note-mac-arm64-3.62.1.dmg) | [macOS x64](https://github.com/purocean/yn/releases/download/v3.62.1/Yank-Note-mac-x64-3.62.1.dmg) | [Linux AppImage](https://github.com/purocean/yn/releases/download/v3.62.1/Yank-Note-linux-x86_64-3.62.1.AppImage) | [Linux deb](https://github.com/purocean/yn/releases/download/v3.62.1/Yank-Note-linux-amd64-3.62.1.deb)
81+
[Windows](https://github.com/purocean/yn/releases/download/v3.62.2/Yank-Note-win-x64-3.62.2.exe) | [macOS arm64](https://github.com/purocean/yn/releases/download/v3.62.2/Yank-Note-mac-arm64-3.62.2.dmg) | [macOS x64](https://github.com/purocean/yn/releases/download/v3.62.2/Yank-Note-mac-x64-3.62.2.dmg) | [Linux AppImage](https://github.com/purocean/yn/releases/download/v3.62.2/Yank-Note-linux-x86_64-3.62.2.AppImage) | [Linux deb](https://github.com/purocean/yn/releases/download/v3.62.2/Yank-Note-linux-amd64-3.62.2.deb)
8282

8383
1. feat: 侧栏文档大纲支持折叠展开
8484
2. feat: 支持离线激活高级版

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "yank.note",
3-
"version": "3.62.1",
3+
"version": "3.62.2",
44
"description": "Yank Note: A highly extensible Markdown editor, designed for productivity.",
55
"main": "dist/main/app.js",
66
"license": "AGPL-3.0",

src/main/server/premium.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AppLicenseClient } from 'app-license'
1+
import { AppLicenseClient, decodeDevice } from 'app-license'
22
import request from 'request'
33
import { API_BASE_URL, PREMIUM_PUBLIC_KEY } from '../../share/misc'
44
import { getAction } from '../action'
@@ -65,6 +65,14 @@ export function upgradeLicense (payload: {oldLicense: string, locale: string}) {
6565
return fetchApi('/upgrade-license', payload)
6666
}
6767

68+
export async function checkDevice (payload: { device: string }) {
69+
const device = decodeDevice(await genDeviceString())
70+
const _device = decodeDevice(payload.device)
71+
if (device.id !== _device.id || device.platform !== _device.platform) {
72+
throw new Error('INVALID_LICENSE')
73+
}
74+
}
75+
6876
export function genDeviceString () {
6977
return client.genDeviceString()
7078
}

src/renderer/components/Premium.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
</div>
117117
<div class="offline-input-wrapper">
118118
<input readonly :value="machineCode" />
119-
<button class="primary small input-copy-btn" @click="copyMachineCode">Copy</button>
119+
<button v-if="machineCode" class="primary small input-copy-btn" @click="copyMachineCode">Copy</button>
120120
</div>
121121
<div class="code-label">
122122
Activation Token
@@ -226,7 +226,8 @@ export default defineComponent({
226226
227227
devices.value = data.map(x => {
228228
const item = decodeDevice(x)
229-
const isCurrent = token.device === x
229+
const device = decodeDevice(token.device)
230+
const isCurrent = device.id === item.id && device.platform === item.platform
230231
return {
231232
isCurrent,
232233
label: `[${item.platform}] ${item.hostname} ` +
@@ -368,6 +369,7 @@ export default defineComponent({
368369
369370
watch(tab, () => {
370371
offline.value = false
372+
activationToken.value = ''
371373
})
372374
373375
watchEffect(async () => {

src/renderer/others/premium.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type Payload = {
2525
addDevice: { licenseId: string }
2626
fetchDevices: { licenseId: string }
2727
upgradeLicense: { oldLicense: string, locale: string }
28+
checkDevice: { device: string }
2829
genDeviceString: {},
2930
}
3031

@@ -142,7 +143,7 @@ export function showPremium (tab?: PremiumTab) {
142143
ga.logEvent('yn_premium_show', { purchased: getPurchased() })
143144
}
144145

145-
export function getLicenseToken (throwError = false) {
146+
export function getLicenseToken () {
146147
logger.debug('getLicenseToken')
147148
try {
148149
const tokenStr = getSetting('license')
@@ -167,10 +168,6 @@ export function getLicenseToken (throwError = false) {
167168

168169
return syncCacheLicenseToken(token)
169170
} catch (error) {
170-
if (throwError) {
171-
throw error
172-
}
173-
174171
logger.error('getLicenseToken', error)
175172
}
176173

@@ -217,11 +214,21 @@ async function setLicense (licenseId: string) {
217214
}
218215
}
219216

217+
async function checkDevice (device: string) {
218+
try {
219+
await requestApi('checkDevice', { device })
220+
} catch (error) {
221+
cleanLicense()
222+
throw error
223+
}
224+
}
225+
220226
export async function refreshLicense (opts?: { throwError?: boolean }) {
221227
logger.debug('refreshLicense', opts)
222228
try {
223229
const token = getLicenseToken()
224230
if (token) {
231+
await checkDevice(token.device)
225232
await setLicense(token.licenseId)
226233
}
227234
} catch (error) {
@@ -242,7 +249,12 @@ export async function activateLicense (licenseId: string) {
242249
export async function activateByTokenString (tokenString: string) {
243250
logger.debug('activateByToken', tokenString)
244251
await setSetting('license', tokenPrefix + tokenString)
245-
getLicenseToken(true)
252+
const token = getLicenseToken()
253+
if (token) {
254+
await checkDevice(token.device)
255+
} else {
256+
throw new Error('INVALID_LICENSE')
257+
}
246258
}
247259

248260
function checkLicenseStatus () {

0 commit comments

Comments
 (0)