This commit is contained in:
24kycj
2024-12-09 19:30:07 +08:00
parent 63a507a76e
commit 85e58775bc
3 changed files with 17 additions and 25 deletions
+8 -13
View File
@@ -148,7 +148,9 @@
<el-select @change="changeTemplate" v-model="currentTemplate" placeholder="选择一个标签或点击创建标签">
<el-option v-for="item in templates" :key="item.value" :label="item.label" :value="item.value"> </el-option>
</el-select>
<div @click="openFile" class="work_right_top_file">···</div>
<el-tooltip content="选择更多模版" placement="bottom">
<div @click="openFile" class="work_right_top_file">···</div>
</el-tooltip>
</div>
<div class="work_right_top_add">新建标签</div>
</div>
@@ -211,8 +213,7 @@ const dayjs = require('dayjs')
import fileEmpty from './files/fileEmpty'
import files from './files/file'
const exePath = path.dirname(process.execPath)
// const exePath = process.cwd();
const exePath = !app.isPackaged ? process.cwd() : path.dirname(process.execPath)
export default {
name: 'UserInfo',
components: { fileEmpty, files },
@@ -742,20 +743,14 @@ export default {
// 选择模板
changeTemplate(e) {
let that = this
const absolutePath = path.resolve(e)
fs.realpath(absolutePath, (err, fullPath) => {
if (err) {
console.error(err)
return
}
that.form.json_file = fullPath
})
fs.readFile(e, 'utf8', (err, data) => {
const fullPath = path.join(exePath, e)
that.form.json_file = fullPath
fs.readFile(fullPath, 'utf8', (err, data) => {
if (err) {
console.error('读取文件时出错:', err)
return
}
let name = e.split('\\')[1]
let name = path.basename(fullPath)
that.fileLists[0] = new File([data], name, {
type: ''
})