Skip to content

Commit

Permalink
perf: optimize GitHub Pages rule handle logic
Browse files Browse the repository at this point in the history
  • Loading branch information
XPoet committed Jan 3, 2024
1 parent dfc6a3d commit 38f4446
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 19 deletions.
1 change: 0 additions & 1 deletion src/auto-imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@ declare global {
const IEpPicture: typeof import('~icons/ep/picture')['default']
const IEpPostcard: typeof import('~icons/ep/postcard')['default']
const IEpSetting: typeof import('~icons/ep/setting')['default']
const IEpSwitch: typeof import('~icons/ep/switch')['default']
const IEpUpload: typeof import('~icons/ep/upload')['default']
}
2 changes: 1 addition & 1 deletion src/common/model/user-settings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CompressEncoderEnum, ImageLinkFormatModel, ImageLinkRuleModel } from '@/common/model'
import { DeployServerEnum } from '@/components/image-hosting-deploy/image-hosting-deploy.model'
import { DeployServerEnum } from '@/components/deploy-bar/deploy-bar.model'

export enum ElementPlusSizeEnum {
// eslint-disable-next-line no-unused-vars
Expand Down
3 changes: 2 additions & 1 deletion src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ declare module '@vue/runtime-core' {
CompressConfigBox: typeof import('./components/compress-config-box/compress-config-box.vue')['default']
CompressTool: typeof import('./components/tools/compress-tool/compress-tool.vue')['default']
CopyImageLink: typeof import('./components/copy-image-link/copy-image-link.vue')['default']
DeployBar: typeof import('./components/deploy-bar/deploy-bar.vue')['default']
ElBreadcrumb: typeof import('element-plus/es')['ElBreadcrumb']
ElBreadcrumbItem: typeof import('element-plus/es')['ElBreadcrumbItem']
ElButton: typeof import('element-plus/es')['ElButton']
Expand Down Expand Up @@ -71,7 +72,7 @@ declare module '@vue/runtime-core' {
IEpUploadFilled: typeof import('~icons/ep/upload-filled')['default']
IEpUserFilled: typeof import('~icons/ep/user-filled')['default']
ImageCard: typeof import('./components/image-card/image-card.vue')['default']
ImageHostingDeploy: typeof import('./components/image-hosting-deploy/image-hosting-deploy.vue')['default']
ImageHostingDeploy: typeof import('./components/deploy-bar/image-hosting-deploy.vue')['default']
ImageLinkRuleConfig: typeof import('./components/image-link-rule-config/image-link-rule-config.vue')['default']
ImageSelector: typeof import('./components/image-selector/image-selector.vue')['default']
ImgProcessStateCard: typeof import('./components/tools/img-process-state-card/img-process-state-card.vue')['default']
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DeployServerEnum } from '@/components/image-hosting-deploy/image-hosting-deploy.model'
import { DeployServerEnum } from '@/components/deploy-bar/deploy-bar.model'

export const getDeployServerName = (server: DeployServerEnum) => {
switch (server) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,7 @@
$t('settings.image_hosting_deploy.deploy_to', { server: getDeployServerName(di.type) })
"
>
<el-button
type="primary"
:disabled="disabled && di.status !== null"
text
@click="onDeploy(di)"
>
<el-button type="primary" :disabled="disabled" text @click="onDeploy(di)">
{{ $t('settings.image_hosting_deploy.one_click_deploy') }}
</el-button>
</el-tooltip>
Expand All @@ -55,8 +50,8 @@ import { store } from '@/stores'
import { checkoutGhPagesBranch } from '@/common/api'
import { DeployStatusInfo, ImageLinkTypeEnum } from '@/common/model'
import { formatDatetime } from '@/utils'
import { DeployServerEnum } from '@/components/image-hosting-deploy/image-hosting-deploy.model'
import { getDeployServerName } from '@/components/image-hosting-deploy/image-hosting-deploy.util'
import { DeployServerEnum } from '@/components/deploy-bar/deploy-bar.model'
import { getDeployServerName } from '@/components/deploy-bar/deploy-bar.util'
import i18n from '@/plugins/vue/i18n'
import { saveCloudDeployInfo } from '@/views/main-container/main-container.util'
Expand Down Expand Up @@ -98,5 +93,5 @@ const onDeploy = (deployItem: DeployStatusInfo) => {
</script>

<style scoped lang="stylus">
@import "image-hosting-deploy.styl"
@import "deploy-bar.styl"
</style>
2 changes: 1 addition & 1 deletion src/stores/modules/user-settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import UserSettingsStateTypes, {
ImgLinkRuleActionsEnum
} from '@/stores/modules/user-settings/types'
import { LS_PICX_SETTINGS } from '@/common/constant'
import { DeployServerEnum } from '@/components/image-hosting-deploy/image-hosting-deploy.model'
import { DeployServerEnum } from '@/components/deploy-bar/deploy-bar.model'
import { imgLinkRuleVerification } from '@/stores/modules/user-settings/utils'

const initSettings: UserSettingsModel = {
Expand Down
9 changes: 7 additions & 2 deletions src/views/my-settings/my-settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
:key="item.name + '-' + item.id"
:label="item.name"
:value="item.name"
:disabled="isDeployGitHubPages(item.name)"
class="image-link-type-rule-option"
>
<span class="left">{{ item.name }}</span>
Expand Down Expand Up @@ -149,7 +150,7 @@

<!-- 图床部署设置 -->
<el-collapse-item :title="$t('settings.image_hosting_deploy.title')" name="6">
<image-hosting-deploy />
<deploy-bar />
</el-collapse-item>

<!-- 主题设置 -->
Expand Down Expand Up @@ -178,7 +179,7 @@
<script lang="ts" setup>
import { computed, watch } from 'vue'
import { store } from '@/stores'
import { ThemeModeEnum, UserSettingsModel } from '@/common/model'
import { ImageLinkTypeEnum, ThemeModeEnum, UserSettingsModel } from '@/common/model'
const userSettings = computed(() => store.getters.getUserSettings).value
Expand All @@ -201,6 +202,10 @@ const setWatermarkConfig = (config: UserSettingsModel['watermark']) => {
persistUserSettings()
}
const isDeployGitHubPages = (name: string) => {
return name === ImageLinkTypeEnum.GitHubPages && !userSettings.deploy.github.status
}
watch(
() => userSettings.imageName.autoTimestampNaming,
(enable) => {
Expand Down
6 changes: 3 additions & 3 deletions src/views/upload-image/upload-image.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
</div>
</div>

<div class="row-item">
<!-- 部署 -->
<div class="row-item" v-if="userConfigInfo.logined">
<div class="content-box">
<!-- 部署 -->
<image-hosting-deploy :disabled="!isCanDeploy" />
<deploy-bar :disabled="!isCanDeploy" />
</div>
</div>

Expand Down

0 comments on commit 38f4446

Please sign in to comment.