Skip to content

Commit

Permalink
新增创建项目功能
Browse files Browse the repository at this point in the history
  • Loading branch information
duolabmeng6 committed Dec 9, 2023
1 parent dd473d8 commit 5304ec3
Show file tree
Hide file tree
Showing 18 changed files with 639 additions and 105 deletions.
Binary file added GoEasyDesigner/TemplateProject/newWindow.zip
Binary file not shown.
46 changes: 43 additions & 3 deletions GoEasyDesigner/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,8 @@ func (a *App) E创建函数(窗口事件文件路径 string, 插入函数 string
myfunc.E发送跳转代码到ide(插件URL地址, 窗口事件文件路径, 跳转位置)
return "保存成功"
}
func (a *App) E发送跳转代码到ide(插件URL地址 string, 窗口事件文件路径 string, 跳转位置 int) string {
myfunc.E发送跳转代码到ide(插件URL地址, 窗口事件文件路径, 跳转位置)
return "发送跳转代码"
func (a *App) E发送跳转代码到ide(插件URL地址 string, 窗口事件文件路径 string, 跳转位置 int) bool {
return myfunc.E发送跳转代码到ide(插件URL地址, 窗口事件文件路径, 跳转位置)
}

func (a *App) E打开文件对话框() string {
Expand Down Expand Up @@ -195,3 +194,44 @@ func (a *App) E清空文件监视() string {
a.文件监视.E清空()
return "清空文件监视"
}

func (a *App) E打开选择文件夹对话框() string {
println("E打开选择文件夹对话框")
result, err := runtime.OpenDirectoryDialog(a.ctx, runtime.OpenDialogOptions{
Title: "选择文件夹",
})
if err != nil {
return ""
}
return result
}
func (a *App) E取当前目录() string {
return ecore.E取当前目录()
}

func (a *App) E下载github项目(github项目地址 string, 保存目录 string) string {
err := mymodel.E下载github项目(github项目地址, 保存目录)
if err != nil {
return err.Error()
}

return "success"
}

func (a *App) E文件是否存在(路径 string) bool {
return ecore.E文件是否存在(路径)
}

func (a *App) E搜索文件(路径 string, 文件名 string) []string {
//func E文件枚举(欲寻找的目录 string, 欲寻找的文件名 string, files *[]string, 是否带路径 bool, 是否遍历子目录 bool) error {
var files []string
ecore.E文件枚举(路径, 文件名, &files, true, true)
//for _, v := range files {
// println(v)
//}
return files
}

func (a *App) E取运行目录() string {
return ecore.E取运行目录()
}
29 changes: 29 additions & 0 deletions GoEasyDesigner/frontend/src/action/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,35 @@ appAction.init = function () {
store = useAppStore()
t = useI18n().t
}
appAction.新建项目 = function () {
store.显示新建项目对话框 = true

}
appAction.打开项目 = async function () {
const result = await goFc.E打开选择文件夹对话框();
if (result === "") {
//弹出饿了么信息框 提示创建失败
ElMessage({
message: '未选择项目目录',
type: 'error',
});
return false
}

let files = await goFc.E搜索文件(result,"design.json")
if (files.length === 0){
//弹出饿了么信息框 提示创建失败
ElMessage({
message: '项目目录下没有找到design.json文件',
type: 'error',
});
return false
}
console.log("搜索文件",files)
appAction._打开文件加载界面(files[0])
return true

}

appAction.新建 = function () {
function 创建窗口() {
Expand Down
42 changes: 41 additions & 1 deletion GoEasyDesigner/frontend/src/app11.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
default-expand-all
style="width: 100%;"
@node-click="data=>组件树选中(data)"
:filter-node-method="filterNodeMethod"
filterable
/>

</div>
Expand Down Expand Up @@ -167,6 +169,16 @@
<el-row>
<el-col :span="20">
<t-dropdown :options="[
{
content: $t('app.NewProject') ,
value: 6,
onClick: () => appAction.新建项目(),
},
{
content: $t('app.OpenProject') ,
value: 7,
onClick: () => appAction.打开项目(),
},
{
content: $t('app.new') ,
value: 1,
Expand Down Expand Up @@ -255,13 +267,14 @@
<component is="项目配置对话框" v-model="store.显示项目配置对话框" @确定="store.显示项目配置对话框=false"
@关闭="store.显示项目配置对话框=false"></component>

<component is="新建项目对话框" v-model="store.显示新建项目对话框" @关闭="store.显示新建项目对话框=false"></component>

</template>

<script setup>
import {inject, nextTick, onMounted, ref, watch} from 'vue';
import {useAppStore} from '@/stores/appStore'
import {ElMessage} from "element-plus";
import {ElMessage, ElMessageBox} from "element-plus";
import {Help, Key, Switch} from "@element-plus/icons-vue";
import {appAction} from '@/action/app.js';
Expand Down Expand Up @@ -373,6 +386,7 @@ watch(BoxActiveName, function BoxActiveNameChange() {
})
onMounted(async () => {
store.scrollContainer = scrollContainer.value;
appAction.init()
Expand Down Expand Up @@ -416,6 +430,31 @@ onMounted(async () => {
if (localStorage.getItem("BoxActiveName")) {
BoxActiveName.value = localStorage.getItem("BoxActiveName")
}
// 检查是否打开了项目
if (appAction.store.项目信息.项目根目录 == "" && store.客户端模式 == true){
ElMessageBox.confirm('当前还没有创建项目或者打开项目', '提示', {
confirmButtonText: '新建项目',
cancelButtonText: '打开项目',
showCancelButton: true,
showClose: true,
type: 'warning',
distinguishCancelAndClose: true,
closeOnClickModal: false, // Add this line
}).then(() => {
console.log('新建项目');
appAction.store.显示新建项目对话框 = true
}).catch(action => {
if (action === 'cancel') {
console.log('打开项目');
appAction.打开项目()
} else if (action === 'close') {
console.log('取消');
}
});
}
})
function init_tailwindcss() {
Expand Down Expand Up @@ -757,6 +796,7 @@ store.rightClickMenus = {
]
}
const filterNodeMethod = (value, data) => data.label.toLowerCase().includes(value.toLowerCase())
</script>

<style>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<el-form-item :label="$t('attr.name')" >
<el-form-item :label="$t('attr.name')">
<el-input v-model="props.item.name"/>
<div v-if="是否存在" style="color:red">名称已存在</div>
</el-form-item>
<el-form-item :label="$t('attr.top')">
<el-autocomplete
Expand All @@ -12,7 +13,7 @@
@select="handleSelect"
/>
</el-form-item>
<el-form-item :label="$t('attr.left')">
<el-form-item :label="$t('attr.left')">
<el-autocomplete
v-model="props.item.left"
:fetch-suggestions="querySearch"
Expand All @@ -32,7 +33,7 @@
@select="handleSelect"
/>
</el-form-item>
<el-form-item :label="$t('attr.bottom')">
<el-form-item :label="$t('attr.bottom')">
<el-autocomplete
v-model="props.item.bottom"
:fetch-suggestions="querySearch"
Expand All @@ -42,7 +43,7 @@
@select="handleSelect"
/>
</el-form-item>
<el-form-item :label="$t('attr.width')">
<el-form-item :label="$t('attr.width')">
<el-autocomplete
v-model="props.item.width"
:fetch-suggestions="querySearch"
Expand All @@ -62,24 +63,24 @@
@select="handleSelect"
/>
</el-form-item>
<el-form-item :label="$t('attr.zIndex')">
<el-form-item :label="$t('attr.zIndex')">
<el-input v-model="props.item.zIndex"/>
</el-form-item>
<el-form-item :label="$t('attr.disable')">
<el-form-item :label="$t('attr.disable')">
<el-switch v-model="props.item.disable"/>
</el-form-item>
<el-form-item :label="$t('attr.visible')">
<el-form-item :label="$t('attr.visible')">
<el-switch v-model="props.item.visible"/>
</el-form-item>
<el-form-item :label="$t('attr.backgroundColor')">
<el-form-item :label="$t('attr.backgroundColor')">
<el-color-picker v-model="props.item.background" show-alpha
@active-change="val => props.item.background = val"/>
</el-form-item>
<el-form-item :label="$t('attr.backgroundImage')">
<input ref="fileInput" type="file" style="display: none" @change="handleFileChange"/>
<!-- <el-input v-model="props.item.图片"/>-->
<el-button @click="triggerFileInput">{{$t('app.selectImage')}}</el-button>
<el-button v-show="props.item.图片" @click="clearImage">{{$t('app.clear')}}</el-button>
<el-button @click="triggerFileInput">{{ $t('app.selectImage') }}</el-button>
<el-button v-show="props.item.图片" @click="clearImage">{{ $t('app.clear') }}</el-button>
</el-form-item>
<el-form-item label="图片平铺方式" v-show="props.item.图片">
<el-select v-model="props.item.backgroundRepeat" style="width: 100%">
Expand Down Expand Up @@ -122,10 +123,10 @@
</el-select>
</el-form-item>

<el-form-item :label="$t('attr.border')">
<el-form-item :label="$t('attr.border')">
<el-input v-model="props.item.border"/>
</el-form-item>
<el-form-item :label="$t('attr.fontSize')">
<el-form-item :label="$t('attr.fontSize')">
<el-input v-model="props.item.fontSize"/>
</el-form-item>

Expand All @@ -139,7 +140,7 @@
/>
</el-select>
</el-form-item>
<el-form-item :label="$t('attr.xAxisRollingMode')">
<el-form-item :label="$t('attr.xAxisRollingMode')">
<el-select v-model="props.item.overflowX" style="width: 100%">
<el-option
v-for="(item, index) in overflowX"
Expand All @@ -151,10 +152,16 @@
</el-form-item>

</template>

<script setup>
import {defineProps, onMounted, ref} from "vue";
import {defineProps, onMounted, ref, watch} from "vue";
import {useAppStore} from '@/stores/appStore'
const props = defineProps(['item']);
const store = useAppStore()
const handleSelect = (item) => {
console.log(item)
}
Expand Down Expand Up @@ -259,7 +266,6 @@ const clearImage = () => {
}
onMounted(() => {
if (localStorage.getItem("locale") === "English") {
overflowX.value.forEach((item) => {
Expand All @@ -283,13 +289,39 @@ onMounted(() => {
}
});
// watch(()=>props.item.name, (newVal, oldVal) => {
// if (newVal !== oldVal) {
// //检查新值是否已经存在
// let 是否存在 = store.递归查找名称(store.list, newVal)
// console.log("是否存在", 是否存在,newVal)
//
// console.log("刷新")
// store.取组件列表()
//
//
// }
// });
const 是否存在 = ref(false);
let n = store.递归查找名称数量(store.list, props.item.name);
是否存在.value = n >= 2;
watch(() => props.item.name, (newVal, oldVal) => {
if (newVal !== oldVal) {
let n = store.递归查找名称数量(store.list, newVal);
是否存在.value = n >= 2;
console.log("是否存在", 是否存在.value, newVal);
console.log("刷新");
store.取组件列表();
}
});
</script>

<style>
.el-form-item__label{
width:inherit !important;
min-width:100px !important;
.el-form-item__label {
width: inherit !important;
min-width: 100px !important;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function searchAndJumpToText(searchText) {
if (match) {
const lineNumber = match.range.startLineNumber;
editor.revealLineInCenter(lineNumber); // 将匹配的行居中显示
editor.setPosition({lineNumber: lineNumber + 3, column: 16});
editor.setPosition({lineNumber: lineNumber + 2, column: 16});
} else {
console.log('未找到匹配的文本');
}
Expand Down
Loading

0 comments on commit 5304ec3

Please sign in to comment.