feat: 添加 Cloudflare Workers 支持

- 在 package.json 中添加 @cloudflare/vite-plugin 依赖
- 新增 server/index.ts 文件实现 Cloudflare Workers 逻辑
- 更新 vite.config.ts 配置,添加 cloudflare 插件
- 新增 tsconfig.worker.json 配置 TypeScript 编译选项
- 更新 App.vue,添加从 API 获取名称的功能
This commit is contained in:
严浩
2025-09-09 12:28:27 +08:00
parent 07e8ca247f
commit 7c92f4496e
10 changed files with 7579 additions and 3 deletions

View File

@@ -1,4 +1,14 @@
<script setup lang="ts"></script>
<script setup lang="ts">
import { ref } from 'vue'
const name = ref('Unknown')
const getName = async () => {
const res = await fetch('/api/')
const data = await res.json()
name.value = data.name
}
</script>
<template>
<h1>You did it!</h1>
@@ -6,6 +16,7 @@
Visit <a href="https://vuejs.org/" target="_blank" rel="noopener">vuejs.org</a> to read the
documentation
</p>
<button class="green" @click="getName" aria-label="get name">Name from API is: {{ name }}</button>
</template>
<style scoped></style>