feat: 增加meta标签、优化API接口、调整Nuxt配置及页面结构
This commit is contained in:
parent
9f6f58cad6
commit
c3004d0780
|
@ -7,7 +7,7 @@ import (
|
|||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
// ListFeature 获取要素列表
|
||||
// GetFeatures 获取要素列表
|
||||
// @Summary 获取要素列表
|
||||
// @Description 获取要素列表
|
||||
// @Tags feature
|
||||
|
@ -17,13 +17,24 @@ import (
|
|||
// @Param size query int false "每页数量"
|
||||
// @Success 200 {object} Pagination[FeaturePublic]
|
||||
// @Router /features [get]
|
||||
// GetFeatures 处理获取特征列表的请求
|
||||
func (a *API) GetFeatures(c echo.Context) error {
|
||||
var featureList model.FeatureList
|
||||
// 初始化特征列表请求参数,默认页码为1,每页大小为10
|
||||
var featureList = model.FeatureList{
|
||||
ListQuery: model.ListQuery{
|
||||
Page: 1,
|
||||
Size: 10,
|
||||
},
|
||||
}
|
||||
// 绑定请求参数并验证
|
||||
if err := BindAndValidate(c, &featureList); err != nil {
|
||||
// 如果绑定或验证失败,返回400错误
|
||||
return Error(c, http.StatusBadRequest, err.Error())
|
||||
}
|
||||
// 调用存储层获取特征列表和总数
|
||||
features, total, err := a.store.ListFeature(&featureList)
|
||||
if err != nil {
|
||||
// 如果存储层操作失败,返回500错误
|
||||
return Error(c, http.StatusInternalServerError, err.Error())
|
||||
}
|
||||
// 将 features 转换为 FeaturePublic
|
||||
|
@ -34,7 +45,7 @@ func (a *API) GetFeatures(c echo.Context) error {
|
|||
return Paginate(c, featurePublics, featureList.Page, featureList.Size, total, "获取要素列表成功")
|
||||
}
|
||||
|
||||
// CreateFeature 创建要素
|
||||
// PostFeature 创建要素
|
||||
// @Summary 创建要素
|
||||
// @Description 创建要素
|
||||
// @Tags feature
|
||||
|
@ -68,7 +79,7 @@ func (a *API) GetFeatureByID(c echo.Context) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// UpdateFeature 更新要素
|
||||
// PutFeature 更新要素
|
||||
// @Summary 更新要素
|
||||
// @Description 更新要素
|
||||
// @Tags feature
|
||||
|
|
|
@ -2,6 +2,7 @@ package bin
|
|||
|
||||
import (
|
||||
"context"
|
||||
"github.com/pkg/errors"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"os"
|
||||
|
@ -54,7 +55,7 @@ var rootCmd = &cobra.Command{
|
|||
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
||||
|
||||
if err := s.Start(ctx); err != nil {
|
||||
if err != http.ErrServerClosed {
|
||||
if !errors.Is(err, http.ErrServerClosed) {
|
||||
slog.Error("server start failed", "err", err)
|
||||
cancel()
|
||||
}
|
||||
|
|
16
web/app.vue
16
web/app.vue
|
@ -1,5 +1,21 @@
|
|||
<script setup lang="ts">
|
||||
useHead({
|
||||
meta: [
|
||||
{
|
||||
name: "description",
|
||||
content: "用于地图相关数据管理",
|
||||
},
|
||||
{
|
||||
name: "keywords",
|
||||
content: "maptile.map.geojson",
|
||||
},
|
||||
],
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NuxtLayout>
|
||||
<NuxtLoadingIndicator />
|
||||
<NuxtPage />
|
||||
</NuxtLayout>
|
||||
</template>
|
||||
|
|
|
@ -5,23 +5,28 @@ export default defineNuxtConfig({
|
|||
devServer: {
|
||||
port: 8888,
|
||||
},
|
||||
ssr: false,
|
||||
nitro: {
|
||||
routeRules: {
|
||||
"/api/v1": {proxy: 'http://localhost:8080'}
|
||||
}
|
||||
"/api/v1/**": {
|
||||
proxy: "http://localhost:8080/api/v1/**",
|
||||
},
|
||||
},
|
||||
},
|
||||
app: {
|
||||
head: {
|
||||
title: "Nuxt.js TypeScript TailwindCSS",
|
||||
},
|
||||
rootAttrs: {
|
||||
class: 'main',
|
||||
}
|
||||
class: "main",
|
||||
},
|
||||
components: [{
|
||||
path: '~/components',
|
||||
pathPrefix: false
|
||||
}],
|
||||
},
|
||||
components: [
|
||||
{
|
||||
path: "~/components",
|
||||
pathPrefix: false,
|
||||
},
|
||||
],
|
||||
css: ["@/assets/css/main.css"],
|
||||
modules: ['@nuxtjs/tailwindcss', "@nuxt/icon", "@vueuse/nuxt"],
|
||||
modules: ["@nuxtjs/tailwindcss", "@nuxt/icon", "@vueuse/nuxt"],
|
||||
});
|
File diff suppressed because it is too large
Load Diff
|
@ -10,7 +10,10 @@
|
|||
"postinstall": "nuxt prepare"
|
||||
},
|
||||
"dependencies": {
|
||||
"@mapbox/mapbox-gl-draw": "^1.5.0",
|
||||
"@turf/turf": "^7.2.0",
|
||||
"@vueuse/nuxt": "^12.7.0",
|
||||
"maplibre-gl": "^5.1.1",
|
||||
"nuxt": "^3.15.4",
|
||||
"vue": "latest",
|
||||
"vue-router": "latest"
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
<script setup lang="ts">
|
||||
definePageMeta({
|
||||
layout: 'default'
|
||||
layout: "default",
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="h-[2000px] bg-red-200">hello world</div>
|
||||
<div class="h-[600px] bg-red-200">
|
||||
<Map />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="less" scoped></style>
|
Loading…
Reference in New Issue