Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Sjj1024 committed Dec 19, 2024
1 parent 1d045de commit 9749722
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 41 deletions.
2 changes: 2 additions & 0 deletions src-tauri/capabilities/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"windows": ["main"],
"permissions": [
"core:default",
"core:app:allow-set-app-theme",
"core:app:allow-name",
"opener:default",
"http:allow-fetch",
"http:allow-fetch-cancel",
Expand Down
13 changes: 11 additions & 2 deletions src/pages/edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
>
<el-input
:value="iconFileName"
:disabled="token === null"
readonly
@click="uploadIcon"
class="iconInput"
Expand Down Expand Up @@ -222,7 +223,9 @@
<div class="footerBox">
<el-button @click="saveProject(true)">{{ t('save') }}</el-button>
<el-button @click="preview(false)">{{ t('preview') }}</el-button>
<el-button @click="createRepo">{{ t('publish') }}</el-button>
<el-button :disabled="token === null" @click="createRepo">
{{ t('publish') }}
</el-button>
<!-- <el-button @click="mouseover">test</el-button> -->
</div>
<!-- build -->
Expand Down Expand Up @@ -360,7 +363,7 @@ const formSize = ref<ComponentSize>('default')
const appFormRef = ref<FormInstance>()
const appForm: any = reactive(store.currentProject)
const platformName = platform()
const token = localStorage.getItem('token')
const iconFileName = ref('')
const selJs = ref<any>(null)
const jsFileContents = ref('')
Expand Down Expand Up @@ -1382,7 +1385,13 @@ const initJsFileContents = async () => {
})
}
// init project
const initProject = async () => {
console.log('initProject')
}
onMounted(async () => {
console.log('token', token)
getLatestRelease()
initJsFileContents()
buildTime = 0
Expand Down
89 changes: 50 additions & 39 deletions src/pages/home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ import { usePakeStore } from '@/store'
import { pakeUrlMap, openUrl, initProject } from '@/utils/common'
import pakePlusIcon from '@/assets/images/pakeplus.png'
import { useI18n } from 'vue-i18n'
import { setTheme } from '@tauri-apps/api/app'
import { invoke, convertFileSrc } from '@tauri-apps/api/core'
import { getVersion } from '@tauri-apps/api/app'
Expand All @@ -189,15 +190,17 @@ const branchDialog = ref(false)
const branchName = ref('')
const testLoading = ref(false)
const chageTheme = (theme: string) => {
const chageTheme = async (theme: string) => {
if (theme === 'light') {
document.documentElement.setAttribute('theme', 'light')
document.querySelector('html')?.classList.remove('dark')
document.querySelector('html')?.classList.add('light')
// await setTheme('light')
} else {
document.documentElement.setAttribute('theme', 'dark')
document.querySelector('html')?.classList.remove('light')
document.querySelector('html')?.classList.add('dark')
// await setTheme('dark')
}
localStorage.setItem('theme', theme)
}
Expand Down Expand Up @@ -225,17 +228,14 @@ const getImgUrl = (filePath: string) => {
// new barnch config
const showBranchDialog = () => {
// TODO if token exist, then creat branch, else next page
// if token exist, then creat branch, else next page
getCommitSha()
// checkout has github token
if (localStorage.getItem('token')) {
// need creat new branch, first input project name
branchDialog.value = true
} else {
tokenDialog.value = true
if (token.value === '') {
ElMessage.error(t('configToken'))
return
}
// need creat new branch, first input project name
branchDialog.value = true
}
const changeLang = (lang: string) => {
Expand Down Expand Up @@ -339,44 +339,55 @@ const creatLoading = ref(false)
// creat project branch
const creatBranch = async () => {
creatLoading.value = true
await uploadBuildYml()
token.value && (await uploadBuildYml())
// checkout branch name is english
if (branchName.value && /^[A-Za-z0-9]+$/.test(branchName.value)) {
console.log('branchName.value', branchName.value)
const res: any = await githubApi.createBranch(
store.userInfo.login,
'PakePlus',
{
ref: `refs/heads/${branchName.value}`,
sha: store.commit.sha,
// if token exist, then creat branch, else next page
if (token.value) {
const res: any = await githubApi.createBranch(
store.userInfo.login,
'PakePlus',
{
ref: `refs/heads/${branchName.value}`,
sha: store.commit.sha,
}
)
console.log('createBranch', res)
// 201 is ok
if (res.status === 201) {
const branchInfo: Project = {
...res.data,
...initProject,
name: branchName.value,
}
console.log('branch Info success', branchInfo)
store.setCurrentProject(branchInfo)
creatLoading.value = false
router.push('/edit')
// update new branch build.yml file
// updateBuildYml(branchName.value)
} else if (res.status === 422) {
console.log('project existed')
creatLoading.value = false
ElMessage.success(t('projectExist'))
// router.push('/publish')
} else if (res.status === 401) {
ElMessage.error(t('tokenError'))
creatLoading.value = false
} else {
creatLoading.value = false
console.log('branchInfo error', res)
ElMessage.error(
`${t('creatProjectError')}: ${res.data.message}`
)
}
)
console.log('createBranch', res)
// 201 is ok
if (res.status === 201) {
const branchInfo: Project = {
...res.data,
} else {
store.setCurrentProject({
...initProject,
name: branchName.value,
}
console.log('branch Info success', branchInfo)
store.setCurrentProject(branchInfo)
creatLoading.value = false
})
router.push('/edit')
// update new branch build.yml file
// updateBuildYml(branchName.value)
} else if (res.status === 422) {
console.log('project existed')
creatLoading.value = false
ElMessage.success(t('projectExist'))
// router.push('/publish')
} else if (res.status === 401) {
ElMessage.error(t('tokenError'))
creatLoading.value = false
} else {
creatLoading.value = false
console.log('branchInfo error', res)
ElMessage.error(`${t('creatProjectError')}: ${res.data.message}`)
}
} else {
ElMessage.error(t('englishName'))
Expand Down

0 comments on commit 9749722

Please sign in to comment.