Commit 1b590ec1 authored by limeimei's avatar limeimei

初始化

parents
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
.DS_Store
dist
dist-ssr
coverage
*.local
/cypress/videos/
/cypress/screenshots/
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
*.tsbuildinfo
{
"recommendations": ["Vue.volar"]
}
# voltaic
This template should help get you started developing with Vue 3 in Vite.
## Recommended IDE Setup
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur).
## 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 [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) to make the TypeScript language service aware of `.vue` types.
## Customize configuration
See [Vite Configuration Reference](https://vitejs.dev/config/).
## Project Setup
```sh
npm install
```
### Compile and Hot-Reload for Development
```sh
npm run dev
```
### Type-Check, Compile and Minify for Production
```sh
npm run build
```
/// <reference types="vite/client" />
/// <reference types="node" />
interface IResponse<T> {
code: number;
data: T;
message: string;
}
type RES<T> = Promise<IResponse<T>>
\ No newline at end of file
<!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>Vite App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
This diff is collapsed.
{
"name": "voltaic",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"dev": "vite --mode=dev",
"build": "run-p type-check \"build-only {@}\" --",
"preview": "vite preview",
"build-only": "vite build",
"type-check": "vue-tsc --build --force"
},
"dependencies": {
"axios": "^1.6.7",
"element-plus": "^2.6.1",
"pinia": "^2.1.7",
"vue": "^3.4.21",
"vue-router": "^4.3.0"
},
"devDependencies": {
"@tsconfig/node20": "^20.1.2",
"@types/node": "^20.11.25",
"@vitejs/plugin-vue": "^5.0.4",
"@vue/tsconfig": "^0.5.1",
"npm-run-all2": "^6.1.2",
"typescript": "~5.4.0",
"vite": "^5.1.5",
"vue-tsc": "^2.0.6"
}
}
\ No newline at end of file
<script setup lang="ts">
import { RouterLink, RouterView } from 'vue-router'
import MainIndex from './components/index.vue'
</script>
<template>
<header>
<!-- <img alt="Vue logo" class="logo" src="@/assets/logo.svg" width="125" height="125" /> -->
<div class="wrapper">
<MainIndex />
</div>
</header>
<!-- <RouterView /> -->
</template>
<style scoped>
</style>
\ No newline at end of file
/* color palette from <https://github.com/vuejs/theme> */
:root {
--vt-c-white: #ffffff;
--vt-c-white-soft: #f8f8f8;
--vt-c-white-mute: #f2f2f2;
--vt-c-black: #181818;
--vt-c-black-soft: #222222;
--vt-c-black-mute: #282828;
--vt-c-indigo: #2c3e50;
--vt-c-divider-light-1: rgba(60, 60, 60, 0.29);
--vt-c-divider-light-2: rgba(60, 60, 60, 0.12);
--vt-c-divider-dark-1: rgba(84, 84, 84, 0.65);
--vt-c-divider-dark-2: rgba(84, 84, 84, 0.48);
--vt-c-text-light-1: var(--vt-c-indigo);
--vt-c-text-light-2: rgba(60, 60, 60, 0.66);
--vt-c-text-dark-1: var(--vt-c-white);
--vt-c-text-dark-2: rgba(235, 235, 235, 0.64);
}
/* semantic color variables for this project */
:root {
--color-background: var(--vt-c-white);
--color-background-soft: var(--vt-c-white-soft);
--color-background-mute: var(--vt-c-white-mute);
--color-border: var(--vt-c-divider-light-2);
--color-border-hover: var(--vt-c-divider-light-1);
--color-heading: var(--vt-c-text-light-1);
--color-text: var(--vt-c-text-light-1);
--section-gap: 160px;
}
@media (prefers-color-scheme: dark) {
:root {
--color-background: var(--vt-c-black);
--color-background-soft: var(--vt-c-black-soft);
--color-background-mute: var(--vt-c-black-mute);
--color-border: var(--vt-c-divider-dark-2);
--color-border-hover: var(--vt-c-divider-dark-1);
--color-heading: var(--vt-c-text-dark-1);
--color-text: var(--vt-c-text-dark-2);
}
}
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
font-weight: normal;
}
body {
min-height: 100vh;
color: var(--color-text);
background: var(--color-background);
transition:
color 0.5s,
background-color 0.5s;
line-height: 1.6;
font-family:
Inter,
-apple-system,
BlinkMacSystemFont,
'Segoe UI',
Roboto,
Oxygen,
Ubuntu,
Cantarell,
'Fira Sans',
'Droid Sans',
'Helvetica Neue',
sans-serif;
font-size: 15px;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 261.76 226.69"><path d="M161.096.001l-30.225 52.351L100.647.001H-.005l130.877 226.688L261.749.001z" fill="#41b883"/><path d="M161.096.001l-30.225 52.351L100.647.001H52.346l78.526 136.01L209.398.001z" fill="#34495e"/></svg>
@import './base.css';
#app {
/* max-width: 1280px; */
margin: 0 auto;
/* padding: 2rem; */
font-weight: normal;
}
a,
.green {
text-decoration: none;
color: hsla(160, 100%, 37%, 1);
transition: 0.4s;
padding: 3px;
}
@media (hover: hover) {
a:hover {
background-color: hsla(160, 100%, 37%, 0.2);
}
}
\ No newline at end of file
<script setup lang="ts">
defineProps < {
msg: string
} > ()
</script>
<template>
<div class="greetings">
<h1 class="green">{{ msg }}</h1>
<h3>
You’ve successfully created a project with
<a href="https://vitejs.dev/" target="_blank" rel="noopener">Vite</a> +
<a href="https://vuejs.org/" target="_blank" rel="noopener">Vue 3</a>. What's next?
</h3>
</div>
</template>
<style scoped>
h1 {
font-weight: 500;
font-size: 2.6rem;
position: relative;
top: -10px;
}
h3 {
font-size: 1.2rem;
}
.greetings h1,
.greetings h3 {
text-align: center;
}
@media (min-width: 1024px) {
.greetings h1,
.greetings h3 {
text-align: left;
}
}
</style>
\ No newline at end of file
<script setup lang="ts">
import { ref } from 'vue'
let list = ref([{ id: 0, name: 22 }, { id: 1, name: 22 }, { id: 2, name: 22 }])
</script>
<template>
<div class="wrapper">
<div class="top">
<div class="top_item"><span class="top_item_title">设备SN</span><span class="top_item_con">1111</span></div>
<div class="top_item"><span class="top_item_title">设备状态</span><span class="top_item_con">1111</span></div>
<div class="top_item"><span class="top_item_title">设备温度</span><span class="top_item_con">1111</span></div>
<div class="top_item"><span class="top_item_title">设备总功率</span><span class="top_item_con">1111</span></div>
</div>
<div class="center">
<div v-for="item in list" :key="item.id">
<div class="center_item">
<el-button type="primary">通道{{item.id +1}}</el-button>
<div class="item_table_w">
<div class="item_table">
<div class="item_text"><span style="margin-right: 37px;">电流</span> <span>14A</span>
</div>
<div class="item_text2"><span style="margin-right: 37px;">电压</span><span>14A</span> </div>
</div>
<img src="@/assets/img/box.png" alt="" class="item_img">
</div>
</div>
</div>
</div>
</div>
</template>
<style scoped>
.wrapper {
background: #F4F7FC;
height: 100vh;
padding: 40px;
}
.top {
display: flex;
}
.top_item {
width: 300px;
height: 150px;
background: #FFFFFF;
box-shadow: 0px 1px 4px 1px rgba(21, 34, 50, 0.08);
border-radius: 6px 6px 6px 6px;
display: flex;
flex-direction: column;
padding: 20px;
margin-right: 40px;
}
.top_item_title {
font-size: 18px;
color: #7E84A3;
margin-bottom: 34px;
}
.top_item_con {
font-size: 28px;
color: #131523;
}
.center {
background: #FFFFFF;
display: flex;
margin-top: 40px;
}
.center_item {
width: 227px;
display: flex;
flex-direction: column;
align-items: center;
margin-top: 34px;
}
.item_table_w {
display: flex;
flex-direction: column;
border-right: 1px solid #E5E5E5;
width: 227px;
align-items: center;
margin-bottom: 38px;
}
.item_table {
border: 1px solid #B1B1B1;
line-height: 32px;
width: 152px;
text-align: center;
font-size: 18px;
color: #333333;
margin: 14px 0 36px 0;
}
.item_text {
border-bottom: 1px solid #B1B1B1;
}
.item_img {
width: 35.76px;
height: 150.37px;
}
</style>
\ No newline at end of file
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import Direct from './direct.vue'
import { UserService } from '/src/utils/api.ts'
onMounted(() => {
// login1()
})
const login1 = async () => {
const loginParams = {
autoLogin: true,
username: 'sixiang',
password: 'qwe123',
}
const res = await UserService.login1(loginParams)
// console.log(res)
}
let activeName = ref(0)
const handleClick = (tab) => {
console.log(tab.props.name)
}
</script>
<template>
<div class="wrapper">
<div class="header">
<el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane label="光伏智能直流汇流箱" name="0">
<Direct />
</el-tab-pane>
<el-tab-pane label="配置管理" name="second">光伏智能交流汇流箱</el-tab-pane>
<el-tab-pane label="角色管理" name="third">光伏智能并网箱</el-tab-pane>
</el-tabs>
</div>
</div>
</template>
<style scoped>
.wrapper {
/* background: #F4F7FC; */
}
:deep(.el-tabs) {
--el-tabs-header-height: 70px;
}
:deep(.el-tabs__header) {
margin: 0;
background: white;
margin-left: 50px;
}
:deep(.el-tabs__nav-wrap::after) {
height: 0px;
}
</style>
\ No newline at end of file
import './assets/main.css'
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import router from './router'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
const app = createApp(App)
app.use(createPinia())
app.use(router)
app.use(ElementPlus)
app.mount('#app')
import { createRouter, createWebHistory } from 'vue-router'
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
// {
// path: '/about',
// name: 'about',
// // route level code-splitting
// // this generates a separate chunk (About.[hash].js) for this route
// // which is lazy-loaded when the route is visited.
// component: () => import('../views/AboutView.vue')
// }
]
})
export default router
import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
export const useCounterStore = defineStore('counter', () => {
const count = ref(0)
const doubleCount = computed(() => count.value * 2)
function increment() {
count.value++
}
return { count, doubleCount, increment }
})
import { request } from './axios'
/**
* @description -封装User类型的接口方法
*/
export class UserService { // 模块一
/**
* @description 用户登录
* @param {string} username - 用户名
* @return {HttpResponse} result
*/
static async login1(params: Object) { // 接口一
console.log(params)
return request('/user/login', params, 'post')
}
}
export class landRelevant { // 模块二
/**
* @description 获取地列表
* @return {HttpResponse} result
*/
static async landList({ params }: any) {
return request('/land_list_info', params, 'get')
}
}
import axios from 'axios';
import { showMessage } from "./status"; // 引入状态码文件
import { ElMessage } from 'element-plus' // 引入el 提示框,这个项目里用什么组件库这里引什么
const instance = axios.create({
baseURL: `sys/dev`,
timeout: 3500 //响应时间
})
//http request 拦截器
instance.interceptors.request.use(
(config) => {
console.log("请求拦截器");
let token = localStorage.getItem("token");
if (token) {
if (config.headers) {
config.headers["Authorization"] = token
}
}
return config;
},
error => {
return Promise.reject(error);
}
);
//http response 拦截器
instance.interceptors.response.use(
response => {
return response;
},
error => {
const { response } = error;
if (response) {
// 请求已发出,但是不在2xx的范围
showMessage(response.status); // 传入响应码,匹配响应码对应信息
return Promise.reject(response.data);
} else {
ElMessage.warning('网络连接异常,请稍后再试!');
}
}
);
// 封装 GET POST 请求并导出
export function request(url = '', params = {}, type = 'POST') {
//设置 url params type 的默认值
return new Promise((resolve, reject) => {
let promise
if (type.toUpperCase() === 'GET') {
promise = instance({
url,
params
})
} else if (type.toUpperCase() === 'POST') {
promise = instance({
method: 'POST',
url,
data: params
})
}
//处理返回
promise.then(res => {
resolve(res)
}).catch(err => {
reject(err)
})
})
}
export const showMessage = (status: number | string): string => {
let message: string = "";
switch (status) {
case 400:
message = "请求错误(400)";
break;
case 401:
message = "未授权,请重新登录(401)";
break;
case 403:
message = "拒绝访问(403)";
break;
case 404:
message = "请求出错(404)";
break;
case 408:
message = "请求超时(408)";
break;
case 500:
message = "服务器错误(500)";
break;
case 501:
message = "服务未实现(501)";
break;
case 502:
message = "网络错误(502)";
break;
case 503:
message = "服务不可用(503)";
break;
case 504:
message = "网络超时(504)";
break;
case 505:
message = "HTTP版本不受支持(505)";
break;
default:
message = `连接出错(${status})!`;
}
return `${message},请检查网络或联系管理员!`;
};
{
"extends": "@vue/tsconfig/tsconfig.dom.json",
"include": [
"env.d.ts",
"src/**/*",
"src/**/*.vue"
],
"exclude": [
"src/**/__tests__/*"
],
"compilerOptions": {
"composite": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"baseUrl": ".",
"paths": {
"@/*": [
"./src/*"
]
}
}
}
\ No newline at end of file
{
"files": [],
"references": [
{
"path": "./tsconfig.node.json"
},
{
"path": "./tsconfig.app.json"
}
]
}
{
"extends": "@tsconfig/node20/tsconfig.json",
"include": [
"vite.config.*",
"vitest.config.*",
"cypress.config.*",
"nightwatch.conf.*",
"playwright.config.*"
],
"compilerOptions": {
"composite": true,
"noEmit": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"module": "ESNext",
"moduleResolution": "Bundler",
"types": ["node"]
}
}
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
server: {
proxy: {
'/sys/dev/': {
target: 'http://120.77.240.215:8856',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/sys/, ''),
}
}
},
define: {
'process.env': {}
}
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment