Merge pull request '前端' (#2) from gsl into main

main
fdzcxy212206413 1 month ago
commit 10d135c0e8

@ -0,0 +1,14 @@
/* eslint-env node */
require('@rushstack/eslint-patch/modern-module-resolution')
module.exports = {
root: true,
'extends': [
'plugin:vue/vue3-essential',
'eslint:recommended',
'@vue/eslint-config-prettier/skip-formatting'
],
parserOptions: {
ecmaVersion: 'latest'
}
}

30
.gitignore vendored

@ -0,0 +1,30 @@
# 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

@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/prettierrc",
"semi": false,
"tabWidth": 2,
"singleQuote": true,
"printWidth": 100,
"trailingComma": "none"
}

@ -0,0 +1,7 @@
{
"recommendations": [
"Vue.volar",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
]
}

@ -1,2 +1 @@
# gsl_grs

@ -0,0 +1,13 @@
<!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.js"></script>
</body>
</html>

@ -0,0 +1,8 @@
{
"compilerOptions": {
"paths": {
"@/*": ["./src/*"]
}
},
"exclude": ["node_modules", "dist"]
}

3117
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -0,0 +1,28 @@
{
"name": "base-conversion",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore",
"format": "prettier --write src/"
},
"dependencies": {
"axios": "^1.7.7",
"element-plus": "^2.8.4",
"vue": "^3.4.29"
},
"devDependencies": {
"@rushstack/eslint-patch": "^1.8.0",
"@vitejs/plugin-vue": "^5.0.5",
"@vue/eslint-config-prettier": "^9.0.0",
"eslint": "^8.57.0",
"eslint-plugin-vue": "^9.23.0",
"prettier": "^3.3.3",
"sass-embedded": "^1.79.4",
"vite": "^5.3.1"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

@ -0,0 +1,11 @@
<script setup>
import BaseConversion from '@/components/BaseConversion.vue'
</script>
<template>
<div id="id">
<BaseConversion></BaseConversion>
</div>
</template>
<style scoped lang="scss"></style>

@ -0,0 +1,5 @@
import request from '@/utils/request.js'
export const baseConversionService = (dataModel) => {
return request.post('/conversion/change', dataModel)
}

@ -0,0 +1,167 @@
<script setup>
import { ref } from 'vue'
import { ElMessage } from 'element-plus'
import { baseConversionService } from '@/api/data.js'
//
const dataModel = ref({
before: '10',
number: '',
after: '10'
})
const result = ref('')
//
const dataModelRules = {
number: [
{ required: true, message: '请输入数字', trigger: 'blur' },
{
validator: (rule, value, callback) => {
const base = parseInt(dataModel.value.before)
if (base === 2) {
const isBinary = /^[01]+$/.test(value)
return isBinary ? callback() : callback(new Error('二进制只能输入0或1'))
} else if (base === 8) {
const isOctal = /^[0-7]+$/.test(value)
return isOctal ? callback() : callback(new Error('八进制只能输入0-7'))
} else if (base === 10) {
return callback()
} else if (base === 16) {
const isHexadecimal = /^[0-9A-Fa-f]+$/.test(value)
return isHexadecimal ? callback() : callback(new Error('十六进制只能输入0-9和A-F'))
}
callback(new Error('无效的进制'))
},
trigger: 'blur'
}
]
}
//
const change = async () => {
let res = await baseConversionService(dataModel.value)
if (!res.data.data) {
ElMessage({
message: res.data.message,
grouping: true,
type: 'error'
})
} else {
result.value = res.data.data
ElMessage({
message: res.data.message,
grouping: true,
type: 'success'
})
}
}
//
const clear = () => {
dataModel.value.number = ''
result.value = ''
}
</script>
<template>
<el-card class="page-container">
<template #header>
<div class="header">
<span>进制转换</span>
</div>
</template>
<el-row>
<el-col :span="12">
<el-form :model="dataModel" :rules="dataModelRules" label-width="100px" size="large">
<el-form-item label="进制选择">
<el-radio-group v-model="dataModel.before">
<el-radio value="2">二进制</el-radio>
<el-radio value="10">十进制</el-radio>
<el-radio value="8">八进制</el-radio>
<el-radio value="16">十六进制</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="输入数字" prop="number">
<el-input v-model.number="dataModel.number"></el-input>
</el-form-item>
<el-form-item label="转化后进制">
<el-radio-group v-model="dataModel.after">
<el-radio value="2">二进制</el-radio>
<el-radio value="10">十进制</el-radio>
<el-radio value="8">八进制</el-radio>
<el-radio value="16">十六进制</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="change" class="modify-button"
><span>转换</span></el-button
>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="clear" class="modify-button"
><span>清空数据</span></el-button
>
</el-form-item>
<el-form-item label="结果">
<el-input v-model="result" disabled></el-input>
</el-form-item>
</el-form>
</el-col>
</el-row>
</el-card>
</template>
<style scoped lang="scss">
.page-container {
.modify-button {
display: inline-block;
width: 150px;
height: 50px;
border-radius: 10px;
border: 1px solid #03045e;
position: relative;
overflow: hidden;
transition: all 0.5s ease-in;
z-index: 1;
}
.modify-button::before,
.modify-button::after {
content: '';
position: absolute;
top: 0;
width: 0;
height: 100%;
transform: skew(15deg);
transition: all 0.5s;
overflow: hidden;
z-index: -1;
}
.modify-button::before {
left: -10px;
background: #240046;
}
.modify-button::after {
right: -10px;
background: #5a189a;
}
.modify-button:hover::before,
.modify-button:hover::after {
width: 58%;
}
.modify-button:hover span {
color: #e0aaff;
transition: 0.3s;
}
.modify-button span {
color: #03045e;
font-size: 18px;
transition: all 0.3s ease-in;
}
}
</style>

@ -0,0 +1,8 @@
import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import App from './App.vue'
const app = createApp(App)
app.use(ElementPlus)
app.mount('#app')

@ -0,0 +1,7 @@
import axios from 'axios'
//定义一个变量,记录公共的前缀
const baseURL = '/api'
const instance = axios.create({ baseURL })
export default instance

@ -0,0 +1,28 @@
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: {
//获取路径当中包含了/api的请求
'/api': {
//后台服务所在的源
target: 'http://localhost:5678',
//修改源
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '')
}
}
}
})
Loading…
Cancel
Save