test: 替换弹窗为独立窗口
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
"$schema": "../gen/schemas/desktop-schema.json",
|
||||
"identifier": "default",
|
||||
"description": "enables the default permissions",
|
||||
"windows": ["main"],
|
||||
"windows": ["*"],
|
||||
"permissions": [
|
||||
"core:default",
|
||||
"core:window:default",
|
||||
@@ -28,6 +28,14 @@
|
||||
"core:window:allow-set-always-on-top",
|
||||
"core:window:allow-set-always-on-bottom",
|
||||
"core:window:allow-unmaximize",
|
||||
"core:window:allow-unminimize"
|
||||
"core:window:allow-unminimize",
|
||||
"core:window:allow-center",
|
||||
"core:window:allow-request-user-attention",
|
||||
"core:window:allow-set-decorations",
|
||||
"core:window:allow-set-resizable",
|
||||
"core:window:allow-set-skip-taskbar",
|
||||
"core:webview:allow-set-webview-position",
|
||||
"core:webview:allow-set-webview-size",
|
||||
"core:window:allow-create"
|
||||
]
|
||||
}
|
||||
|
55
src/utils/tauriWindow.ts
Normal file
55
src/utils/tauriWindow.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import { WebviewWindow } from '@tauri-apps/api/webviewWindow'
|
||||
|
||||
/**
|
||||
* 打开新的页面功能
|
||||
* @param label 新打开页面的标签
|
||||
* @param options 新页面配置项
|
||||
*/
|
||||
export const newWindow = async (
|
||||
label: string,
|
||||
options: any
|
||||
) => {
|
||||
const webview = new WebviewWindow(`${label}`, {
|
||||
...options
|
||||
})
|
||||
webview.once('tauri://created', async function () {
|
||||
console.log(`${label}创建成功`)
|
||||
})
|
||||
webview.once('tauri://error', function (e) {
|
||||
console.log(e)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建 Excel 编辑窗口
|
||||
* @param id Excel 记录 ID
|
||||
* @param name Excel 名称
|
||||
*/
|
||||
export const createEditWindow = async (id: number, name: string) => {
|
||||
await newWindow(`excel-edit-${id}`, {
|
||||
url: `/wps/xlsx?id=${id}&mode=edit`,
|
||||
title: `编辑 Excel - ${name}`,
|
||||
width: 900,
|
||||
height: 650,
|
||||
resizable: true,
|
||||
decorations: true,
|
||||
center: true,
|
||||
visible: true
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建通用 Excel 窗口
|
||||
*/
|
||||
export const createExcelWindow = async () => {
|
||||
await newWindow('excel-main', {
|
||||
url: '/wps/xlsx',
|
||||
title: 'Excel 数据管理',
|
||||
width: 1000,
|
||||
height: 700,
|
||||
resizable: true,
|
||||
decorations: true,
|
||||
center: true,
|
||||
visible: true
|
||||
})
|
||||
}
|
@@ -9,11 +9,7 @@
|
||||
label-width="110px"
|
||||
>
|
||||
<el-form-item>
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
@click="openForm('create')"
|
||||
>
|
||||
<el-button type="primary" plain @click="openForm('create')">
|
||||
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
||||
</el-button>
|
||||
<el-button type="danger" plain @click="toggleExpandAll">
|
||||
@@ -37,22 +33,12 @@
|
||||
<el-table-column prop="functions" label="方法名称" />
|
||||
<el-table-column prop="parameter" label="方法参数" />
|
||||
<el-table-column prop="chineseName" label="中文描述" />
|
||||
<el-table-column label="操作" align="center" width="150">
|
||||
<el-table-column label="操作" align="center" width="200">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
@click="openForm('update', scope.row.id)"
|
||||
>
|
||||
<el-button link type="primary" @click="openIndependentWindow(scope.row)">
|
||||
修改
|
||||
</el-button>
|
||||
<el-button
|
||||
link
|
||||
type="danger"
|
||||
@click="handleDelete(scope.row.id)"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
<el-button link type="danger" @click="handleDelete(scope.row.id)"> 删除 </el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -63,12 +49,10 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import { handleTree } from '@/utils/tree'
|
||||
import * as XlsxApi from '@/api/wps/xlsx'
|
||||
import XlsxForm from './XlsxForm.vue'
|
||||
|
||||
import { newWindow } from '@/utils/tauriWindow'
|
||||
|
||||
defineOptions({ name: 'WpsXlsx' })
|
||||
|
||||
@@ -138,6 +122,27 @@ const handleDelete = async (id: number) => {
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 打开独立窗口 */
|
||||
const openIndependentWindow = async (row: any) => {
|
||||
try {
|
||||
// 直接使用 newWindow 方法创建独立窗口
|
||||
await newWindow(`excel-edit-${row.id}`, {
|
||||
url: `/wps/xlsx?id=${row.id}&mode=edit`,
|
||||
title: `编辑 Excel - ${row.name}`,
|
||||
width: 900,
|
||||
height: 650,
|
||||
resizable: true,
|
||||
decorations: true,
|
||||
center: true,
|
||||
visible: true
|
||||
})
|
||||
message.success(`独立窗口已打开: ${row.name}`)
|
||||
} catch (error) {
|
||||
console.error('打开独立窗口失败:', error)
|
||||
message.error('打开独立窗口失败')
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(async () => {
|
||||
await getList()
|
||||
|
Reference in New Issue
Block a user