diff --git a/.gitignore b/.gitignore index a19f004..3caed4b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,21 @@ -# ---> Vue -# gitignore template for Vue.js projects -# -# Recommended template: Node.gitignore - -# TODO: where does this rule come from? -docs/_book - -# TODO: where does this rule come from? -test/ +.DS_Store +node_modules/ +dist/ +admindb/ +npm-debug.log* +yarn-debug.log* +yarn-error.log* +/test/unit/coverage/ +/test/e2e/reports/ +selenium-debug.log +# Editor directories and files +.idea +.vscode +*.suo +*.ntvs* +*.njsproj +*.sln +package-lock.json +.env.production.local +.vs/ diff --git a/README.md b/README.md index a5b8285..d8f38d0 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ # go_fish_web -钓鱼Web端 \ No newline at end of file +钓鱼Web端 + +npm install + +npm run \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..8388c4b --- /dev/null +++ b/index.html @@ -0,0 +1,13 @@ + + + + + + + Vite + Vue + + +
+ + + diff --git a/package.json b/package.json new file mode 100644 index 0000000..c688bb9 --- /dev/null +++ b/package.json @@ -0,0 +1,20 @@ +{ + "name": "fish_game", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build", + "preview": "vite preview" + }, + "dependencies": { + "axios": "^1.8.4", + "vue": "^3.5.13", + "vue-router": "^4.5.0" + }, + "devDependencies": { + "@vitejs/plugin-vue": "^5.2.1", + "vite": "^6.2.0" + } +} diff --git a/public/vite.svg b/public/vite.svg new file mode 100644 index 0000000..e7b8dfb --- /dev/null +++ b/public/vite.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/App.vue b/src/App.vue new file mode 100644 index 0000000..98240ae --- /dev/null +++ b/src/App.vue @@ -0,0 +1,3 @@ + diff --git a/src/api/login/login.js b/src/api/login/login.js new file mode 100644 index 0000000..6391df9 --- /dev/null +++ b/src/api/login/login.js @@ -0,0 +1,15 @@ +/* + * @Descripttion: + * @version: 1.0.0 + * @Author: LyMy + * @Date: 2025-04-11 15:56:41 + * @LastEditors: LyMy + * @LastEditTime: 2025-04-11 15:58:45 + * @FilePath: \fish_game\src\api\login\login.js + */ +import request from '@/utils/request' + +// 登录接口 +export function login(data) { + return request.post('/Account/login', data) +} \ No newline at end of file diff --git a/src/assets/vue.svg b/src/assets/vue.svg new file mode 100644 index 0000000..770e9d3 --- /dev/null +++ b/src/assets/vue.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/HelloWorld.vue b/src/components/HelloWorld.vue new file mode 100644 index 0000000..546ebbc --- /dev/null +++ b/src/components/HelloWorld.vue @@ -0,0 +1,43 @@ + + + + + diff --git a/src/main.js b/src/main.js new file mode 100644 index 0000000..3e79677 --- /dev/null +++ b/src/main.js @@ -0,0 +1,5 @@ +import { createApp } from 'vue' +import App from './App.vue' +import router from './router' + +createApp(App).use(router).mount('#app') diff --git a/src/pages/equipments/Equipments.vue b/src/pages/equipments/Equipments.vue new file mode 100644 index 0000000..c998c8a --- /dev/null +++ b/src/pages/equipments/Equipments.vue @@ -0,0 +1,15 @@ + + + + + diff --git a/src/pages/fishbaskets/Fishbaskets.vue b/src/pages/fishbaskets/Fishbaskets.vue new file mode 100644 index 0000000..11698a0 --- /dev/null +++ b/src/pages/fishbaskets/Fishbaskets.vue @@ -0,0 +1,24 @@ + + + + + + diff --git a/src/pages/fishing/Fishing.vue b/src/pages/fishing/Fishing.vue new file mode 100644 index 0000000..9c5849f --- /dev/null +++ b/src/pages/fishing/Fishing.vue @@ -0,0 +1,24 @@ + + + + + + diff --git a/src/pages/login/Login.vue b/src/pages/login/Login.vue new file mode 100644 index 0000000..b59bfa7 --- /dev/null +++ b/src/pages/login/Login.vue @@ -0,0 +1,62 @@ + + + + + + + diff --git a/src/pages/main/Home.vue b/src/pages/main/Home.vue new file mode 100644 index 0000000..b88afdc --- /dev/null +++ b/src/pages/main/Home.vue @@ -0,0 +1,50 @@ + + + + + diff --git a/src/pages/market/Market.vue b/src/pages/market/Market.vue new file mode 100644 index 0000000..058389e --- /dev/null +++ b/src/pages/market/Market.vue @@ -0,0 +1,24 @@ + + + + + + diff --git a/src/pages/ranking/Ranking.vue b/src/pages/ranking/Ranking.vue new file mode 100644 index 0000000..36d960e --- /dev/null +++ b/src/pages/ranking/Ranking.vue @@ -0,0 +1,24 @@ + + + + + + diff --git a/src/pages/shop/Shop.vue b/src/pages/shop/Shop.vue new file mode 100644 index 0000000..fcfa6da --- /dev/null +++ b/src/pages/shop/Shop.vue @@ -0,0 +1,24 @@ + + + + + + diff --git a/src/router.js b/src/router.js new file mode 100644 index 0000000..afcd915 --- /dev/null +++ b/src/router.js @@ -0,0 +1,74 @@ +import { createRouter, createWebHistory } from 'vue-router' +import Login from './pages/login/Login.vue' +import Home from './pages/main/Home.vue' +import Equipments from '@/pages/equipments/Equipments.vue' +import Fishing from '@/pages/fishing/Fishing.vue' +import Fishbaskets from '@/pages/fishbaskets/Fishbaskets.vue' +import Shop from '@/pages/shop/Shop.vue' +import Market from '@/pages/market/Market.vue' +import Ranking from '@/pages/ranking/Ranking.vue' + + +const routes = [ + { + path: '/', + name: 'Home', + component: Home, + meta: { requiresAuth: true } + }, + { + path: '/login', + name: 'Login', + component: Login + }, + { + path: '/equipments', + name: 'equipments', + component: Equipments + }, + { + path: '/fishing', + name: 'fishing', + component: Fishing + }, + { + path: '/fishbaskets', + name: 'fishbaskets', + component: Fishbaskets + }, + { + path: '/shop', + name: 'shop', + component: Shop + }, + { + path: '/market', + name: 'market', + component: Market + }, + { + path: '/ranking', + name: 'ranking', + component: Ranking + }, +] + +const router = createRouter({ + history: createWebHistory(), + routes +}) + +router.beforeEach((to, from, next) => { + const token = localStorage.getItem('token') + if (to.meta.requiresAuth && !token) { + // 如果访问需要登录的页面且没有 token,跳转到登录页面 + next('/login') + } else if (to.name === 'Login' && token) { + // 如果已经登录,且访问的是登录页面,跳转到首页 + next('/') + } else { + next() // 继续导航 + } +}) + +export default router diff --git a/src/style.css b/src/style.css new file mode 100644 index 0000000..f691315 --- /dev/null +++ b/src/style.css @@ -0,0 +1,79 @@ +:root { + font-family: system-ui, Avenir, Helvetica, Arial, sans-serif; + line-height: 1.5; + font-weight: 400; + + color-scheme: light dark; + color: rgba(255, 255, 255, 0.87); + background-color: #242424; + + font-synthesis: none; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +a { + font-weight: 500; + color: #646cff; + text-decoration: inherit; +} +a:hover { + color: #535bf2; +} + +body { + margin: 0; + display: flex; + place-items: center; + min-width: 320px; + min-height: 100vh; +} + +h1 { + font-size: 3.2em; + line-height: 1.1; +} + +button { + border-radius: 8px; + border: 1px solid transparent; + padding: 0.6em 1.2em; + font-size: 1em; + font-weight: 500; + font-family: inherit; + background-color: #1a1a1a; + cursor: pointer; + transition: border-color 0.25s; +} +button:hover { + border-color: #646cff; +} +button:focus, +button:focus-visible { + outline: 4px auto -webkit-focus-ring-color; +} + +.card { + padding: 2em; +} + +#app { + max-width: 1280px; + margin: 0 auto; + padding: 2rem; + text-align: center; +} + +@media (prefers-color-scheme: light) { + :root { + color: #213547; + background-color: #ffffff; + } + a:hover { + color: #747bff; + } + button { + background-color: #f9f9f9; + } +} diff --git a/src/utils/request.js b/src/utils/request.js new file mode 100644 index 0000000..7192f87 --- /dev/null +++ b/src/utils/request.js @@ -0,0 +1,41 @@ +/* + * @Descripttion: + * @version: 1.0.0 + * @Author: LyMy + * @Date: 2025-04-11 15:56:12 + * @LastEditors: LyMy + * @LastEditTime: 2025-04-11 16:19:14 + * @FilePath: \fish_game\src\utils\request.js + */ +import axios from 'axios' + +// 创建 axios 实例 +const request = axios.create({ + baseURL: 'http://49.235.165.171:31001', // 你的基础地址 + timeout: 5000 +}) + +request.defaults.headers['Content-Type'] = 'application/json' + +// 请求拦截器 +request.interceptors.request.use( + config => { + const token = localStorage.getItem('token') + if (token) { + config.headers.Authorization = `Bearer ${token}` + } + return config + }, + error => Promise.reject(error) +) + +// 响应拦截器 +request.interceptors.response.use( + response => response.data, + error => { + console.error('接口请求错误:', error) + return Promise.reject(error) + } +) + +export default request diff --git a/vite.config.js b/vite.config.js new file mode 100644 index 0000000..a28e1b7 --- /dev/null +++ b/vite.config.js @@ -0,0 +1,21 @@ +/* + * @Descripttion: + * @version: 1.0.0 + * @Author: LyMy + * @Date: 2025-04-11 15:43:49 + * @LastEditors: LyMy + * @LastEditTime: 2025-04-11 16:07:34 + * @FilePath: \fish_game\vite.config.js + */ +import { defineConfig } from 'vite' +import vue from '@vitejs/plugin-vue' +import path from 'path' // 需要导入 path 模块 + +export default defineConfig({ + plugins: [vue()], + resolve: { + alias: { + '@': path.resolve(__dirname, 'src') // 加这行 + } + } +})