Skip to content

Commit d67cfa0

Browse files
committed
Merge branch 'main' of github.com:Sjj1024/PakePlus
merge
2 parents e55fd37 + 9bbff17 commit d67cfa0

File tree

11 files changed

+87
-18
lines changed

11 files changed

+87
-18
lines changed

public/custom.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,23 @@ console.log(
33
'color:orangered;font-weight:bolder'
44
)
55

6+
// very important, if you don't know what it is, don't touch it
7+
// 非常重要,不懂代码不要动
68
const hookClick = (e) => {
7-
e.preventDefault()
89
const origin = e.target.closest('a')
9-
if (origin && origin.href) {
10+
const isBaseTargetBlank = document.querySelector(
11+
'head base[target="_blank"]'
12+
)
13+
console.log('origin', origin, isBaseTargetBlank)
14+
if (
15+
(origin && origin.href && origin.target === '_blank') ||
16+
(origin && origin.href && isBaseTargetBlank)
17+
) {
18+
e.preventDefault()
19+
console.log('handle origin', origin)
1020
location.href = origin.href
21+
} else {
22+
console.log('not handle origin', origin)
1123
}
1224
}
1325

src-tauri/data/custom.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,23 @@ console.log(
33
'color:orangered;font-weight:bolder'
44
)
55

6+
// very important, if you don't know what it is, don't touch it
7+
// 非常重要,不懂代码不要动
68
const hookClick = (e) => {
7-
e.preventDefault()
89
const origin = e.target.closest('a')
9-
if (origin && origin.href) {
10+
const isBaseTargetBlank = document.querySelector(
11+
'head base[target="_blank"]'
12+
)
13+
console.log('origin', origin, isBaseTargetBlank)
14+
if (
15+
(origin && origin.href && origin.target === '_blank') ||
16+
(origin && origin.href && isBaseTargetBlank)
17+
) {
18+
e.preventDefault()
19+
console.log('handle origin', origin)
1020
location.href = origin.href
21+
} else {
22+
console.log('not handle origin', origin)
1123
}
1224
}
1325

src/components/TauriConfig.vue

+15
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,11 @@ import { oneDark } from '@codemirror/theme-one-dark'
382382
import { openUrl, urlMap } from '@/utils/common'
383383
import { ref } from 'vue'
384384
import { usePakeStore } from '@/store'
385+
import { ElMessage } from 'element-plus'
386+
import { useI18n } from 'vue-i18n'
385387
386388
const store = usePakeStore()
389+
const { t } = useI18n()
387390
const activeName = ref('1')
388391
const localTheme = localStorage.getItem('theme')
389392
@@ -422,8 +425,20 @@ const updateCode = () => {
422425
uiCode.value = JSON.stringify(store.currentProject.more, null, 2)
423426
}
424427
428+
const checkJson = () => {
429+
try {
430+
const codeObj = JSON.parse(uiCode.value)
431+
console.log('codeObj', codeObj)
432+
store.updateTauriConfig(codeObj)
433+
return true
434+
} catch (error) {
435+
return false
436+
}
437+
}
438+
425439
defineExpose({
426440
updateCode,
441+
checkJson,
427442
})
428443
</script>
429444

src/lang/en_us.ts

+3
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,7 @@ export default {
125125
windowKeep: 'Window Keep',
126126
injectJq: 'Inject JQ',
127127
scriptEdit: 'Script Edit',
128+
dispatchError: 'dispatch error',
129+
dispatchSuccess: 'dispatch success',
130+
jsonError: 'json format error',
128131
}

src/lang/ja_jp.ts

+3
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,7 @@ export default {
125125
windowKeep: 'ウィンドウ保持',
126126
injectJq: 'JQを注入',
127127
scriptEdit: 'スクリプト編集',
128+
dispatchError: 'dispatchエラー',
129+
dispatchSuccess: 'dispatch成功',
130+
jsonError: 'json形式エラー',
128131
}

src/lang/ko_kr.ts

+3
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,7 @@ export default {
126126
windowKeep: '창 유지',
127127
injectJq: 'JQ 주입',
128128
scriptEdit: '스크립트 편집',
129+
dispatchError: 'dispatch 오류',
130+
dispatchSuccess: 'dispatch 성공',
131+
jsonError: 'json 형식 오류',
129132
}

src/lang/zh_cn.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default {
3636
appIcon: 'APP图标',
3737
appVersion: 'APP版本',
3838
versionSemVer: '版本号必须是例如:1.2.1格式',
39-
platform: '预览平台',
39+
platform: '窗口模式',
4040
desktop: '桌面端',
4141
winSize: '窗口大小',
4242
width: '宽度',
@@ -123,4 +123,7 @@ export default {
123123
windowKeep: '窗口保持',
124124
injectJq: '注入JQ',
125125
scriptEdit: '脚本编辑',
126+
dispatchError: 'dispatch错误',
127+
dispatchSuccess: 'dispatch成功',
128+
jsonError: 'json格式错误',
126129
}

src/lang/zh_tw.ts

+3
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,7 @@ export default {
120120
windowKeep: '窗口保持',
121121
injectJq: '注入JQ',
122122
scriptEdit: '腳本編輯',
123+
dispatchError: 'dispatch錯誤',
124+
dispatchSuccess: 'dispatch成功',
125+
jsonError: 'json格式錯誤',
123126
}

src/pages/edit.vue

+26-11
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@
385385
:width="isTauri ? '90%' : '60%'"
386386
center
387387
align-center
388-
@closed="closeConfigDialog"
388+
:before-close="closeConfigDialog"
389389
>
390390
<template #header="{ titleId, titleClass }">
391391
<div class="configHeader">
@@ -399,13 +399,13 @@
399399
</template>
400400
<TauriConfig ref="tauriConfigRef" :isJson="isJson" />
401401
</el-dialog>
402-
<!-- code edit -->
402+
<!-- js code edit -->
403403
<el-dialog
404404
v-model="codeDialogVisible"
405405
:width="isTauri ? '90%' : '60%'"
406406
center
407407
align-center
408-
@closed="closeConfigDialog"
408+
@closed="closeJsCodeEditDialog"
409409
>
410410
<template #header="{ titleId, titleClass }">
411411
<div class="configHeader">
@@ -610,10 +610,20 @@ const changeUrl = (value: string) => {
610610
}
611611
612612
// close tauri config dialog
613-
const closeConfigDialog = () => {
614-
configDialogVisible.value = false
613+
const closeConfigDialog = (done: any) => {
614+
console.log('closeConfigDialog', done)
615+
const isJson = tauriConfigRef.value?.checkJson()
616+
if (isJson) {
617+
configDialogVisible.value = false
618+
done()
619+
} else {
620+
ElMessage.error(t('jsonError'))
621+
}
622+
}
623+
624+
// close js code edit dialog
625+
const closeJsCodeEditDialog = () => {
615626
codeDialogVisible.value = false
616-
// console.log('closeConfigDialog', tauriConfig)
617627
}
618628
619629
// switch tauri config json or code
@@ -734,6 +744,9 @@ const uploadIcon = async () => {
734744
735745
// update icon file content
736746
const updateIcon = async () => {
747+
if (iconBase64.value === '') {
748+
return
749+
}
737750
const iconContent = store.currentProject.iconRound
738751
? roundIcon.value.split('base64,')[1]
739752
: iconBase64.value.split('base64,')[1]
@@ -1168,7 +1181,7 @@ const publishWeb = async () => {
11681181
console.log('publish web')
11691182
loadingText(t('syncConfig') + '...')
11701183
// update app icon
1171-
iconBase64.value && (await updateIcon())
1184+
await updateIcon()
11721185
// update build.yml
11731186
await updateBuildYml()
11741187
// update Cargo.toml
@@ -1249,7 +1262,7 @@ const dispatchAction = async () => {
12491262
console.log('dispatchRes---', dispatchRes)
12501263
if (dispatchRes.status !== 204) {
12511264
console.error('dispatch res error', dispatchRes)
1252-
ElMessage.error('dispatch res error')
1265+
ElMessage.error(t('dispatchError') + ':' + dispatchRes.data.message)
12531266
buildLoading.value = false
12541267
return
12551268
} else {
@@ -1278,10 +1291,12 @@ const dispatchAction = async () => {
12781291
12791292
// create issue
12801293
const createIssue = async (url: string, label: string, title: string) => {
1294+
console.log('createIssue', url, label, title)
12811295
const issueRes: any = await githubApi.createIssue({
1282-
body: `name: ${store.currentProject.name}\n
1283-
build info: ${url}`,
1284-
labels: [label],
1296+
body: `build name: ${store.currentProject.name}\r
1297+
show name: ${store.currentProject.showName}\r
1298+
build state: ${label}\r
1299+
build action: ${url}`,
12851300
title: title,
12861301
})
12871302
console.log('issueRes---', issueRes)

src/pages/home.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ const commitShas = async (tips: boolean = true) => {
358358
console.log('wait fork done res', res)
359359
if (res[0] && res[1]) {
360360
// delete build.yml
361-
store.noMain && deleteBuildYml()
361+
store.noSjj1024 && deleteBuildYml()
362362
testLoading.value = false
363363
if (!tips) {
364364
tokenDialog.value = false

src/store/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ export const usePakeStore = defineStore('pakeplus', {
830830
getAddAge: (state) => {
831831
return (num: number) => state.age + num
832832
},
833-
noMain: (state) => {
833+
noSjj1024: (state) => {
834834
return state.userInfo.login !== 'Sjj1024'
835835
},
836836
isRelease: (state) => {

0 commit comments

Comments
 (0)