mirror of https://github.com/halo-dev/halo
pull/3445/head
parent
da3a315f8f
commit
91c9ac6981
|
@ -4,7 +4,7 @@ const baseUrl = '/api/admin/themes'
|
||||||
|
|
||||||
const themeApi = {}
|
const themeApi = {}
|
||||||
|
|
||||||
themeApi.listAll = () => {
|
themeApi.list = () => {
|
||||||
return service({
|
return service({
|
||||||
url: `${baseUrl}`,
|
url: `${baseUrl}`,
|
||||||
method: 'get'
|
method: 'get'
|
||||||
|
@ -133,63 +133,6 @@ themeApi.fetching = url => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
themeApi.fetchingBranches = url => {
|
|
||||||
return service({
|
|
||||||
url: `${baseUrl}/fetchingBranches`,
|
|
||||||
timeout: 60000,
|
|
||||||
params: {
|
|
||||||
uri: url
|
|
||||||
},
|
|
||||||
method: 'post'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
themeApi.fetchingReleases = url => {
|
|
||||||
return service({
|
|
||||||
url: `${baseUrl}/fetchingReleases`,
|
|
||||||
timeout: 60000,
|
|
||||||
params: {
|
|
||||||
uri: url
|
|
||||||
},
|
|
||||||
method: 'post'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
themeApi.fetchingBranch = (url, branchName) => {
|
|
||||||
return service({
|
|
||||||
url: `${baseUrl}/fetchBranch`,
|
|
||||||
timeout: 60000,
|
|
||||||
params: {
|
|
||||||
uri: url,
|
|
||||||
branch: branchName
|
|
||||||
},
|
|
||||||
method: 'get'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
themeApi.fetchingLatestRelease = url => {
|
|
||||||
return service({
|
|
||||||
url: `${baseUrl}/fetchLatestRelease`,
|
|
||||||
timeout: 60000,
|
|
||||||
params: {
|
|
||||||
uri: url
|
|
||||||
},
|
|
||||||
method: 'get'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
themeApi.fetchingRelease = (url, tagName) => {
|
|
||||||
return service({
|
|
||||||
url: `${baseUrl}/fetchingRelease`,
|
|
||||||
timeout: 60000,
|
|
||||||
params: {
|
|
||||||
uri: url,
|
|
||||||
tag: tagName
|
|
||||||
},
|
|
||||||
method: 'get'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
themeApi.getContent = path => {
|
themeApi.getContent = path => {
|
||||||
return service({
|
return service({
|
||||||
url: `${baseUrl}/files/content`,
|
url: `${baseUrl}/files/content`,
|
||||||
|
|
|
@ -859,7 +859,11 @@ body {
|
||||||
}
|
}
|
||||||
|
|
||||||
.ant-affix {
|
.ant-affix {
|
||||||
z-index: 2000!important;
|
z-index: 1000!important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.v-note-wrapper {
|
||||||
|
z-index: 999!important;
|
||||||
}
|
}
|
||||||
|
|
||||||
#nprogress {
|
#nprogress {
|
||||||
|
|
|
@ -132,7 +132,7 @@ export default {
|
||||||
handleListThemes() {
|
handleListThemes() {
|
||||||
this.themesLoading = true
|
this.themesLoading = true
|
||||||
themeApi
|
themeApi
|
||||||
.listAll()
|
.list()
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
this.themes = response.data.data
|
this.themes = response.data.data
|
||||||
})
|
})
|
||||||
|
|
|
@ -162,13 +162,13 @@
|
||||||
更多主题请访问:
|
更多主题请访问:
|
||||||
<a
|
<a
|
||||||
target="_blank"
|
target="_blank"
|
||||||
href="https://halo.run/p/themes"
|
href="https://halo.run/p/themes.html"
|
||||||
>https://halo.run/p/themes</a>
|
>https://halo.run/p/themes</a>
|
||||||
</template>
|
</template>
|
||||||
</a-alert>
|
</a-alert>
|
||||||
</a-tab-pane>
|
</a-tab-pane>
|
||||||
<a-tab-pane
|
<a-tab-pane
|
||||||
tab="远程拉取"
|
tab="远程下载"
|
||||||
key="2"
|
key="2"
|
||||||
>
|
>
|
||||||
<a-form-model
|
<a-form-model
|
||||||
|
@ -179,72 +179,18 @@
|
||||||
>
|
>
|
||||||
<a-form-model-item
|
<a-form-model-item
|
||||||
prop="url"
|
prop="url"
|
||||||
label="Github 仓库地址:"
|
label="远程地址:"
|
||||||
|
help="* 支持 Git 仓库地址,ZIP 链接。"
|
||||||
>
|
>
|
||||||
<a-input-search
|
<a-input v-model="installModal.remote.url" />
|
||||||
v-model="installModal.remote.url"
|
|
||||||
enter-button="获取版本"
|
|
||||||
@search="handleFetching"
|
|
||||||
:loading="installModal.remote.repoFetching"
|
|
||||||
/>
|
|
||||||
</a-form-model-item>
|
</a-form-model-item>
|
||||||
<a-form-model-item label="版本类型:">
|
<a-form-model-item>
|
||||||
<a-select v-model="installModal.remote.byBranchOrRelease">
|
|
||||||
<a-select-option value="release">发行版</a-select-option>
|
|
||||||
<a-select-option value="branch">开发版</a-select-option>
|
|
||||||
</a-select>
|
|
||||||
</a-form-model-item>
|
|
||||||
<a-form-model-item
|
|
||||||
label="版本:"
|
|
||||||
v-show="installModal.remote.byBranchOrRelease === 'release'"
|
|
||||||
>
|
|
||||||
<a-select
|
|
||||||
v-model="installModal.remote.selectedRelease"
|
|
||||||
:loading="installModal.remote.repoFetching"
|
|
||||||
>
|
|
||||||
<a-select-option
|
|
||||||
v-for="(item, index) in installModal.remote.releases"
|
|
||||||
:key="index"
|
|
||||||
:value="item.branch"
|
|
||||||
>{{ item.branch }}</a-select-option>
|
|
||||||
</a-select>
|
|
||||||
</a-form-model-item>
|
|
||||||
<a-form-model-item
|
|
||||||
label="分支:"
|
|
||||||
v-show="installModal.remote.byBranchOrRelease === 'branch'"
|
|
||||||
>
|
|
||||||
<a-select
|
|
||||||
v-model="installModal.remote.selectedBranch"
|
|
||||||
:loading="installModal.remote.repoFetching"
|
|
||||||
>
|
|
||||||
<a-select-option
|
|
||||||
v-for="(item, index) in installModal.remote.branches"
|
|
||||||
:key="index"
|
|
||||||
:value="item.branch"
|
|
||||||
>{{ item.branch }}</a-select-option>
|
|
||||||
</a-select>
|
|
||||||
</a-form-model-item>
|
|
||||||
<a-form-model-item v-show="installModal.remote.byBranchOrRelease === 'release'">
|
|
||||||
<ReactiveButton
|
<ReactiveButton
|
||||||
:disabled="!installModal.remote.selectedRelease"
|
|
||||||
type="primary"
|
type="primary"
|
||||||
@click="handleReleaseDownloading"
|
@click="handleRemoteFetching"
|
||||||
@callback="handleReleaseDownloadedCallback"
|
@callback="handleRemoteFetchCallback"
|
||||||
:loading="installModal.remote.releaseDownloading"
|
:loading="installModal.remote.fetching"
|
||||||
:errored="installModal.remote.releaseDownloadErrored"
|
:errored="installModal.remote.fetchErrored"
|
||||||
text="下载"
|
|
||||||
loadedText="下载成功"
|
|
||||||
erroredText="下载失败"
|
|
||||||
></ReactiveButton>
|
|
||||||
</a-form-model-item>
|
|
||||||
<a-form-model-item v-show="installModal.remote.byBranchOrRelease === 'branch'">
|
|
||||||
<ReactiveButton
|
|
||||||
:disabled="!installModal.remote.selectedBranch"
|
|
||||||
type="primary"
|
|
||||||
@click="handleBranchPulling"
|
|
||||||
@callback="handleBranchPulledCallback"
|
|
||||||
:loading="installModal.remote.branchPulling"
|
|
||||||
:errored="installModal.remote.branchPullErrored"
|
|
||||||
text="下载"
|
text="下载"
|
||||||
loadedText="下载成功"
|
loadedText="下载成功"
|
||||||
erroredText="下载失败"
|
erroredText="下载失败"
|
||||||
|
@ -256,7 +202,7 @@
|
||||||
closable
|
closable
|
||||||
>
|
>
|
||||||
<template slot="message">
|
<template slot="message">
|
||||||
远程地址即主题仓库地址,建议使用发行版本。更多主题请访问:
|
目前仅支持远程 Git 仓库和 ZIP 下载链接。更多主题请访问:
|
||||||
<a
|
<a
|
||||||
target="_blank"
|
target="_blank"
|
||||||
href="https://halo.run/p/themes.html"
|
href="https://halo.run/p/themes.html"
|
||||||
|
@ -341,23 +287,11 @@ export default {
|
||||||
remote: {
|
remote: {
|
||||||
url: null,
|
url: null,
|
||||||
|
|
||||||
repoFetching: false,
|
fetching: false,
|
||||||
repoFetchErrored: false,
|
fetchErrored: false,
|
||||||
|
|
||||||
branches: [],
|
|
||||||
selectedBranch: null,
|
|
||||||
branchPulling: false,
|
|
||||||
branchPullErrored: false,
|
|
||||||
|
|
||||||
releases: [],
|
|
||||||
selectedRelease: null,
|
|
||||||
releaseDownloading: false,
|
|
||||||
releaseDownloadErrored: false,
|
|
||||||
|
|
||||||
byBranchOrRelease: 'release', // release or branch, default is release
|
|
||||||
|
|
||||||
rules: {
|
rules: {
|
||||||
url: [{ required: true, message: '* Github 仓库地址不能为空', trigger: ['change'] }],
|
url: [{ required: true, message: '* 远程地址不能为空', trigger: ['change'] }],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -417,7 +351,7 @@ export default {
|
||||||
handleListThemes() {
|
handleListThemes() {
|
||||||
this.list.loading = true
|
this.list.loading = true
|
||||||
themeApi
|
themeApi
|
||||||
.listAll()
|
.list()
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
this.list.data = response.data.data
|
this.list.data = response.data.data
|
||||||
})
|
})
|
||||||
|
@ -463,72 +397,26 @@ export default {
|
||||||
this.localUpdateModel.visible = false
|
this.localUpdateModel.visible = false
|
||||||
this.handleListThemes()
|
this.handleListThemes()
|
||||||
},
|
},
|
||||||
handleFetching() {
|
handleRemoteFetching() {
|
||||||
const _this = this
|
this.$refs.remoteInstallForm.validate((valid) => {
|
||||||
_this.$refs.remoteInstallForm.validate((valid) => {
|
|
||||||
if (valid) {
|
if (valid) {
|
||||||
_this.installModal.remote.repoFetching = true
|
this.installModal.remote.fetching = true
|
||||||
themeApi.fetchingBranches(_this.installModal.remote.url).then((response) => {
|
|
||||||
const branches = response.data.data
|
|
||||||
_this.installModal.remote.branches = branches
|
|
||||||
if (branches && branches.length > 0) {
|
|
||||||
_this.installModal.remote.selectedBranch = branches[0].branch
|
|
||||||
}
|
|
||||||
})
|
|
||||||
themeApi
|
themeApi
|
||||||
.fetchingReleases(_this.installModal.remote.url)
|
.fetching(this.installModal.remote.url)
|
||||||
.then((response) => {
|
.catch(() => {
|
||||||
const releases = response.data.data
|
this.installModal.remote.fetchErrored = true
|
||||||
_this.installModal.remote.releases = releases
|
|
||||||
if (releases && releases.length > 0) {
|
|
||||||
_this.installModal.remote.selectedRelease = releases[0].branch
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
_this.installModal.remote.repoFetching = false
|
this.installModal.remote.fetching = false
|
||||||
}, 400)
|
}, 400)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleBranchPulling() {
|
handleRemoteFetchCallback() {
|
||||||
this.installModal.remote.branchPulling = true
|
if (this.installModal.remote.fetchErrored) {
|
||||||
themeApi
|
this.installModal.remote.fetchErrored = false
|
||||||
.fetchingBranch(this.installModal.remote.url, this.installModal.remote.selectedBranch)
|
|
||||||
.catch(() => {
|
|
||||||
this.installModal.remote.branchPullErrored = true
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
setTimeout(() => {
|
|
||||||
this.installModal.remote.branchPulling = false
|
|
||||||
}, 400)
|
|
||||||
})
|
|
||||||
},
|
|
||||||
handleBranchPulledCallback() {
|
|
||||||
if (this.installModal.remote.branchPullErrored) {
|
|
||||||
this.installModal.remote.branchPullErrored = false
|
|
||||||
} else {
|
|
||||||
this.installModal.visible = false
|
|
||||||
this.handleListThemes()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
handleReleaseDownloading() {
|
|
||||||
this.installModal.remote.releaseDownloading = true
|
|
||||||
themeApi
|
|
||||||
.fetchingRelease(this.installModal.remote.url, this.installModal.remote.selectedRelease)
|
|
||||||
.catch(() => {
|
|
||||||
this.installModal.remote.branchPullErrored = true
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
setTimeout(() => {
|
|
||||||
this.installModal.remote.releaseDownloading = false
|
|
||||||
}, 400)
|
|
||||||
})
|
|
||||||
},
|
|
||||||
handleReleaseDownloadedCallback() {
|
|
||||||
if (this.installModal.remote.releaseDownloadErrored) {
|
|
||||||
this.installModal.remote.releaseDownloadErrored = false
|
|
||||||
} else {
|
} else {
|
||||||
this.installModal.visible = false
|
this.installModal.visible = false
|
||||||
this.handleListThemes()
|
this.handleListThemes()
|
||||||
|
@ -574,12 +462,7 @@ export default {
|
||||||
if (this.$refs.updateByupload) {
|
if (this.$refs.updateByupload) {
|
||||||
this.$refs.updateByupload.handleClearFileList()
|
this.$refs.updateByupload.handleClearFileList()
|
||||||
}
|
}
|
||||||
this.installModal.remote.branches = []
|
|
||||||
this.installModal.remote.selectedBranch = null
|
|
||||||
this.installModal.remote.releases = []
|
|
||||||
this.installModal.remote.selectedRelease = null
|
|
||||||
this.installModal.remote.url = null
|
this.installModal.remote.url = null
|
||||||
this.installModal.remote.byBranchOrRelease = 'release'
|
|
||||||
this.handleListThemes()
|
this.handleListThemes()
|
||||||
},
|
},
|
||||||
onThemeSettingsDrawerClose() {
|
onThemeSettingsDrawerClose() {
|
||||||
|
|
Loading…
Reference in New Issue