This commit is contained in:
2026-03-30 11:07:54 +08:00
parent 47c9f98f8f
commit c8a9ef1dae
10 changed files with 64 additions and 19 deletions

View File

@@ -1 +1 @@
VITE_API_BASE=http://localhost:5162
VITE_API_BASE=http://localhost:5002

2
env/.env.production vendored
View File

@@ -1 +1 @@
VITE_API_BASE=https://api.stopshopping.bjbj.me
VITE_API_BASE=https://adminapi.stopshopping.bjbj.me

3
package-lock.json generated
View File

@@ -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": {

View File

@@ -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",

21
rollup-plugin-robots.ts Normal file
View File

@@ -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);
});
}
},
};
}

View File

@@ -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,

View File

@@ -14,6 +14,14 @@ export const signIn = async (params: M.SignInParams): Promise<M.SignInResponse>
return signInResult
}
export const refreshToken = async (): Promise<M.AccessTokenResponse> => {
return await AxiosHelper.getInstance().post('/admin/refreshtoken')
}
export const signOut = async (): Promise<M.ApiResponseMessage> => {
return await AxiosHelper.getInstance().post('/admin/signout')
}
//common
export const upload = async (params: M.UploadParams): Promise<M.UploadResponse> => {
return await AxiosHelper.getInstance().postFormData('/common/upload', params)
@@ -29,14 +37,6 @@ export const csrfToken = async (): Promise<M.AntiForgeryTokenResponse> => {
return csrfResult
}
export const refreshToken = async (): Promise<M.AccessTokenResponse> => {
return await AxiosHelper.getInstance().post('/common/refreshtoken')
}
export const signOut = async (): Promise<M.ApiResponseMessage> => {
return await AxiosHelper.getInstance().post('/common/signout')
}
//category
export const getCategoryTree = async (): Promise<M.CategoryListResponse> => {
return await AxiosHelper.getInstance().get('/category/list')

View File

@@ -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]

View File

@@ -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 = {

View File

@@ -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'
},
},
},
},
})