From a580d89e3915853d82b35d68c50bc0e4f86f6ebc Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Wed, 3 Aug 2022 11:30:13 +0800 Subject: [PATCH] feat: add support for theme management (halo-dev/console#592) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ryan Wang #### What type of PR is this? /kind feature /milestone 2.0 #### What this PR does / why we need it: 添加基础的主题管理支持,适配 https://github.com/halo-dev/halo/pull/2280 /hold until https://github.com/halo-dev/halo/pull/2280 merge #### Which issue(s) this PR fixes: None #### Screenshots: |image|image| | ---- | ---- | |image| | #### Special notes for your reviewer: None #### Does this PR introduce a user-facing change? ```release-note None ``` --- package.json | 2 +- packages/shared/package.json | 2 +- packages/shared/src/utils/api-client.ts | 2 + pnpm-lock.yaml | 12 +- src/modules/interface/themes/ThemeDetail.vue | 220 ++++-------------- .../themes/components/ThemeListModal.vue | 143 ++++++++++++ .../interface/themes/composables/use-theme.ts | 83 +++++++ 7 files changed, 278 insertions(+), 186 deletions(-) create mode 100644 src/modules/interface/themes/components/ThemeListModal.vue create mode 100644 src/modules/interface/themes/composables/use-theme.ts diff --git a/package.json b/package.json index 5cb2b20ad..ec93d3c2e 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "@formkit/vue": "1.0.0-beta.10", "@halo-dev/admin-api": "^1.1.0", "@halo-dev/admin-shared": "workspace:*", - "@halo-dev/api-client": "^0.0.6", + "@halo-dev/api-client": "^0.0.7", "@halo-dev/components": "workspace:*", "@vueuse/components": "^8.9.4", "@vueuse/core": "^8.9.4", diff --git a/packages/shared/package.json b/packages/shared/package.json index 453afb6da..59641352c 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -35,7 +35,7 @@ "homepage": "https://github.com/halo-dev/halo-admin/tree/next/shared/components#readme", "license": "MIT", "dependencies": { - "@halo-dev/api-client": "^0.0.6", + "@halo-dev/api-client": "^0.0.7", "@halo-dev/components": "workspace:*", "axios": "^0.27.2" }, diff --git a/packages/shared/src/utils/api-client.ts b/packages/shared/src/utils/api-client.ts index 64d63c84e..3bbb12df7 100644 --- a/packages/shared/src/utils/api-client.ts +++ b/packages/shared/src/utils/api-client.ts @@ -9,6 +9,7 @@ import { V1alpha1RoleBindingApi, V1alpha1SettingApi, V1alpha1UserApi, + ThemeHaloRunV1alpha1ThemeApi, } from "@halo-dev/api-client"; import type { AxiosInstance } from "axios"; import axios from "axios"; @@ -58,6 +59,7 @@ function setupApiClient(axios: AxiosInstance) { ), plugin: new PluginHaloRunV1alpha1PluginApi(undefined, apiUrl, axios), user: new V1alpha1UserApi(undefined, apiUrl, axios), + theme: new ThemeHaloRunV1alpha1ThemeApi(undefined, apiUrl, axios), // TODO optional // link: new CoreHaloRunV1alpha1LinkApi(undefined, apiUrl, axios), diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ae0e8d696..668bfff15 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,7 +14,7 @@ importers: '@formkit/vue': 1.0.0-beta.10 '@halo-dev/admin-api': ^1.1.0 '@halo-dev/admin-shared': workspace:* - '@halo-dev/api-client': ^0.0.6 + '@halo-dev/api-client': ^0.0.7 '@halo-dev/components': workspace:* '@rushstack/eslint-patch': ^1.1.4 '@tailwindcss/aspect-ratio': ^0.4.0 @@ -84,7 +84,7 @@ importers: '@formkit/vue': 1.0.0-beta.10_h3koegrx2cxvlj7ceqfsnru344 '@halo-dev/admin-api': 1.1.0 '@halo-dev/admin-shared': link:packages/shared - '@halo-dev/api-client': 0.0.6 + '@halo-dev/api-client': 0.0.7 '@halo-dev/components': link:packages/components '@vueuse/components': 8.9.4_vue@3.2.37 '@vueuse/core': 8.9.4_vue@3.2.37 @@ -174,12 +174,12 @@ importers: packages/shared: specifiers: - '@halo-dev/api-client': ^0.0.6 + '@halo-dev/api-client': ^0.0.7 '@halo-dev/components': workspace:* axios: ^0.27.2 vite-plugin-dts: ^1.4.0 dependencies: - '@halo-dev/api-client': 0.0.6 + '@halo-dev/api-client': 0.0.7 '@halo-dev/components': link:../components axios: 0.27.2 devDependencies: @@ -1873,8 +1873,8 @@ packages: - debug dev: false - /@halo-dev/api-client/0.0.6: - resolution: {integrity: sha512-JDWGlTq+pHVrZsmqDCXAowZQFcNL3M6+guL37yrKbhylUgIutYpCMU/d2Qogc+c43FzFBq84igP84T5XtuknjQ==} + /@halo-dev/api-client/0.0.7: + resolution: {integrity: sha512-UP36IYuSuDh/rRX+fwZAiPE+h/bhBLgh4XVfqVFaynHc3fLQhaUchqzqvep0HYAPHW4E7EDfQaNiFLXHUrH1bA==} dev: false /@halo-dev/logger/1.1.0: diff --git a/src/modules/interface/themes/ThemeDetail.vue b/src/modules/interface/themes/ThemeDetail.vue index df939e689..3ab6b6eaa 100644 --- a/src/modules/interface/themes/ThemeDetail.vue +++ b/src/modules/interface/themes/ThemeDetail.vue @@ -1,184 +1,39 @@ 切换主题 - 启用 + + 启用 +