Commit ed7708e4 by luyt

feat:项目显示列表

1 parent 19ea3d71
......@@ -15,6 +15,8 @@ module.exports = {
rules: {
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
"@typescript-eslint/no-explicit-any": 0,
"vue/multi-word-component-names": 0,
},
overrides: [
{
......
{
"endOfLine": "lf"
}
\ No newline at end of file
// Generated by 'unplugin-auto-import'
// We suggest you to commit this file into source control
declare global {
const ElButton: typeof import('element-plus/es')['ElButton']
const ElCard: typeof import('element-plus/es')['ElCard']
const ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
const ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup']
const ElCol: typeof import('element-plus/es')['ElCol']
const ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
const ElForm: typeof import('element-plus/es')['ElForm']
const ElFormItem: typeof import('element-plus/es')['ElFormItem']
const ElInput: typeof import('element-plus/es')['ElInput']
const ElOption: typeof import('element-plus/es')['ElOption']
const ElRadio: typeof import('element-plus/es')['ElRadio']
const ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
const ElRow: typeof import('element-plus/es')['ElRow']
const ElSelect: typeof import('element-plus/es')['ElSelect']
const ElSwitch: typeof import('element-plus/es')['ElSwitch']
const ElTimePicker: typeof import('element-plus/es')['ElTimePicker']
}
export {}
// generated by unplugin-vue-components
// We suggest you to commit this file into source control
// Read more: https://github.com/vuejs/vue-next/pull/3399
import '@vue/runtime-core'
declare module '@vue/runtime-core' {
export interface GlobalComponents {
AddButton: typeof import('./src/components/AddButton.vue')['default']
ElButton: typeof import('element-plus/es')['ElButton']
ElCard: typeof import('element-plus/es')['ElCard']
ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup']
ElCol: typeof import('element-plus/es')['ElCol']
ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
ElForm: typeof import('element-plus/es')['ElForm']
ElFormItem: typeof import('element-plus/es')['ElFormItem']
ElInput: typeof import('element-plus/es')['ElInput']
ElOption: typeof import('element-plus/es')['ElOption']
ElRadio: typeof import('element-plus/es')['ElRadio']
ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
ElRow: typeof import('element-plus/es')['ElRow']
ElSelect: typeof import('element-plus/es')['ElSelect']
ElSwitch: typeof import('element-plus/es')['ElSwitch']
ElTimePicker: typeof import('element-plus/es')['ElTimePicker']
HelloWorld: typeof import('./src/components/HelloWorld.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
}
}
export {}
This diff could not be displayed because it is too large.
......@@ -6,10 +6,11 @@
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"test:unit": "vue-cli-service test:unit",
"lint": "vue-cli-service lint"
"lint": "vue-cli-service lint --fix"
},
"dependencies": {
"core-js": "^3.8.3",
"element-plus": "^2.1.11",
"vue": "^3.2.13",
"vue-router": "^4.0.3",
"vuex": "^4.0.0"
......@@ -39,7 +40,9 @@
"sass": "^1.32.7",
"sass-loader": "^12.0.0",
"ts-jest": "^27.0.4",
"typescript": "~4.5.5"
"typescript": "~4.5.5",
"unplugin-auto-import": "^0.7.1",
"unplugin-vue-components": "^0.19.3"
},
"gitHooks": {
"pre-commit": "lint-staged"
......
......@@ -14,4 +14,17 @@
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
<script src="./on-error.js"></script>
<!-- 编辑器 -->
<script src="https://cdn.staticfile.org/ace/1.4.14/ace.min.js"></script>
<script src="https://cdn.staticfile.org/ace/1.4.14/ext-beautify.min.js"></script>
<script src="https://cdn.staticfile.org/ace/1.4.14/ext-language_tools.min.js"></script>
<script src="https://cdn.staticfile.org/ace/1.4.14/mode-javascript.min.js"></script>
<script src="https://cdn.staticfile.org/ace/1.4.14/snippets/javascript.min.js"></script>
<!-- <script src="https://cdn.staticfile.org/ace/1.4.14/worker-javascript.min.js"></script> -->
<!-- <script src="https://cdn.staticfile.org/ace/1.4.14/theme-xcode.min.js"></script> -->
<!-- <script src="https://cdn.staticfile.org/ace/1.4.14/theme-twilight.min.js"></script> -->
<!-- <script src="https://cdn.staticfile.org/ace/1.4.14/theme-tomorrow_night_eighties.min.js"></script> -->
<script src="https://cdn.staticfile.org/ace/1.4.14/theme-one_dark.min.js"></script>
</html>
window.onerror = function (message, source, lineno, colno, error) {
console.log("arguments", arguments);
console.log("message", message);
console.log("source", source);
console.log("lineno", lineno);
console.log("colno", colno);
console.log("error", error);
window.editorError = window.arguments;
return true;
};
<template>
<nav>
<!-- <nav>
<router-link to="/">Home</router-link> |
<router-link to="/about">About</router-link>
</nav>
</nav> -->
<router-view />
</template>
<style lang="scss">
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
* {
padding: 0;
margin: 0;
}
nav {
padding: 30px;
a {
font-weight: bold;
color: #2c3e50;
&.router-link-exact-active {
color: #42b983;
}
}
html,
body {
// height: 100%;
// min-height: 100%;
}
#app {
// min-height: 100%;
}
</style>
<template>
<el-button size="large" class="add-btn" type="primary" :icon="Plus" circle />
</template>
<script lang="ts" setup>
import { Plus } from "@element-plus/icons-vue";
</script>
<style lang="scss">
.add-btn {
position: fixed;
bottom: 100px;
right: 150px;
}
</style>
<template>
<div class="back-btn">
<el-button type="success" :icon="Back">
<!-- <Back /> -->
</el-button>
</div>
</template>
<script lang="ts">
import { defineComponent } from "vue";
import { Back } from "@element-plus/icons-vue";
export default defineComponent({
name: "BackButton",
// components: { Back },
setup() {
return {
Back,
};
},
});
</script>
<!-- <script lang="ts" setup>
import { Back } from "@element-plus/icons-vue";
</script> -->
<style lang="scss">
.back-btn {
position: fixed;
top: 50px;
left: 100px;
}
</style>
......@@ -4,6 +4,10 @@ import HomeView from "../views/HomeView.vue";
const routes: Array<RouteRecordRaw> = [
{
path: "/",
redirect: "/addproject",
},
{
path: "/",
name: "home",
component: HomeView,
},
......@@ -16,6 +20,26 @@ const routes: Array<RouteRecordRaw> = [
component: () =>
import(/* webpackChunkName: "about" */ "../views/AboutView.vue"),
},
{
path: "/aceeditor",
name: "aceeditor",
component: () =>
import(/* webpackChunkName: "aceeditor" */ "../views/AceEditor.vue"),
},
{
path: "/project",
name: "project",
component: () =>
import(/* webpackChunkName: "project" */ "../views/project/Project.vue"),
},
{
path: "/addproject",
name: "addproject",
component: () =>
import(
/* webpackChunkName: "addproject" */ "../views/project/AddProject.vue"
),
},
];
const router = createRouter({
......
......@@ -4,3 +4,9 @@ declare module '*.vue' {
const component: DefineComponent<{}, {}, any>
export default component
}
// declare var ace:any
interface Window {
ace: any,
aceError: any
}
declare const windos: Window & typeof globalThis
\ No newline at end of file
/**
* 存放公共的类型声明文件
*/
<template>
<div>
<div id="editor">{name: 'jack', age: '20'}</div>
<button @click="codeFormat">格式化代码</button>
<button @click="getCode">获取内容</button>
</div>
</template>
<script lang="ts">
import { defineComponent, onMounted, ref } from "vue";
export default defineComponent({
name: "AceEditor",
props: {},
setup() {
const editorRef = ref();
let beautify: any;
const codeFormat = () => {
beautify.beautify(editorRef.value.session);
};
onMounted(() => {
if (window.ace) {
let ace = window.ace;
ace.config.set("basePath", "https://cdn.staticfile.org/ace/1.4.14/");
// // ace.config.setModuleUrl(
// // "ace/mode/javascript_worker",
// // "https://cdn.staticfile.org/ace/1.4.14/worker-javascript.min.js"
// // );
// // ace.config.set(
// // "basePath",
// // "https://cdn.staticfile.org/ace/1.4.14/"
// // );
// // ace.config.setModuleUrl(
// // "ace/ext/language_tools",
// // "https://cdn.staticfile.org/ace/1.4.14/ext-language_tools.min.js"
// // );
editorRef.value = ace.edit("editor");
beautify = ace.require("ace/ext/beautify");
editorRef.value.setTheme("ace/theme/one_dark");
editorRef.value.session.setMode("ace/mode/javascript");
editorRef.value.setFontSize(18);
editorRef.value.session.setUseWorker(false);
//菜单提示
ace.require("ace/ext/language_tools");
editorRef.value.setOptions({
enableBasicAutocompletion: true,
enableSnippets: true,
enableLiveAutocompletion: true,
});
}
});
// 获取内容
const getCode = () => {
const content = editorRef.value.getValue();
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const contentObj = eval("(" + content + ")");
};
return {
codeFormat,
getCode,
};
},
});
</script>
<style lang="scss">
#editor {
// width: 500px;
width: 100%;
height: 400px;
.ace_print-margin {
// display: none;
}
}
</style>
<template>
<div class="add-project">
<BackButton />
<h3>项目分类</h3>
<section>
<el-form
ref="ruleFormRef"
:model="ruleForm"
:rules="rules"
label-width="120px"
class="demo-ruleForm"
:size="formSize"
>
<el-form-item label="名称" prop="name">
<el-input v-model="ruleForm.name" />
</el-form-item>
<el-form-item label="baseUrl" prop="baseUrl">
<el-input v-model="ruleForm.baseUrl" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="ruleForm.remark" type="textarea" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submitForm(ruleFormRef)"
>创建</el-button
>
<el-button @click="resetForm(ruleFormRef)">重置</el-button>
</el-form-item>
</el-form>
</section>
</div>
</template>
<script lang="ts">
import { defineComponent, reactive, ref } from "vue";
import type { FormInstance, FormRules } from "element-plus";
import BackButton from "@/components/BackButton.vue";
export default defineComponent({
name: "AddProject",
setup() {
const formSize = ref("default");
const ruleFormRef = ref<FormInstance>();
const ruleForm = reactive({
name: "",
baseUrl: "",
remark: "",
});
const rules = reactive<FormRules>({
name: [{ required: true, message: "请输入名字", trigger: "blur" }],
baseUrl: { required: true, message: "请输入baseUrl", trigger: "blur" },
remark: { required: true, message: "请输入描述", trigger: "blur" },
});
const submitForm = async (formEl: FormInstance | undefined) => {
if (!formEl) return;
await formEl.validate((valid, fields) => {
if (valid) {
console.log("submit!");
} else {
console.log("error submit!", fields);
}
});
};
const resetForm = (formEl: FormInstance | undefined) => {
if (!formEl) return;
formEl.resetFields();
};
return {
formSize,
ruleFormRef,
ruleForm,
rules,
submitForm,
resetForm,
};
},
components: {
BackButton,
},
});
</script>
<style lang="scss">
.add-project {
// display: flex;
// flex-direction: column;
// justify-content: center;
margin: 0 auto;
width: 1000px;
text-align: center;
h3 {
margin-top: 40px;
margin-bottom: 30px;
}
}
</style>
<template>
<div class="project">
<el-row :gutter="20">
<el-col
v-for="item in projectList"
:key="item.id"
:xs="12"
:sm="9"
:md="8"
:lg="6"
:xl="4"
>
<el-card :body-style="{ padding: '0px' }" shadow="hover">
<img
style="width: 100%; height: 240px"
src="../../assets/project.png"
class="image"
/>
<div style="padding: 14px">
<span>{{ item.name }}</span>
<span>{{ item.remark }}</span>
<div class="bottom">
<el-button type="text" class="button" @click="editFn(item)"
>编辑</el-button
>
<el-button type="text" class="button" @click="deleteFn(item)"
>删除</el-button
>
</div>
</div>
</el-card>
</el-col>
</el-row>
<AddButton @click="addFn" />
</div>
</template>
<script lang="ts">
import { defineComponent, reactive, toRefs } from "vue";
import AddButton from "@/components/AddButton.vue";
interface ProjectItem {
id: string;
name: string;
baseUrl: string;
remark: string;
}
interface DataType {
projectList: ProjectItem[];
}
export default defineComponent({
name: "Project",
props: {},
setup() {
const state = reactive<DataType>({
projectList: [],
});
const editFn = (item: ProjectItem) => {
console.log("editFn", item);
};
const deleteFn = (item: ProjectItem) => {
console.log("deleteFn", item);
};
const addFn = () => {
console.log(123456);
};
setTimeout(() => {
state.projectList = [
{
id: "12",
name: "test项目2",
baseUrl: "test",
remark: "备注备注",
},
{
id: "13",
name: "test项目3",
baseUrl: "test",
remark: "备注备注",
},
{
id: "14",
name: "test项目4",
baseUrl: "test",
remark: "备注备注",
},
{
id: "15",
name: "test项目5",
baseUrl: "test",
remark: "备注备注",
},
{
id: "16",
name: "test项目6",
baseUrl: "test",
remark: "备注备注",
},
{
id: "17",
name: "test项目7",
baseUrl: "test",
remark: "备注备注",
},
];
});
return {
...toRefs(state),
editFn,
deleteFn,
addFn,
};
},
components: {
AddButton,
},
});
</script>
<style lang="scss">
.project {
.el-row {
margin-left: 0 !important;
margin-right: 0 !important;
}
.el-card {
margin-bottom: 20px;
}
}
</style>
const { defineConfig } = require("@vue/cli-service");
const AutoImport = require("unplugin-auto-import/webpack");
const Components = require("unplugin-vue-components/webpack");
const { ElementPlusResolver } = require("unplugin-vue-components/resolvers");
module.exports = defineConfig({
transpileDependencies: true,
configureWebpack: {
plugins: [
AutoImport({
resolvers: [ElementPlusResolver()],
}),
Components({
resolvers: [ElementPlusResolver()],
}),
],
},
});
This diff could not be displayed because it is too large.
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!