Browse Source

feat: 初始化仓库及页面路由

master
wally 3 years ago
commit
fc3b55cde6
  1. 8
      .editorconfig
  2. 1
      .env.development
  3. 1
      .env.production
  4. 1
      .env.test
  5. 10
      .eslintignore
  6. 55
      .eslintrc.js
  7. 8
      .gitignore
  8. 4
      .husky/pre-commit
  9. 1
      .npmrc
  10. 13
      .prettierrc
  11. 7
      README.md
  12. 19
      alias.config.js
  13. 1
      commitlint.config.js
  14. 14
      index.html
  15. 16248
      package-lock.json
  16. 72
      package.json
  17. BIN
      public/favicon.ico
  18. 96
      src/App.vue
  19. 8
      src/apis/index.js
  20. BIN
      src/assets/arrow-bottom.png
  21. BIN
      src/assets/bg.png
  22. BIN
      src/assets/border-1.png
  23. BIN
      src/assets/border-2.png
  24. BIN
      src/assets/border-3.png
  25. BIN
      src/assets/border-5.png
  26. BIN
      src/assets/border-main.png
  27. BIN
      src/assets/border-s-1.png
  28. BIN
      src/assets/border-s-2.png
  29. BIN
      src/assets/btn-border.png
  30. BIN
      src/assets/circle-blue.png
  31. BIN
      src/assets/circle-green.png
  32. BIN
      src/assets/circle-red.png
  33. BIN
      src/assets/circle-yellow.png
  34. BIN
      src/assets/farm-top.png
  35. BIN
      src/assets/hot.png
  36. BIN
      src/assets/icon-location.png
  37. BIN
      src/assets/icon-phone.png
  38. BIN
      src/assets/icon-play.png
  39. BIN
      src/assets/logo.png
  40. BIN
      src/assets/modal-bg.png
  41. BIN
      src/assets/new.png
  42. BIN
      src/assets/top.png
  43. 8
      src/main.js
  44. 20
      src/routers/index.js
  45. 21
      src/store/index.js
  46. 25
      src/utils/axios.js
  47. 6
      src/utils/time.js
  48. 11
      src/views/GameList.vue
  49. 11
      src/views/Index.vue
  50. 11
      src/views/TrainSiteList.vue
  51. 37
      vite.config.js
  52. 5132
      yarn.lock

8
.editorconfig

@ -0,0 +1,8 @@
[*.{js,jsx,ts,tsx,vue}]
indent_style = space
indent_size = 2
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 140
root = true

1
.env.development

@ -0,0 +1 @@
VITE_API_URL=http://localhost:4001

1
.env.production

@ -0,0 +1 @@
VITE_API_URL=https://www.tall.wiki

1
.env.test

@ -0,0 +1 @@
VITE_API_URL=https://test.tall.wiki

10
.eslintignore

@ -0,0 +1,10 @@
node_modules
dist/
test
build/
babel.config.js
package.json
postcss.config.js
.eslintrc.js
vite.config.js
*/Middle.vue

55
.eslintrc.js

@ -0,0 +1,55 @@
module.exports = {
env: {
browser: true,
es2021: true,
},
extends: ['plugin:vue/essential', 'airbnb-base', 'plugin:prettier/recommended'],
parserOptions: {
ecmaVersion: 12,
sourceType: 'module',
},
plugins: ['vue'],
rules: {
'import/no-unresolved': 0,
'import/extensions': 0,
'no-plusplus': 0,
'no-use-before-define': [
'error',
{
functions: false,
classes: true,
variables: true,
},
],
'consistent-return': 0,
'vue/html-self-closing': 'off',
'no-unused-expressions': 'off',
'vue/no-mutating-props': 'off',
'vue/no-multiple-template-root': 'off',
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-param-reassign': 'off',
'max-len': [
'error',
{
code: 140,
tabWidth: 2,
},
],
'object-curly-newline': ['error', { multiline: true }],
'arrow-parens': ['error', 'as-needed'],
'linebreak-style': 'off',
'vue/attributes-order': 'off',
'vue/singleline-html-element-content-newline': 'off',
'vue/max-attributes-per-line': 'off',
'vue/multiline-html-element-content-newline': 'off',
'vue/html-indent': 'off',
'vue/html-closing-bracket-newline': [
'error',
{
singleline: 'never',
multiline: 'always',
},
],
},
};

8
.gitignore

@ -0,0 +1,8 @@
node_modules
.DS_Store
dist
dist-ssr
*.local
.eslintcache
.idea
.vscode

4
.husky/pre-commit

@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx lint-staged

1
.npmrc

@ -0,0 +1 @@
registry=https://registry.npm.taobao.org

13
.prettierrc

@ -0,0 +1,13 @@
{
"printWidth": 140,
"singleQuote": true,
"semi": true,
"trailingComma": "all",
"arrowParens": "avoid",
"tabWidth": 2,
"useTabs": false,
"bracketSpacing": true,
"jsxBracketSameLine": false,
"proseWrap": "always",
"endOfLine": "lf"
}

7
README.md

@ -0,0 +1,7 @@
# Vue 3 + Vite
This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
## Recommended IDE Setup
- [VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar)

19
alias.config.js

@ -0,0 +1,19 @@
const path = require('path');
const resolve = dir => path.join(__dirname, dir);
module.exports = {
resolve: {
alias: {
'~': __dirname,
'@': resolve('src'),
views: resolve('src/views'),
components: resolve('src/components'),
assets: resolve('src/assets'),
utils: resolve('src/utils'),
store: resolve('src/store'),
apis: resolve('src/apis'),
config: resolve('src/config'),
},
},
};

1
commitlint.config.js

@ -0,0 +1 @@
module.exports = {extends: ['@commitlint/config-angular']};

14
index.html

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>康复游戏</title>
<link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/normalize/8.0.1/normalize.min.css" />
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>

16248
package-lock.json

File diff suppressed because it is too large

72
package.json

@ -0,0 +1,72 @@
{
"name": "vue3-vite-template",
"version": "0.0.0",
"scripts": {
"dev": "vite --mode test",
"build": "vite build --mode production",
"serve": "vite preview",
"cz": "git add . && git cz",
"format": "prettier --write ./src",
"lint": "eslint ./src --ext .vue,.js,.ts",
"fix": "eslint --fix ./src --ext .vue,.js,.ts",
"prepare": "husky install"
},
"dependencies": {
"@vitejs/plugin-vue": "^1.9.3",
"axios": "^0.23.0",
"dayjs": "^1.10.7",
"echarts": "^5.2.2",
"echarts-gl": "^2.0.8",
"element-plus": "^1.1.0-beta.24",
"lodash": "^4.17.21",
"vite": "^2.6.4",
"vite-plugin-compression": "^0.3.5",
"vite-plugin-windicss": "^1.4.11",
"vue": "^3.2.16",
"vue-router": "^4.0.12",
"vuex": "^4.0.2",
"windicss": "^3.1.9"
},
"devDependencies": {
"@commitlint/cli": "^13.2.1",
"@commitlint/config-angular": "^13.2.0",
"commitizen": "^4.2.4",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^7.32.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-html": "^6.2.0",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-vue": "^7.19.1",
"husky": "^7.0.2",
"lint-staged": "^11.2.3",
"prettier": "^2.4.1",
"unplugin-vue-components": "^0.15.6",
"vite-plugin-linter": "^1.0.1",
"vite-plugin-pwa": "^0.11.6"
},
"browserslist": [
"Android >= 4",
"ios >= 8"
],
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"lint-staged": {
"src/**/*.{js,ts,jsx,json,css,vue}": [
"eslint --fix",
"git add"
],
"*.js": "eslint --cache --fix"
},
"husky": {
"hooks": {
"prepare-commit-msg": "exec < /dev/tty && git cz --hook || true",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
"pre-commit": "lint-staged"
}
}
}

BIN
public/favicon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

96
src/App.vue

@ -0,0 +1,96 @@
<template>
<div class="page">
<router-view></router-view>
</div>
</template>
<script setup>
import { onMounted, provide } from 'vue';
provide('scene', 'center');
function setRem(html) {
html.style.fontSize = `${html.clientWidth / 1920}px`;
}
onMounted(() => {
const html = document.documentElement;
setRem(html);
window.addEventListener(
'resize',
() => {
setRem(html);
},
false,
);
});
</script>
<style>
html,
body,
#app,
.page {
height: 100%;
}
* {
user-select: none;
}
html {
background-size: cover;
background: url('@/assets/bg.png') no-repeat fixed center center;
overflow: hidden;
}
.clear:after {
content: '';
display: block;
height: 0;
visibility: hidden;
clear: both;
}
.float-left {
float: left;
}
.float-right {
float: right;
}
.absolute {
position: absolute;
}
.fixed {
position: fixed;
}
.relative {
position: relative;
}
.flex {
display: flex;
}
.flex-1 {
flex: 1;
}
.items-center {
align-items: center;
}
.justify-center {
justify-content: center;
}
.m-t {
margin-top: 10rem;
}
.m-b {
margin-bottom: 10rem;
}
.p {
padding: 10rem;
}
.p-16 {
padding: 16rem;
}
.overflow-hidden {
overflow: hidden;
}
</style>

8
src/apis/index.js

@ -0,0 +1,8 @@
// noinspection SpellCheckingInspection
import http from 'utils/axios';
// 获取天气信息
// eslint-disable-next-line import/prefer-default-export
export const getWeather = () =>
http.get('https://devapi.qweather.com/v7/weather/now?key=9764d65c999349a9b42c42a8f1052a81&location=112.48699,37.94036&lang =zh');

BIN
src/assets/arrow-bottom.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 573 B

BIN
src/assets/bg.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

BIN
src/assets/border-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

BIN
src/assets/border-2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

BIN
src/assets/border-3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

BIN
src/assets/border-5.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

BIN
src/assets/border-main.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
src/assets/border-s-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

BIN
src/assets/border-s-2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

BIN
src/assets/btn-border.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
src/assets/circle-blue.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

BIN
src/assets/circle-green.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

BIN
src/assets/circle-red.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

BIN
src/assets/circle-yellow.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

BIN
src/assets/farm-top.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

BIN
src/assets/hot.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 832 B

BIN
src/assets/icon-location.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 737 B

BIN
src/assets/icon-phone.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
src/assets/icon-play.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 841 B

BIN
src/assets/logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

BIN
src/assets/modal-bg.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

BIN
src/assets/new.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 927 B

BIN
src/assets/top.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

8
src/main.js

@ -0,0 +1,8 @@
import { createApp } from 'vue';
import App from './App.vue';
import router from './routers/index';
import store from './store/index';
const app = createApp(App);
app.use(router).use(store).mount('#app');

20
src/routers/index.js

@ -0,0 +1,20 @@
import { createRouter, createWebHistory } from 'vue-router';
// 还有 createWebHashHistory 和 createMemoryHistory
export const routes = [
{ path: '/kangfu/game/start', name: 'Start', component: () => import('views/Index.vue') },
{ path: '/kangfu/game/start/train', name: 'Train', component: () => import('views/TrainSiteList.vue') },
{ path: '/kangfu/game/start/game', name: 'Game', component: () => import('views/GameList.vue') },
];
const router = createRouter({
history: createWebHistory(),
routes: [
{
path: '/',
redirect: '/kangfu/game/start',
},
].concat(routes),
});
export default router;

21
src/store/index.js

@ -0,0 +1,21 @@
import { createStore } from 'vuex';
export default createStore({
state: { modal: false, monitor: true },
getters: {},
mutations: {
/**
* 设置modal是否显示
* @param state
* @param {Boolean} display
*/
setModal(state, display) {
state.modal = display;
},
setMonitor(state, display) {
state.monitor = display;
},
},
actions: {},
});

25
src/utils/axios.js

@ -0,0 +1,25 @@
import Axios from 'axios';
const instance = Axios.create({ timeout: 20000 });
// request
instance.interceptors.request.use(
config => {
return config;
},
error => {
return Promise.reject(error);
},
);
// response
instance.interceptors.response.use(
response => {
return response.data;
},
error => {
return Promise.reject(error);
},
);
export default instance;

6
src/utils/time.js

@ -0,0 +1,6 @@
import dayjs from 'dayjs';
// require('dayjs/esm/locale/zh-cn');
dayjs.locale('zh-cn');
export default dayjs;

11
src/views/GameList.vue

@ -0,0 +1,11 @@
<template>
游戏列表选择
</template>
<script>
export default {
name: 'GameList',
};
</script>
<style scoped></style>

11
src/views/Index.vue

@ -0,0 +1,11 @@
<template>
入口页
</template>
<script>
export default {
name: 'Index',
};
</script>
<style scoped></style>

11
src/views/TrainSiteList.vue

@ -0,0 +1,11 @@
<template>
训练部位选择
</template>
<script>
export default {
name: 'TrainSite',
};
</script>
<style scoped></style>

37
vite.config.js

@ -0,0 +1,37 @@
import { defineConfig } from 'vite';
import path from 'path';
import vue from '@vitejs/plugin-vue';
import viteCompression from 'vite-plugin-compression';
import { VitePWA } from 'vite-plugin-pwa';
const resolve = dir => path.join(__dirname, dir);
// https://vitejs.dev/config/
export default defineConfig({
base: '/kangfu/game/start/',
plugins: [vue(), VitePWA(), viteCompression()],
resolve: {
alias: {
'~': __dirname,
'@': resolve('src'),
views: resolve('src/views'),
components: resolve('src/components'),
assets: resolve('src/assets'),
utils: resolve('src/utils'),
store: resolve('src/store'),
apis: resolve('src/apis'),
config: resolve('src/config'),
},
},
build: {
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes('node_modules')) {
return id.toString().split('node_modules/')[1].split('/')[0].toString();
}
},
},
},
},
});

5132
yarn.lock

File diff suppressed because it is too large
Loading…
Cancel
Save