This commit is contained in:
2023-06-02 23:53:07 +08:00
parent afb2e49345
commit 4dedacf449
31 changed files with 1368 additions and 1236 deletions

View File

@@ -4,4 +4,4 @@ indent_size = 2
end_of_line = lf end_of_line = lf
trim_trailing_whitespace = true trim_trailing_whitespace = true
insert_final_newline = true insert_final_newline = true
max_line_length = 100 max_line_length = 200

View File

@@ -4,17 +4,17 @@ module.exports = {
node: true, node: true,
}, },
extends: [ extends: [
'plugin:vue/vue3-essential',
'@vue/airbnb',
'@vue/typescript/recommended', '@vue/typescript/recommended',
'plugin:vue/vue3-essential',
'prettier',
'@vue/eslint-config-typescript'
], ],
parserOptions: { parserOptions: {
ecmaVersion: 2020, ecmaVersion: 'latest',
}, },
rules: { rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'import/no-extraneous-dependencies': ['error', { devDependencies: true }], "vue/component-name-in-template-casing": ["error", "PascalCase"],
'linebreak-style': ['off', 'windows'],
}, },
}; };

5
.prettierrc.json Normal file
View File

@@ -0,0 +1,5 @@
{
"tabWidth": 2,
"semi": false,
"singleQuote": true
}

View File

@@ -8,13 +8,15 @@
"lint": "vue-cli-service lint" "lint": "vue-cli-service lint"
}, },
"dependencies": { "dependencies": {
"@vueuse/core": "^10.1.0",
"core-js": "^3.8.3", "core-js": "^3.8.3",
"register-service-worker": "^1.7.2",
"vue": "^3.2.13", "vue": "^3.2.13",
"vue-router": "^4.0.3", "vue-router": "^4.0.3",
"vue-turnstile": "^1.0.0",
"vuex": "^4.0.0" "vuex": "^4.0.0"
}, },
"devDependencies": { "devDependencies": {
"@babel/eslint-parser": "^7.21.3",
"@typescript-eslint/eslint-plugin": "^5.4.0", "@typescript-eslint/eslint-plugin": "^5.4.0",
"@typescript-eslint/parser": "^5.4.0", "@typescript-eslint/parser": "^5.4.0",
"@vue/cli-plugin-babel": "~5.0.0", "@vue/cli-plugin-babel": "~5.0.0",
@@ -26,12 +28,16 @@
"@vue/cli-service": "~5.0.0", "@vue/cli-service": "~5.0.0",
"@vue/eslint-config-airbnb": "^6.0.0", "@vue/eslint-config-airbnb": "^6.0.0",
"@vue/eslint-config-typescript": "^9.1.0", "@vue/eslint-config-typescript": "^9.1.0",
"eslint": "^7.32.0", "eslint": "^8.39.0",
"eslint-config-prettier": "^8.8.0",
"eslint-loader": "^4.0.2",
"eslint-plugin-import": "^2.25.3", "eslint-plugin-import": "^2.25.3",
"eslint-plugin-vue": "^8.0.3", "eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-vue": "^9.11.0",
"eslint-plugin-vuejs-accessibility": "^1.1.0", "eslint-plugin-vuejs-accessibility": "^1.1.0",
"lint-staged": "^11.1.2", "lint-staged": "^11.1.2",
"naive-ui": "^2.34.3", "naive-ui": "^2.34.3",
"prettier": "^2.8.8",
"stylus": "^0.55.0", "stylus": "^0.55.0",
"stylus-loader": "^6.1.0", "stylus-loader": "^6.1.0",
"typescript": "~4.5.5" "typescript": "~4.5.5"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 799 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

View File

@@ -1,3 +0,0 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M8.00251 14.9297L0 1.07422H6.14651L8.00251 4.27503L9.84583 1.07422H16L8.00251 14.9297Z" fill="black"/>
</svg>

Before

Width:  |  Height:  |  Size: 215 B

View File

@@ -1,15 +1,18 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang=""> <html lang="zh-Hans">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0"> <meta name="viewport" content="width=device-width,initial-scale=1.0" />
<link rel="icon" href="<%= BASE_URL %>favicon.ico"> <link rel="icon" href="<%= BASE_URL %>favicon.ico" />
<title><%= htmlWebpackPlugin.options.title %></title> <title><%= htmlWebpackPlugin.options.title %></title>
</head> </head>
<body> <body>
<noscript> <noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong> <strong
>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work
properly without JavaScript enabled. Please enable it to continue.
</strong>
</noscript> </noscript>
<div id="app"></div> <div id="app"></div>
<!-- built files will be auto injected --> <!-- built files will be auto injected -->

View File

@@ -1,8 +1,4 @@
<template> <template>
<nav>
<router-link to="/">Home</router-link> |
<router-link to="/about">About</router-link>
</nav>
<router-view/> <router-view/>
</template> </template>

20
src/api/account.ts Normal file
View 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
View File

@@ -0,0 +1,5 @@
export interface APIRoot<T> {
code: number;
message: string;
data: T;
}

13
src/api/query.ts Normal file
View 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>;
}

View File

@@ -2,13 +2,15 @@
<div class="hello"> <div class="hello">
<h1>{{ msg }}</h1> <h1>{{ msg }}</h1>
<p> <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 check out the
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>. <a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
</p> </p>
<h3>Installed CLI Plugins</h3> <h3>Installed CLI Plugins</h3>
<ul> <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-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-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> <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> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent } from 'vue'; import { defineComponent } from 'vue'
export default defineComponent({ export default defineComponent({
name: 'HelloWorld', name: 'HelloWorld',
props: { props: {
msg: String, msg: String,
}, },
}); })
</script> </script>
<!-- Add "scoped" attribute to limit CSS to this component only --> <!-- Add "scoped" attribute to limit CSS to this component only -->

3
src/data/constants.ts Normal file
View 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;

View File

@@ -1,18 +1,18 @@
<template> <template>
<div class="home"> <div class="home">
<img alt="Vue logo" src="../assets/logo.png"> <img alt="Vue logo" src="../assets/logo.png" />
<HelloWorld msg="Welcome to Your Vue.js + TypeScript App" /> <HelloWorld msg="Welcome to Your Vue.js + TypeScript App" />
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent } from 'vue'; import { defineComponent } from 'vue'
import HelloWorld from '@/components/HelloWorld.vue'; // @ is an alias to /src import HelloWorld from '@/components/HelloWorld.vue' // @ is an alias to /src
export default defineComponent({ export default defineComponent({
name: 'HomeView', name: 'HomeView',
components: { components: {
HelloWorld, HelloWorld,
}, },
}); })
</script> </script>

View File

@@ -1,9 +1,13 @@
<template> <template>
<n-button> <div style="display: flex;justify-content: center;">
Hello <div>
</n-button> <NText strong tag="h1">
vtsuru
</NText>
</div>
</div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { NButton } from 'naive-ui'; import { NButton, NText } from 'naive-ui'
</script> </script>

View File

@@ -13,7 +13,7 @@
"sourceMap": true, "sourceMap": true,
"baseUrl": ".", "baseUrl": ".",
"types": [ "types": [
"webpack-env" "webpack-env",
], ],
"paths": { "paths": {
"@/*": [ "@/*": [

2478
yarn.lock

File diff suppressed because it is too large Load Diff