// noinspection JSXNamespaceValidation
const Nano = require('nano-jsx')
const fetch = require('node-fetch')
const { Fragment, jsx } = require('nano-jsx')
const { PureCss, CustomCss } = require('./css')
const SettingUI = () => {
let submit = async event => {
utools.dbStorage.setItem("username", document.getElementById('username').value)
utools.dbStorage.setItem("password", document.getElementById('password').value)
utools.showNotification('保存成功')
}
return jsx`
<${Fragment}>
<head>
<title>Setting</title>
<style>${PureCss}</style>
<style>${CustomCss}</style>
<script src="index.js"/>
</head>
<body>
<div id="root"/>
<form id="setting" class="pure-form pure-form-stacked">
<fieldset>
<legend>用户设置</legend>
<label for="stacked-email">邮箱</label>
<input id="username" class="pure-input-1" placeholder="请输入邮箱" />
<label for="stacked-password">密码</label>
<input id="password" class="pure-input-1" placeholder="请输入密码" />
<div class="form-button-group">
<button type="submit" class="pure-button pure-button-primary" onclick=${event => submit(event)}>保存</button>
<button class="pure-button" onclick=${event => utools.outPlugin()}>取消</button>
</div>
</fieldset>
</form>
</body>
</${Fragment}>`
}
window.exports = {
'setting': {
args: {
enter(action, callback) {
utools.setExpendHeight(480)
Nano.render(jsx`${SettingUI}`, document.documentElement)
document.getElementById('username').value = utools.dbStorage.getItem("username")
document.getElementById('password').value = utools.dbStorage.getItem("password")
}
},
mode: 'none'
},
'index': {
args: {
enter(action, callback) {
document.getElementById('setting')?.remove()
callback([
{
title: '新建工单',
description: '默认科室信息科',
icon: 'logo.png'
}
])
},
search: (action, searchWord, callbackSetList) => {
// 获取一些数据
// 执行 callbackSetList 显示出来
callbackSetList([
{
title: '新建工单',
description: '默认科室信息科',
icon: 'logo.png',
text: searchWord
}
])
},
select: async (action, itemData, callbackSetList) => {
console.log(fetch) //Module
fetch("http://xxxx") //报错fetch not a fun
},
placeholder: "新建工单"
},
mode: 'list'
}
}