Skip to content

Commit 8177f2f

Browse files
committed
fix: normalize app path separators for Windows registry compatibility
1 parent 5aa6604 commit 8177f2f

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

frontend/src/stores/env.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const useEnvStore = defineStore('env', () => {
1414
appName: '',
1515
appVersion: '',
1616
basePath: '',
17+
appPath: '',
1718
os: '',
1819
arch: '',
1920
})
@@ -22,7 +23,11 @@ export const useEnvStore = defineStore('env', () => {
2223

2324
const setupEnv = async () => {
2425
const _env = await GetEnv()
25-
env.value = _env
26+
const appPath = `${_env.basePath}/${_env.appName}`
27+
env.value = {
28+
..._env,
29+
appPath: _env.os === 'windows' ? appPath.replaceAll('/', '\\') : appPath,
30+
}
2631
}
2732

2833
const updateSystemProxyStatus = async () => {

frontend/src/utils/helper.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ import { ignoredError, stringifyNoFolding, message, confirm } from '@/utils'
1818

1919
// Permissions Helper
2020
export const SwitchPermissions = async (enable: boolean) => {
21-
const { basePath, appName } = useEnvStore().env
21+
const { appPath } = useEnvStore().env
2222
const args = enable
2323
? [
2424
'add',
2525
'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers',
2626
'/v',
27-
basePath + '\\' + appName,
27+
appPath,
2828
'/t',
2929
'REG_SZ',
3030
'/d',
@@ -35,20 +35,20 @@ export const SwitchPermissions = async (enable: boolean) => {
3535
'delete',
3636
'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers',
3737
'/v',
38-
basePath + '\\' + appName,
38+
appPath,
3939
'/f',
4040
]
4141
await Exec('reg', args)
4242
}
4343

4444
export const CheckPermissions = async () => {
45-
const { basePath, appName } = useEnvStore().env
45+
const { appPath } = useEnvStore().env
4646
try {
4747
const out = await Exec('reg', [
4848
'query',
4949
'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers',
5050
'/v',
51-
basePath + '\\' + appName,
51+
appPath,
5252
'/t',
5353
'REG_SZ',
5454
])

frontend/src/utils/others.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ export const getGitHubApiAuthorization = () => {
180180
}
181181

182182
export const getTaskSchXmlString = async (delay = 30) => {
183-
const { basePath, appName } = useEnvStore().env
183+
const { appPath } = useEnvStore().env
184184

185185
const xml = /*xml*/ `<?xml version="1.0" encoding="UTF-16"?>
186186
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
@@ -221,7 +221,7 @@ export const getTaskSchXmlString = async (delay = 30) => {
221221
</Settings>
222222
<Actions Context="Author">
223223
<Exec>
224-
<Command>${basePath}\\${appName}</Command>
224+
<Command>${appPath}</Command>
225225
<Arguments>tasksch</Arguments>
226226
</Exec>
227227
</Actions>

0 commit comments

Comments
 (0)