From c8a9ef1dae271b5f9d3ff30a084720db1739cd01 Mon Sep 17 00:00:00 2001 From: GaoXiang Date: Mon, 30 Mar 2026 11:07:54 +0800 Subject: [PATCH] as is --- env/.env.development | 2 +- env/.env.production | 2 +- package-lock.json | 3 ++- package.json | 2 +- rollup-plugin-robots.ts | 21 +++++++++++++++++++++ src/api/AxiosHelper.ts | 2 +- src/api/index.ts | 16 ++++++++-------- src/api/models/Enums.ts | 6 +++--- src/views/CategoryView.vue | 4 ++-- vite.config.ts | 25 ++++++++++++++++++++++++- 10 files changed, 64 insertions(+), 19 deletions(-) create mode 100644 rollup-plugin-robots.ts diff --git a/env/.env.development b/env/.env.development index 2c67dcf..3215ada 100644 --- a/env/.env.development +++ b/env/.env.development @@ -1 +1 @@ -VITE_API_BASE=http://localhost:5162 \ No newline at end of file +VITE_API_BASE=http://localhost:5002 \ No newline at end of file diff --git a/env/.env.production b/env/.env.production index a6119ba..b08f86c 100644 --- a/env/.env.production +++ b/env/.env.production @@ -1 +1 @@ -VITE_API_BASE=https://api.stopshopping.bjbj.me \ No newline at end of file +VITE_API_BASE=https://adminapi.stopshopping.bjbj.me \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 95fc6ef..5631971 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,6 @@ "name": "stop-shopping-admin", "version": "0.0.0", "dependencies": { - "@types/qs": "^6.15.0", "axios": "^1.13.6", "echarts": "^6.0.0", "qs": "^6.15.0", @@ -19,6 +18,7 @@ "@tailwindcss/vite": "^4.2.1", "@tsconfig/node24": "^24.0.4", "@types/node": "^24.11.0", + "@types/qs": "^6.15.0", "@vitejs/plugin-vue": "^6.0.4", "@vue/eslint-config-typescript": "^14.7.0", "@vue/tsconfig": "^0.8.1", @@ -2197,6 +2197,7 @@ "version": "6.15.0", "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.15.0.tgz", "integrity": "sha512-JawvT8iBVWpzTrz3EGw9BTQFg3BQNmwERdKE22vlTxawwtbyUSlMppvZYKLZzB5zgACXdXxbD3m1bXaMqP/9ow==", + "dev": true, "license": "MIT" }, "node_modules/@typescript-eslint/eslint-plugin": { diff --git a/package.json b/package.json index f175129..a49df78 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,6 @@ "format": "prettier --write --experimental-cli src/" }, "dependencies": { - "@types/qs": "^6.15.0", "axios": "^1.13.6", "echarts": "^6.0.0", "qs": "^6.15.0", @@ -26,6 +25,7 @@ "@tailwindcss/vite": "^4.2.1", "@tsconfig/node24": "^24.0.4", "@types/node": "^24.11.0", + "@types/qs": "^6.15.0", "@vitejs/plugin-vue": "^6.0.4", "@vue/eslint-config-typescript": "^14.7.0", "@vue/tsconfig": "^0.8.1", diff --git a/rollup-plugin-robots.ts b/rollup-plugin-robots.ts new file mode 100644 index 0000000..92f28cf --- /dev/null +++ b/rollup-plugin-robots.ts @@ -0,0 +1,21 @@ +import { join } from "path"; +import { type Plugin } from "rollup"; + +export default function robotsPlugin(): Plugin { + return { + name: "rollup-plugin-robots", + writeBundle(options, _) { + this.debug(options.dir || "dir undefined"); + if (options.dir) { + this.fs + .writeFile( + join(options.dir, "robots.txt"), + "User-agent: *\nDisallow: /", + ) + .catch((err) => { + this.error(err); + }); + } + }, + }; +} diff --git a/src/api/AxiosHelper.ts b/src/api/AxiosHelper.ts index 79594cb..e8068e1 100644 --- a/src/api/AxiosHelper.ts +++ b/src/api/AxiosHelper.ts @@ -6,7 +6,7 @@ import { type AntiForgeryTokenResponse, type AntiForgeryToken } from './models/A import { type ProblemDetails } from './ProblemDetails' class AxiosHelper { - private readonly REFRESH_TOKEN_URL: string = '/common/refreshtoken' + private readonly REFRESH_TOKEN_URL: string = '/admin/refreshtoken' private constructor(config?: CreateAxiosDefaults) { this.axios = Axios.create({ withCredentials: true, diff --git a/src/api/index.ts b/src/api/index.ts index f3644ec..b1ad78e 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -14,6 +14,14 @@ export const signIn = async (params: M.SignInParams): Promise return signInResult } +export const refreshToken = async (): Promise => { + return await AxiosHelper.getInstance().post('/admin/refreshtoken') +} + +export const signOut = async (): Promise => { + return await AxiosHelper.getInstance().post('/admin/signout') +} + //common export const upload = async (params: M.UploadParams): Promise => { return await AxiosHelper.getInstance().postFormData('/common/upload', params) @@ -29,14 +37,6 @@ export const csrfToken = async (): Promise => { return csrfResult } -export const refreshToken = async (): Promise => { - return await AxiosHelper.getInstance().post('/common/refreshtoken') -} - -export const signOut = async (): Promise => { - return await AxiosHelper.getInstance().post('/common/signout') -} - //category export const getCategoryTree = async (): Promise => { return await AxiosHelper.getInstance().get('/category/list') diff --git a/src/api/models/Enums.ts b/src/api/models/Enums.ts index 32cd54a..13b0d7a 100644 --- a/src/api/models/Enums.ts +++ b/src/api/models/Enums.ts @@ -1,6 +1,6 @@ export const UploadScences = { - Avatar: 'Avatar', - Product: 'Product', - Category: 'Category', + Avatar: 0, + Product: 1, + Category: 2, } as const export type UploadScencesType = (typeof UploadScences)[keyof typeof UploadScences] diff --git a/src/views/CategoryView.vue b/src/views/CategoryView.vue index 794ffbb..41152c9 100644 --- a/src/views/CategoryView.vue +++ b/src/views/CategoryView.vue @@ -2,7 +2,7 @@ import { ref, onMounted } from 'vue' import { store } from '../store/appdata' import { getCategoryTree, editCategory, deleteCategory, upload } from '../api' -import { type Category } from '../api/models' +import { type Category, UploadScences } from '../api/models' import { TreeView, type TreeItem } from '../components' type AddOrEdit = 'add' | 'edit' @@ -151,7 +151,7 @@ async function logoSelected(e: Event) { states.value.loading = true const uploadResult = await upload({ file: el.files[0]!, - scences: 'Category', + scences: UploadScences.Category, }) if (uploadResult.isSucced) { states.value.current = { diff --git a/vite.config.ts b/vite.config.ts index 4be09fc..142df43 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -5,14 +5,37 @@ import tailwindcss from '@tailwindcss/vite' import vue from '@vitejs/plugin-vue' import vueDevTools from 'vite-plugin-vue-devtools' import path from 'node:path' +import robots from './rollup-plugin-robots' // https://vite.dev/config/ export default defineConfig({ - plugins: [tailwindcss(), vue(), vueDevTools()], + plugins: [tailwindcss(), vue(), vueDevTools(), robots()], envDir: path.resolve('.', 'env'), resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)), }, }, + build: { + rollupOptions: { + output: { + manualChunks: { + vue: ['vue'], + 'vue-router': ['vue-router'], + http: ['axios', 'qs'], + echarts: ['echarts'], + }, + chunkFileNames: (chunkFileInfo) => { + for (const id of chunkFileInfo.moduleIds) { + const match = id.match(/\/pages\/([^/]+)/) + if (match) { + return `js/${match[1].toLocaleLowerCase()}-[hash].js` + } + } + + return 'js/[name]-[hash].js' + }, + }, + }, + }, })