Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use globally provided axios instance #114

Merged
merged 2 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ build {
}

halo {
version = '2.15.0'
version = '2.17.0'
debug = true;
}
4 changes: 2 additions & 2 deletions console/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
},
"dependencies": {
"@halo-dev/api-client": "^2.11.0",
"@halo-dev/api-client": "^2.17.0",
"@halo-dev/components": "^1.10.0",
"@halo-dev/console-shared": "^2.11.0",
"@halo-dev/richtext-editor": "^2.12.0",
Expand All @@ -30,7 +30,7 @@
"vue-router": "^4.1.6"
},
"devDependencies": {
"@halo-dev/ui-plugin-bundler-kit": "^2.12.0",
"@halo-dev/ui-plugin-bundler-kit": "^2.17.0",
"@iconify/json": "^2.2.180",
"@rushstack/eslint-patch": "^1.2.0",
"@tailwindcss/aspect-ratio": "^0.4.2",
Expand Down
20 changes: 14 additions & 6 deletions console/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions console/src/components/MomentEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import TextEditor from "@/components/TextEditor.vue";
import SendMoment from "~icons/ic/sharp-send";
import cloneDeep from "lodash.clonedeep";
import TablerPhoto from "~icons/tabler/photo";
import apiClient from "@/utils/api-client";
import { axiosInstance } from "@halo-dev/api-client";
import { useConsoleTagQueryFetch } from "@/composables/use-tag";

const props = withDefaults(
Expand Down Expand Up @@ -83,7 +83,7 @@ const handlerCreateOrUpdateMoment = async () => {
const handleSave = async (moment: Moment) => {
moment.spec.releaseTime = new Date().toISOString();
moment.spec.approved = true;
const { data } = await apiClient.post<Moment>(
const { data } = await axiosInstance.post<Moment>(
`/apis/console.api.moment.halo.run/v1alpha1/moments`,
moment
);
Expand All @@ -92,12 +92,12 @@ const handleSave = async (moment: Moment) => {
};

const handleUpdate = async (moment: Moment) => {
const { data } = await apiClient.get<Moment>(
const { data } = await axiosInstance.get<Moment>(
`/apis/moment.halo.run/v1alpha1/moments/${moment.metadata.name}`
);
// 更新当前需要提交的 moment spec 为最新
data.spec = moment.spec;
const updated = await apiClient.put<Moment>(
const updated = await axiosInstance.put<Moment>(
`/apis/moment.halo.run/v1alpha1/moments/${moment.metadata.name}`,
data
);
Expand Down
8 changes: 4 additions & 4 deletions console/src/components/MomentItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { ListedMoment, Moment } from "@/types";
import { computed, ref, toRaw } from "vue";
import MomentEdit from "./MomentEdit.vue";
import MomentPreview from "./MomentPreview.vue";
import apiClient from "@/utils/api-client";
import { axiosInstance } from "@halo-dev/api-client";
import {
Dialog,
Toast,
Expand Down Expand Up @@ -45,7 +45,7 @@ const deleteMoment = () => {
confirmType: "danger",
onConfirm: async () => {
try {
const { data } = await apiClient.delete(
const { data } = await axiosInstance.delete(
`/apis/moment.halo.run/v1alpha1/moments/${previewMoment.value.metadata.name}`
);

Expand All @@ -65,12 +65,12 @@ const handleUpdate = (moment: Moment) => {
};

const handleApproved = async () => {
const { data } = await apiClient.get<Moment>(
const { data } = await axiosInstance.get<Moment>(
`/apis/moment.halo.run/v1alpha1/moments/${editingMoment.value.metadata.name}`
);
// 更新当前需要提交的 moment spec 为最新
data.spec.approved = true;
await apiClient.put<Moment>(
await axiosInstance.put<Moment>(
`/apis/moment.halo.run/v1alpha1/moments/${editingMoment.value.metadata.name}`,
data
);
Expand Down
4 changes: 2 additions & 2 deletions console/src/composables/use-tag.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import apiClient from "@/utils/api-client";
import { axiosInstance } from "@halo-dev/api-client";
import { useQuery } from "@tanstack/vue-query";
import type { Ref } from "vue";

Expand All @@ -25,7 +25,7 @@ export function useTagQueryFetch(
return useQuery<string[]>({
queryKey: ["moments-tags", props.keyword],
queryFn: async () => {
const { data } = await apiClient.get(
const { data } = await axiosInstance.get(
`/apis/${group}.api.moment.halo.run/v1alpha1/tags`,
{
params: {
Expand Down
8 changes: 4 additions & 4 deletions console/src/uc/MomentEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import TextEditor from "@/components/TextEditor.vue";
import SendMoment from "~icons/ic/sharp-send";
import cloneDeep from "lodash.clonedeep";
import TablerPhoto from "~icons/tabler/photo";
import apiClient from "@/utils/api-client";
import { axiosInstance } from "@halo-dev/api-client";
import { useUCTagQueryFetch } from "@/composables/use-tag";

const props = withDefaults(
Expand Down Expand Up @@ -83,7 +83,7 @@ const handlerCreateOrUpdateMoment = async () => {
const handleSave = async (moment: Moment) => {
moment.spec.releaseTime = new Date().toISOString();
moment.spec.approved = true;
const { data } = await apiClient.post<Moment>(
const { data } = await axiosInstance.post<Moment>(
`/apis/uc.api.moment.halo.run/v1alpha1/moments`,
moment
);
Expand All @@ -92,12 +92,12 @@ const handleSave = async (moment: Moment) => {
};

const handleUpdate = async (moment: Moment) => {
const { data } = await apiClient.get<Moment>(
const { data } = await axiosInstance.get<Moment>(
`/apis/uc.api.moment.halo.run/v1alpha1/moments/${moment.metadata.name}`
);
// 更新当前需要提交的 moment spec 为最新
data.spec = moment.spec;
const updated = await apiClient.put<Moment>(
const updated = await axiosInstance.put<Moment>(
`/apis/uc.api.moment.halo.run/v1alpha1/moments/${moment.metadata.name}`,
data
);
Expand Down
4 changes: 2 additions & 2 deletions console/src/uc/MomentItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { ListedMoment, Moment } from "@/types";
import { computed, ref, toRaw } from "vue";
import MomentEdit from "./MomentEdit.vue";
import MomentPreview from "@/components/MomentPreview.vue";
import apiClient from "@/utils/api-client";
import { axiosInstance } from "@halo-dev/api-client";
import {
Dialog,
Toast,
Expand Down Expand Up @@ -45,7 +45,7 @@ const deleteMoment = () => {
confirmType: "danger",
onConfirm: async () => {
try {
const { data } = await apiClient.delete(
const { data } = await axiosInstance.delete(
`/apis/uc.api.moment.halo.run/v1alpha1/moments/${previewMoment.value.metadata.name}`
);

Expand Down
4 changes: 2 additions & 2 deletions console/src/uc/MomentsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import MingcuteMomentsLine from "~icons/mingcute/moment-line";
import type { User } from "@halo-dev/api-client";
import type { ListedMoment } from "@/types";
import { useQuery } from "@tanstack/vue-query";
import apiClient from "@/utils/api-client";
import { axiosInstance } from "@halo-dev/api-client";
import MomentItem from "./MomentItem.vue";
import DatePicker from "vue-datepicker-next";
import "vue-datepicker-next/index.css";
Expand Down Expand Up @@ -92,7 +92,7 @@ const {
contributors = [selectedContributor.value.metadata.name];
}

const { data } = await apiClient.get(
const { data } = await axiosInstance.get(
"/apis/uc.api.moment.halo.run/v1alpha1/moments",
{
params: {
Expand Down
62 changes: 0 additions & 62 deletions console/src/utils/api-client.ts

This file was deleted.

4 changes: 2 additions & 2 deletions console/src/views/MomentsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import MingcuteMomentsLine from "~icons/mingcute/moment-line";
import type { ListedMoment } from "@/types";
import { useQuery } from "@tanstack/vue-query";
import apiClient from "@/utils/api-client";
import { axiosInstance } from "@halo-dev/api-client";
import MomentItem from "@/components/MomentItem.vue";
import DatePicker from "vue-datepicker-next";
import "vue-datepicker-next/index.css";
Expand Down Expand Up @@ -65,7 +65,7 @@ const {
tag,
],
queryFn: async () => {
const { data } = await apiClient.get(
const { data } = await axiosInstance.get(
"/apis/console.api.moment.halo.run/v1alpha1/moments",
{
params: {
Expand Down
8 changes: 6 additions & 2 deletions console/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { fileURLToPath, URL } from "url";

import { defineConfig } from "vite";
import { defineConfig, type Plugin } from "vite";
import vue from "@vitejs/plugin-vue";
import Icons from "unplugin-icons/vite";
import { HaloUIPluginBundlerKit } from "@halo-dev/ui-plugin-bundler-kit";

export default defineConfig({
plugins: [vue(), Icons({ compiler: "vue3" }), HaloUIPluginBundlerKit()],
plugins: [
vue(),
Icons({ compiler: "vue3" }),
HaloUIPluginBundlerKit() as Plugin,
],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
spec:
enabled: true
version: 1.0.1
requires: ">=2.15.0"
requires: ">=2.17.0"
author:
name: Halo
website: https://github.com/halo-dev
Expand Down