feat: ts定义

This commit is contained in:
neo 2024-12-14 21:11:25 +08:00
parent 27cc7c4d21
commit f38a1a806e
5 changed files with 16 additions and 4 deletions

View File

@ -72,7 +72,7 @@ const AppDetail = ({}) => {
const getCaskDetail = id => { const getCaskDetail = id => {
fetch( fetch(
'http://localhost:8000/homebrew/cask-detail?' + AVALON_SERVER + '/homebrew/cask-detail?' +
queryString.stringify({ queryString.stringify({
id, id,
}), }),
@ -92,7 +92,7 @@ const AppDetail = ({}) => {
const getFormulaDetail = id => { const getFormulaDetail = id => {
fetch( fetch(
'http://localhost:8000/homebrew/formula-detail?' + AVALON_SERVER + '/homebrew/formula-detail?' +
queryString.stringify({ queryString.stringify({
id, id,
}), }),

View File

@ -47,7 +47,7 @@ const CaskAndFormula = ({}) => {
const getCaskList = () => { const getCaskList = () => {
fetch( fetch(
'http://localhost:8000/homebrew/cask-list?' + AVALON_SERVER + '/homebrew/cask-list?' +
queryString.stringify(listParams), queryString.stringify(listParams),
) )
.then(response => response.json()) .then(response => response.json())
@ -60,7 +60,7 @@ const CaskAndFormula = ({}) => {
const getFormula = () => { const getFormula = () => {
fetch( fetch(
'http://localhost:8000/homebrew/formula-list?' + AVALON_SERVER + '/homebrew/formula-list?' +
queryString.stringify(listParams), queryString.stringify(listParams),
) )
.then(response => response.json()) .then(response => response.json())

View File

@ -4,6 +4,9 @@ export default defineConfig({
title: 'Homebrew 中文网', title: 'Homebrew 中文网',
mode: 'site', mode: 'site',
logo: '/images/homebrew-256x256.png', logo: '/images/homebrew-256x256.png',
define: {
'AVALON_SERVER': process.env.NODE_ENV === 'production' ? 'https://avalon.idayer.com' : 'http://localhost:8000',
},
favicon: '/favicon.ico', favicon: '/favicon.ico',
locales: [['zh-CN', '中文']], locales: [['zh-CN', '中文']],
metas: [], metas: [],

View File

@ -15,6 +15,7 @@
}, },
"allowSyntheticDefaultImports": true "allowSyntheticDefaultImports": true
}, },
"include": ["./global.d.ts"],
"exclude": [ "exclude": [
"node_modules", "node_modules",
"lib", "lib",

8
typings.d.ts vendored
View File

@ -1,2 +1,10 @@
declare module '*.css'; declare module '*.css';
declare module '*.less'; declare module '*.less';
declare var AVALON_SERVER: string
declare global {
var AVALON_SERVER: string
}
export {}