mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-07 02:46:55 +08:00
nothing
This commit is contained in:
@@ -1,8 +1,4 @@
|
||||
<template>
|
||||
<nav>
|
||||
<router-link to="/">Home</router-link> |
|
||||
<router-link to="/about">About</router-link>
|
||||
</nav>
|
||||
<router-view/>
|
||||
</template>
|
||||
|
||||
|
||||
20
src/api/account.ts
Normal file
20
src/api/account.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import QueryAPI from '@/api/query'
|
||||
import { BASE_API } from '@/data/constants'
|
||||
import { APIRoot } from './api-models'
|
||||
|
||||
const ACCOUNT_URL = `${BASE_API}account/`
|
||||
|
||||
export async function Register(name: string, email: string, password: string): Promise<APIRoot<string>> {
|
||||
return QueryAPI<string>(`${ACCOUNT_URL}register`, {
|
||||
name,
|
||||
email,
|
||||
password,
|
||||
})
|
||||
}
|
||||
|
||||
export async function Login(nameOrEmail: string, password: string): Promise<APIRoot<string>> {
|
||||
return QueryAPI<string>(`${ACCOUNT_URL}login`, {
|
||||
nameOrEmail,
|
||||
password,
|
||||
})
|
||||
}
|
||||
5
src/api/api-models.ts
Normal file
5
src/api/api-models.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export interface APIRoot<T> {
|
||||
code: number;
|
||||
message: string;
|
||||
data: T;
|
||||
}
|
||||
13
src/api/query.ts
Normal file
13
src/api/query.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
/* eslint-disable indent */
|
||||
import { APIRoot } from './api-models';
|
||||
|
||||
export default async function QueryAPI<T>(url: string, body?: unknown): Promise<APIRoot<T>> {
|
||||
const data = await fetch(url,{
|
||||
method: 'post',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(body)
|
||||
}); // 不处理异常, 在页面处理
|
||||
return await data.json() as APIRoot<T>;
|
||||
}
|
||||
@@ -2,13 +2,15 @@
|
||||
<div class="hello">
|
||||
<h1>{{ msg }}</h1>
|
||||
<p>
|
||||
For a guide and recipes on how to configure / customize this project,<br>
|
||||
For a guide and recipes on how to configure / customize this project,<br />
|
||||
check out the
|
||||
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
|
||||
</p>
|
||||
<h3>Installed CLI Plugins</h3>
|
||||
<ul>
|
||||
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
|
||||
<li>
|
||||
<a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a>
|
||||
</li>
|
||||
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-pwa" target="_blank" rel="noopener">pwa</a></li>
|
||||
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-router" target="_blank" rel="noopener">router</a></li>
|
||||
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-vuex" target="_blank" rel="noopener">vuex</a></li>
|
||||
@@ -35,14 +37,14 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { defineComponent } from 'vue'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'HelloWorld',
|
||||
props: {
|
||||
msg: String,
|
||||
},
|
||||
});
|
||||
})
|
||||
</script>
|
||||
|
||||
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
||||
|
||||
3
src/data/constants.ts
Normal file
3
src/data/constants.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
const debugAPI = `${process.env.VITE_debugAPI}/api/`
|
||||
const releseAPI = `${document.location.protocol}//api.vtsuru.live/api/`;
|
||||
export const BASE_API = process.env.NODE_ENV === 'development' ? debugAPI : releseAPI;
|
||||
@@ -1,18 +1,18 @@
|
||||
<template>
|
||||
<div class="home">
|
||||
<img alt="Vue logo" src="../assets/logo.png">
|
||||
<HelloWorld msg="Welcome to Your Vue.js + TypeScript App"/>
|
||||
<img alt="Vue logo" src="../assets/logo.png" />
|
||||
<HelloWorld msg="Welcome to Your Vue.js + TypeScript App" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import HelloWorld from '@/components/HelloWorld.vue'; // @ is an alias to /src
|
||||
import { defineComponent } from 'vue'
|
||||
import HelloWorld from '@/components/HelloWorld.vue' // @ is an alias to /src
|
||||
|
||||
export default defineComponent({
|
||||
name: 'HomeView',
|
||||
components: {
|
||||
HelloWorld,
|
||||
},
|
||||
});
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
<template>
|
||||
<n-button>
|
||||
Hello
|
||||
</n-button>
|
||||
<div style="display: flex;justify-content: center;">
|
||||
<div>
|
||||
<NText strong tag="h1">
|
||||
vtsuru
|
||||
</NText>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { NButton } from 'naive-ui';
|
||||
import { NButton, NText } from 'naive-ui'
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user