zhangdechen %!s(int64=3) %!d(string=hai) anos
achega
7ccfd26e2b

+ 24 - 0
.gitignore

@@ -0,0 +1,24 @@
+# Logs
+logs
+*.log
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+pnpm-debug.log*
+lerna-debug.log*
+
+node_modules
+dist
+dist-ssr
+*.local
+
+# Editor directories and files
+.vscode/*
+!.vscode/extensions.json
+.idea
+.DS_Store
+*.suo
+*.ntvs*
+*.njsproj
+*.sln
+*.sw?

+ 3 - 0
.vscode/extensions.json

@@ -0,0 +1,3 @@
+{
+  "recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"]
+}

+ 18 - 0
README.md

@@ -0,0 +1,18 @@
+# Vue 3 + TypeScript + Vite
+
+This template should help get you started developing with Vue 3 and TypeScript 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
+
+- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
+
+## Type Support For `.vue` Imports in TS
+
+TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types.
+
+If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps:
+
+1. Disable the built-in TypeScript Extension
+   1. Run `Extensions: Show Built-in Extensions` from VSCode's command palette
+   2. Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)`
+2. Reload the VSCode window by running `Developer: Reload Window` from the command palette.

+ 13 - 0
index.html

@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="UTF-8" />
+    <link rel="icon" type="image/svg+xml" href="/vite.svg" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+    <title>Vite + Vue + TS</title>
+  </head>
+  <body>
+    <div id="app"></div>
+    <script type="module" src="/src/main.ts"></script>
+  </body>
+</html>

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 3496 - 0
package-lock.json


+ 29 - 0
package.json

@@ -0,0 +1,29 @@
+{
+  "name": "music-api",
+  "private": true,
+  "version": "0.0.0",
+  "type": "module",
+  "scripts": {
+    "dev": "vite",
+    "start": "vite",
+    "serve": "vite",
+    "build": "vue-tsc && vite build",
+    "preview": "vite preview"
+  },
+  "dependencies": {
+    "axios": "^1.4.0",
+    "element-plus": "^2.3.8",
+    "fast-glob": "^3.3.0",
+    "pinia": "^2.1.4",
+    "sass": "^1.63.6",
+    "vite-plugin-svg-icons": "^2.0.1",
+    "vue": "^3.3.4",
+    "vue-router": "^4.2.4"
+  },
+  "devDependencies": {
+    "@vitejs/plugin-vue": "^4.2.3",
+    "typescript": "^5.0.2",
+    "vite": "^4.4.0",
+    "vue-tsc": "^1.8.3"
+  }
+}

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1 - 0
public/vite.svg


+ 16 - 0
src/App.vue

@@ -0,0 +1,16 @@
+<script setup lang="ts">
+</script>
+
+<template>
+  <router-view v-slot="{Component}">
+    <transition>
+      <keep-alive>
+        <component :is="Component"></component>
+      </keep-alive>
+    </transition>
+  </router-view>
+</template>
+
+<style scoped>
+
+</style>

+ 87 - 0
src/assets/static/style/global.scss

@@ -0,0 +1,87 @@
+@font-face{
+  font-family: SHSSR;
+  src: url('../font/Source_Han_Sans_SC_Regular.otf');
+}
+body,html{
+  padding: 0;
+  margin: 0;
+  font-size: 16px;
+  font-weight: 400;
+  font-family: SHSSR;
+  *{
+    box-sizing: border-box;
+  }
+}
+.fl{
+  float: left;
+}
+.fr{
+  float: right;
+}
+ul,li{
+  list-style: none;
+  padding: 0;
+  margin: 0;
+}
+.text-center{
+  text-align:  center;
+}
+.text-left{
+  text-align: left;
+}
+.text-right{
+  text-align: right;
+}
+.relative{
+  position: relative;
+}
+.absolute{
+  position: absolute;
+}
+.h1{
+  font-size: 2em;
+  font-weight: 600;
+}
+.h2{
+  font-size: 1.8em;
+  font-weight: 600;
+}
+.h3{
+  font-size: 1.6em;
+  font-weight: 600;
+}
+.h4{
+  font-size: 1.4em;
+}
+.h5{
+  font-size: 1.2em;
+}
+.h6{
+  font-size: 1em;
+}
+.p{
+  font-weight: 600;
+}
+.pointer{
+  cursor: pointer;
+}
+::-webkit-scrollbar {/*滚动条整体样式*/
+  width: 0px;     /*高宽分别对应横竖滚动条的尺寸*/
+  height: 0px;
+}
+::-webkit-scrollbar-thumb {/*滚动条里面小方块*/
+  border-radius: 10px;
+  box-shadow: inset 0 0 5px rgba(71, 71, 71, 0.2);
+  background: #bbb;
+}
+::-webkit-scrollbar-track {/*滚动条里面轨道*/
+  box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
+  border-radius: 10px;
+  background: #EDEDED;
+}
+.margin-auto{
+  margin: auto;
+}
+
+
+

+ 1 - 0
src/assets/static/style/index.scss

@@ -0,0 +1 @@
+@use './global.scss' as global ;

+ 54 - 0
src/assets/static/style/loading.scss

@@ -0,0 +1,54 @@
+.block-loading {
+    width: 100%;
+    height: 100%;
+    position: fixed;
+    z-index: 9990;
+    background-color: rgba(0,0,0,.5);
+}
+.block-loading .block-loading-box {
+    position: absolute;
+    top: 50%;
+    left: 50%;
+    transform: translate(-50%, -50%);
+}
+.block-loading .block-loading-box-warp {
+    width: 80px;
+    height: 80px;
+}
+.block-loading .block-loading-box-warp .block-loading-box-item {
+    width: 33.333333%;
+    height: 33.333333%;
+    background: #409eff;
+    float: left;
+    animation: block-loading-animation 1.2s infinite ease;
+    border-radius: 1px;
+}
+.block-loading .block-loading-box-warp .block-loading-box-item:nth-child(7) {
+    animation-delay: 0s;
+}
+.block-loading .block-loading-box-warp .block-loading-box-item:nth-child(4),
+.block-loading .block-loading-box-warp .block-loading-box-item:nth-child(8) {
+    animation-delay: 0.1s;
+}
+.block-loading .block-loading-box-warp .block-loading-box-item:nth-child(1),
+.block-loading .block-loading-box-warp .block-loading-box-item:nth-child(5),
+.block-loading .block-loading-box-warp .block-loading-box-item:nth-child(9) {
+    animation-delay: 0.2s;
+}
+.block-loading .block-loading-box-warp .block-loading-box-item:nth-child(2),
+.block-loading .block-loading-box-warp .block-loading-box-item:nth-child(6) {
+    animation-delay: 0.3s;
+}
+.block-loading .block-loading-box-warp .block-loading-box-item:nth-child(3) {
+    animation-delay: 0.4s;
+}
+@keyframes block-loading-animation {
+    0%,
+    70%,
+    100% {
+        transform: scale3D(1, 1, 1);
+    }
+    35% {
+        transform: scale3D(0, 0, 1);
+    }
+}

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1 - 0
src/assets/static/svg/home.svg


+ 1 - 0
src/assets/static/svg/vue.svg

@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="37.07" height="36" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 198"><path fill="#41B883" d="M204.8 0H256L128 220.8L0 0h97.92L128 51.2L157.44 0h47.36Z"></path><path fill="#41B883" d="m0 0l128 220.8L256 0h-51.2L128 132.48L50.56 0H0Z"></path><path fill="#35495E" d="M50.56 0L128 133.12L204.8 0h-47.36L128 51.2L97.92 0H50.56Z"></path></svg>

+ 38 - 0
src/components/HelloWorld.vue

@@ -0,0 +1,38 @@
+<script setup lang="ts">
+import { ref } from 'vue'
+
+defineProps<{ msg: string }>()
+
+const count = ref(0)
+</script>
+
+<template>
+  <h1>{{ msg }}</h1>
+
+  <div class="card">
+    <button type="button" @click="count++">count is {{ count }}</button>
+    <p>
+      Edit
+      <code>components/HelloWorld.vue</code> to test HMR
+    </p>
+  </div>
+
+  <p>
+    Check out
+    <a href="https://vuejs.org/guide/quick-start.html#local" target="_blank"
+      >create-vue</a
+    >, the official Vue + Vite starter
+  </p>
+  <p>
+    Install
+    <a href="https://github.com/vuejs/language-tools" target="_blank">Volar</a>
+    in your IDE for a better DX
+  </p>
+  <p class="read-the-docs">Click on the Vite and Vue logos to learn more</p>
+</template>
+
+<style scoped>
+.read-the-docs {
+  color: #888;
+}
+</style>

+ 42 - 0
src/components/svg-icon/index.vue

@@ -0,0 +1,42 @@
+<template>
+  <svg class="svgClass" :class="svgClass" aria-hidden="true" :style="_style">
+    <use :xlink:href="_name" />
+  </svg>
+</template>
+<script lang="ts" setup>
+import {ref,computed } from 'vue'
+
+interface Props {
+  name:string,
+  prefix?:string,
+  size?:number | string,
+  svgClass?:string,
+  svgStyle?:string,
+  width?:string,
+  height?:string,
+}
+const props = withDefaults( defineProps<Props>(),{
+  prefix:'icon',
+  size:1.5
+})
+const _style = computed(()=>{
+  if(props.width && props.height){
+    return `width:${props.width};height:${props.height};`;
+  }
+  if(props.size){
+    return `width:${props.size}em;height:${props.size}em;`;
+  }
+  return '';
+})
+const _name = computed(()=>`#${props.prefix}-${props.name}`)
+</script>
+<style lang="scss">
+.svgClass{
+  width:2em;
+  height:2em;
+  vertical-align: middle;
+  position: relative;
+  top: -1px;
+  fill: currentColor;
+}
+</style>

+ 22 - 0
src/main.ts

@@ -0,0 +1,22 @@
+import { createApp } from 'vue'
+import App from './App.vue'
+
+import 'virtual:svg-icons-register'
+import { registerIcons } from './utils/common'
+
+import ElementPlus from 'element-plus'
+import 'element-plus/dist/index.css'
+import 'element-plus/theme-chalk/dark/css-vars.css'
+import './assets/static/style/index.scss'
+
+import { createPinia } from 'pinia'
+const pinia = createPinia();
+
+import router from './router'
+
+const app = createApp(App)
+app.use(router)
+app.use(ElementPlus)
+app.use(pinia)
+registerIcons(app)
+app.mount('#app')

+ 25 - 0
src/router/index.ts

@@ -0,0 +1,25 @@
+import 'vue-router'
+import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
+
+const routes: Array<RouteRecordRaw> = [
+  {
+    path: '/',
+    redirect: '/index'
+  },
+  {
+    path: '/index',
+    name: '首页',
+    component: () => import('../views/index.vue'),
+    meta: {
+      icon: 'home'
+    }
+  },
+
+]
+
+const router = createRouter({
+  history: createWebHistory(),
+  routes
+})
+
+export default router

+ 22 - 0
src/stores/global.ts

@@ -0,0 +1,22 @@
+import { ref } from 'vue'
+import { defineStore } from 'pinia'
+
+export const useGlobalStore = defineStore("global",()=>{
+  let token = ref('');
+
+  let isDark = ref(false);
+
+  let change = (option:String,val?:any) => {
+    console.log(option,val)
+    if(option == 'dark'){
+      isDark.value = !isDark.value;
+      return 
+    }else if(option == 'toke'){
+      return token.value = val;
+    }else{
+      return console.log("no change option");
+    }
+  }
+  
+  return { token,isDark,change }
+})

+ 34 - 0
src/utils/common.ts

@@ -0,0 +1,34 @@
+import * as elIcons from '@element-plus/icons-vue'
+import svgIcon from '../components/svg-icon/index.vue'
+
+export function registerIcons(app: any) {
+  /*
+   * 全局注册 Icon
+   * 使用方式: <svg-icon name="name" size="size" color="color" />
+   * 详见<待完善>
+   */
+  app.component('svg-icon', svgIcon)
+
+  /*
+   * 全局注册element Plus的icon
+   */
+  for (const [key, component] of Object.entries(elIcons)) {
+    app.component(key, component)
+  }
+}
+
+/* 加载网络css文件 */
+export function loadCss(url: string): void {
+  const link = document.createElement('link')
+  link.rel = 'stylesheet'
+  link.href = url
+  link.crossOrigin = 'anonymous'
+  document.getElementsByTagName('head')[0].appendChild(link)
+}
+
+/* 加载网络js文件 */
+export function loadJs(url: string): void {
+  const link = document.createElement('script')
+  link.src = url
+  document.body.appendChild(link)
+}

+ 3 - 0
src/utils/directives.ts

@@ -0,0 +1,3 @@
+export function directives (app:any) {
+  console.log(app)
+}

+ 34 - 0
src/utils/loading.ts

@@ -0,0 +1,34 @@
+import { nextTick } from 'vue'
+import '../assets/static/style/loading.scss'
+
+export const loading = {
+    show: () => {
+        const bodys: Element = document.body
+        const div = document.createElement('div')
+        div.className = 'block-loading'
+        div.innerHTML = `
+            <div class="block-loading-box">
+                <div class="block-loading-box-warp">
+                    <div class="block-loading-box-item"></div>
+                    <div class="block-loading-box-item"></div>
+                    <div class="block-loading-box-item"></div>
+                    <div class="block-loading-box-item"></div>
+                    <div class="block-loading-box-item"></div>
+                    <div class="block-loading-box-item"></div>
+                    <div class="block-loading-box-item"></div>
+                    <div class="block-loading-box-item"></div>
+                    <div class="block-loading-box-item"></div>
+                </div>
+            </div>
+        `
+        bodys.insertBefore(div, bodys.childNodes[0])
+    },
+    hide: () => {
+        nextTick(() => {
+            setTimeout(() => {
+                const el = document.querySelector('.block-loading')
+                el && el.parentNode?.removeChild(el)
+            }, 1000)
+        })
+    },
+}

+ 45 - 0
src/utils/request.ts

@@ -0,0 +1,45 @@
+
+import axios from "axios";
+// import router from '../router'
+// import { useGlobalStore } from '../stores/global';
+// import { ElMessage } from 'element-plus'
+
+// axios.defaults.baseURL = '/dev';
+// axios.interceptors.request.use(
+//   (config:any) => {
+//     const store = useGlobalStore();
+//     let token = store.token || localStorage.getItem("token");
+//     if(token)  
+//       config.headers.Authorization = `token ${token}`;
+//     return config;
+//   },
+//   (err:any) => Promise.reject(err)
+// );
+
+// axios.interceptors.response.use(
+//   (res:any)=>{
+//     if (res.status == '200' && res.data.code == '200' ) {
+//       return Promise.resolve(res.data);
+//     }else{
+//       ElMessage.error( res.message || res.data.message || '错误' );
+//       if(res.data.code == '4000'){
+//         router.replace({path: '/login'});
+//         return Promise.reject(res.data);
+//       }
+//       return Promise.reject(res.data);
+//     }
+//   },(error:any)=>{
+//     ElMessage.error('请求失败,请刷新重试!');
+//     return Promise.reject(error);
+//   }
+// )
+
+export function request(url:string,params:any) {
+  return axios.post(url,params)
+}
+export function get(url:string,params?:any){
+  return axios.get(url,{params})
+}
+export function post(url:string,params?:any) {
+  return axios.post(url,params)
+}

+ 65 - 0
src/views/index.vue

@@ -0,0 +1,65 @@
+<template>
+  <svg-icon :size="14" name="vue" class="svgicon" color="#ff0000" /> <br>
+  <svg-icon :size="4" name="home" class="svgicon" color="#ff0000"  /> <br>
+  <el-row class="mb-4">
+    <el-button>Default</el-button>
+    <el-button type="primary">Primary</el-button>
+    <el-button type="success">Success</el-button>
+    <el-button type="info">Info</el-button>
+    <el-button type="warning">Warning</el-button>
+    <el-button type="danger">Danger</el-button>
+  </el-row>
+
+  <el-row class="mb-4">
+    <el-button plain>Plain</el-button>
+    <el-button type="primary" plain>Primary</el-button>
+    <el-button type="success" plain>Success</el-button>
+    <el-button type="info" plain>Info</el-button>
+    <el-button type="warning" plain>Warning</el-button>
+    <el-button type="danger" plain>Danger</el-button>
+  </el-row>
+
+  <el-row class="mb-4">
+    <el-button round>Round</el-button>
+    <el-button type="primary" round>Primary</el-button>
+    <el-button type="success" round>Success</el-button>
+    <el-button type="info" round>Info</el-button>
+    <el-button type="warning" round>Warning</el-button>
+    <el-button type="danger" round>Danger</el-button>
+  </el-row>
+
+  <el-row>
+    <el-button :icon="Search" circle />
+    <el-button type="primary" :icon="Edit" circle />
+    <el-button type="success" :icon="Check" circle />
+    <el-button type="info" :icon="Message" circle />
+    <el-button type="warning" :icon="Star" circle />
+    <el-button type="danger" :icon="Delete" circle />
+  </el-row>
+  <el-skeleton />
+  <br />
+
+  <el-skeleton style="--el-skeleton-circle-size: 100px">
+    <template #template>
+      <el-skeleton-item variant="circle" />
+    </template>
+  </el-skeleton>
+
+
+</template>
+
+<script lang="ts" setup>
+import {
+  Check,
+  Delete,
+  Edit,
+  Message,
+  Search,
+  Star,
+} from '@element-plus/icons-vue'
+</script>
+<style lang='scss' scoped>
+  .mb-4{
+    margin-bottom: 4px;
+  }
+</style>

+ 1 - 0
src/vite-env.d.ts

@@ -0,0 +1 @@
+/// <reference types="vite/client" />

+ 25 - 0
tsconfig.json

@@ -0,0 +1,25 @@
+{
+  "compilerOptions": {
+    "target": "ES2020",
+    "useDefineForClassFields": true,
+    "module": "ESNext",
+    "lib": ["ES2020", "DOM", "DOM.Iterable"],
+    "skipLibCheck": true,
+
+    /* Bundler mode */
+    "moduleResolution": "bundler",
+    "allowImportingTsExtensions": true,
+    "resolveJsonModule": true,
+    "isolatedModules": true,
+    "noEmit": true,
+    "jsx": "preserve",
+
+    /* Linting */
+    "strict": true,
+    "noUnusedLocals": true,
+    "noUnusedParameters": true,
+    "noFallthroughCasesInSwitch": true
+  },
+  "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
+  "references": [{ "path": "./tsconfig.node.json" }]
+}

+ 10 - 0
tsconfig.node.json

@@ -0,0 +1,10 @@
+{
+  "compilerOptions": {
+    "composite": true,
+    "skipLibCheck": true,
+    "module": "ESNext",
+    "moduleResolution": "bundler",
+    "allowSyntheticDefaultImports": true
+  },
+  "include": ["vite.config.ts"]
+}

+ 18 - 0
vite.config.ts

@@ -0,0 +1,18 @@
+import { defineConfig } from 'vite'
+import vue from '@vitejs/plugin-vue'
+import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
+import path , {resolve} from 'path'
+// https://vitejs.dev/config/
+export default defineConfig({
+  plugins: [
+    vue(),
+    createSvgIconsPlugin({
+      iconDirs: [resolve(process.cwd(), 'src/assets/static/svg')],  
+    }),
+  ],
+  server:{
+    hmr:true,  
+    port: 9074,
+    open: true, 
+  }
+})

+ 29 - 0
记录.md

@@ -0,0 +1,29 @@
+##  记录
+
+-------------------
+
+1. 新建项目 ``npm create vite@latest vue-vite-ts -- --template vue-ts``。
+2. 加载依赖 ``npm i``,启动服务``npm run dev``。
+3. 修改``vite.config.ts`` 中的配置,``defineConfig.server``新增配置。
+   > {  
+   >    hmr:true,  
+   >    port: 9074,   
+   >    open: true,    
+   > }  
+4. 增加路由插件vue-router  ``npm install vue-router@4``,使用HTML5模式。
+   在src路径下新建router文件夹,在``main.ts``中加载注册使用。
+5. 添加elementui插件  ``npm install element-plus --save``。
+   在``main.ts``中引用使用。
+   > import 'element-plus/dist/index.css'  
+   > import 'element-plus/theme-chalk/dark/css-vars.css'
+6. 添加pinia插件, ``npm install pinia --save``。
+   在``main.ts``中加载注册使用。
+   > import { createPinia } from 'pinia'   
+   > const pinia = createPinia();
+7. 添加sass 插件, ``npm install sass --save``
+8. 新增使用svg图片的功能。
+   使用vite-plugin-svg-icons插件,还需要安装下fast-glob相关依赖。
+   
+
+
+