Compare commits
4 Commits
ed9f3d4189
...
daaddfaaf2
Author | SHA1 | Date |
---|---|---|
lyc | daaddfaaf2 | |
lyc | 5fea7e094d | |
lyc | e221bedb81 | |
lyc | 0ec1a7327a |
|
@ -1,3 +1,3 @@
|
||||||
provider: generic
|
provider: generic
|
||||||
url: https://example.com/auto-updates
|
url: http://localhost:3000/
|
||||||
updaterCacheDirName: electron-app-updater
|
updaterCacheDirName: electron-app-updater
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
appId: com.electron.app
|
||||||
|
productName: AIx
|
||||||
|
directories:
|
||||||
|
buildResources: build
|
||||||
|
files:
|
||||||
|
- '!**/.vscode/*'
|
||||||
|
- '!src/*'
|
||||||
|
- '!electron.vite.config.{js,ts,mjs,cjs}'
|
||||||
|
- '!{.eslintignore,.eslintrc.cjs,.prettierignore,.prettierrc.yaml,dev-app-update.yml,CHANGELOG.md,README.md}'
|
||||||
|
- '!{.env,.env.*,.npmrc,pnpm-lock.yaml}'
|
||||||
|
asarUnpack:
|
||||||
|
- resources/**
|
||||||
|
win:
|
||||||
|
executableName: AIx
|
||||||
|
icon: resources/logo.ico
|
||||||
|
nsis:
|
||||||
|
oneClick: false
|
||||||
|
allowToChangeInstallationDirectory: true
|
||||||
|
artifactName: ${name}-${version}-setup.${ext}
|
||||||
|
shortcutName: ${productName}
|
||||||
|
uninstallDisplayName: ${productName}
|
||||||
|
createDesktopShortcut: always
|
||||||
|
mac:
|
||||||
|
entitlementsInherit: build/entitlements.mac.plist
|
||||||
|
extendInfo:
|
||||||
|
- NSCameraUsageDescription: Application requests access to the device's camera.
|
||||||
|
- NSMicrophoneUsageDescription: Application requests access to the device's microphone.
|
||||||
|
- NSDocumentsFolderUsageDescription: Application requests access to the user's Documents folder.
|
||||||
|
- NSDownloadsFolderUsageDescription: Application requests access to the user's Downloads folder.
|
||||||
|
notarize: false
|
||||||
|
dmg:
|
||||||
|
artifactName: ${name}-${version}.${ext}
|
||||||
|
linux:
|
||||||
|
target:
|
||||||
|
- AppImage
|
||||||
|
- snap
|
||||||
|
- deb
|
||||||
|
maintainer: electronjs.org
|
||||||
|
category: Utility
|
||||||
|
appImage:
|
||||||
|
artifactName: ${name}-${version}.${ext}
|
||||||
|
npmRebuild: false
|
||||||
|
publish:
|
||||||
|
provider: generic
|
||||||
|
url: http://localhost:3000
|
||||||
|
electronDownload:
|
||||||
|
mirror: https://npmmirror.com/mirrors/electron/
|
|
@ -12,6 +12,7 @@ asarUnpack:
|
||||||
- resources/**
|
- resources/**
|
||||||
win:
|
win:
|
||||||
executableName: AIx
|
executableName: AIx
|
||||||
|
icon: resources/logo.ico
|
||||||
nsis:
|
nsis:
|
||||||
oneClick: false
|
oneClick: false
|
||||||
allowToChangeInstallationDirectory: true
|
allowToChangeInstallationDirectory: true
|
||||||
|
@ -41,6 +42,6 @@ appImage:
|
||||||
npmRebuild: false
|
npmRebuild: false
|
||||||
publish:
|
publish:
|
||||||
provider: generic
|
provider: generic
|
||||||
url: https://example.com/auto-updates
|
url: https://file.ysaix.com:7868/src/assets/smarttalk/
|
||||||
electronDownload:
|
electronDownload:
|
||||||
mirror: https://npmmirror.com/mirrors/electron/
|
mirror: https://npmmirror.com/mirrors/electron/
|
||||||
|
|
|
@ -13,7 +13,8 @@
|
||||||
"build": "electron-vite build",
|
"build": "electron-vite build",
|
||||||
"postinstall": "electron-builder install-app-deps",
|
"postinstall": "electron-builder install-app-deps",
|
||||||
"build:unpack": "npm run build && electron-builder --dir",
|
"build:unpack": "npm run build && electron-builder --dir",
|
||||||
"build:win": "npm run build && electron-builder --win",
|
"build:test": "npm run build && electron-builder --win --config ./electron-builder-test.yml",
|
||||||
|
"build:prod": "npm run build && electron-builder --win --config ./electron-builder.yml",
|
||||||
"build:mac": "npm run build && electron-builder --mac",
|
"build:mac": "npm run build && electron-builder --mac",
|
||||||
"build:linux": "npm run build && electron-builder --linux"
|
"build:linux": "npm run build && electron-builder --linux"
|
||||||
},
|
},
|
||||||
|
@ -24,6 +25,7 @@
|
||||||
"@vueuse/core": "^10.11.0",
|
"@vueuse/core": "^10.11.0",
|
||||||
"crypto-js": "^4.2.0",
|
"crypto-js": "^4.2.0",
|
||||||
"electron-dl-manager": "^3.0.0",
|
"electron-dl-manager": "^3.0.0",
|
||||||
|
"electron-log": "^5.1.7",
|
||||||
"electron-updater": "^6.1.7",
|
"electron-updater": "^6.1.7",
|
||||||
"element-plus": "^2.7.6",
|
"element-plus": "^2.7.6",
|
||||||
"js-cookie": "^3.0.5",
|
"js-cookie": "^3.0.5",
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 264 KiB |
|
@ -3,6 +3,7 @@ import { join } from 'path'
|
||||||
import { electronApp, optimizer, is } from '@electron-toolkit/utils'
|
import { electronApp, optimizer, is } from '@electron-toolkit/utils'
|
||||||
import icon from '../../resources/icon.png?asset'
|
import icon from '../../resources/icon.png?asset'
|
||||||
import File from './file'
|
import File from './file'
|
||||||
|
import updateInit from './update'
|
||||||
|
|
||||||
File({ app, shell, BrowserWindow, ipcMain })
|
File({ app, shell, BrowserWindow, ipcMain })
|
||||||
process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true'
|
process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true'
|
||||||
|
@ -31,13 +32,14 @@ function createLoginWindow() {
|
||||||
loginWindow.loadURL('http://localhost:5173/#/login')
|
loginWindow.loadURL('http://localhost:5173/#/login')
|
||||||
} else {
|
} else {
|
||||||
loginWindow.loadFile(join(__dirname, '../renderer/index.html'), {hash: 'login'})
|
loginWindow.loadFile(join(__dirname, '../renderer/index.html'), {hash: 'login'})
|
||||||
|
updateInit(loginWindow)
|
||||||
}
|
}
|
||||||
|
|
||||||
loginWindow.webContents.openDevTools()
|
// loginWindow.webContents.openDevTools()
|
||||||
loginWindow.once('ready-to-show', () => {
|
loginWindow.once('ready-to-show', () => {
|
||||||
loginWindow.show()
|
loginWindow.show()
|
||||||
})
|
})
|
||||||
|
|
||||||
loginWindow.on('closed', () => {
|
loginWindow.on('closed', () => {
|
||||||
loginWindow = null
|
loginWindow = null
|
||||||
})
|
})
|
||||||
|
@ -114,7 +116,6 @@ async function createLinkWin(data) {
|
||||||
|
|
||||||
// 初始化完成
|
// 初始化完成
|
||||||
app.on('ready', () => {
|
app.on('ready', () => {
|
||||||
|
|
||||||
// 设置应用程序用户模型标识符
|
// 设置应用程序用户模型标识符
|
||||||
electronApp.setAppUserModelId('com.electron')
|
electronApp.setAppUserModelId('com.electron')
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
import { dialog } from 'electron'
|
||||||
|
import logger from 'electron-log'
|
||||||
|
const updateURL = 'http://27.128.240.72:3000/zhuhao/AIx_Smarttalk/releases/tag/V1.0.0%28%E6%B5%8B%E8%AF%95%E7%89%88%29/'
|
||||||
|
|
||||||
|
// 主进程中的更新检查
|
||||||
|
const { autoUpdater } = require('electron-updater')
|
||||||
|
|
||||||
|
const updateInit = (win) => {
|
||||||
|
logger.info('进来了')
|
||||||
|
// 检查更新
|
||||||
|
autoUpdater.checkForUpdates()
|
||||||
|
// 自动下载
|
||||||
|
autoUpdater.autoDownload = false
|
||||||
|
// 设置版本更新服务器地址
|
||||||
|
// autoUpdater.setFeedURL(updateURL)
|
||||||
|
|
||||||
|
//监听更新事件
|
||||||
|
autoUpdater.on('update-available', (info) => {
|
||||||
|
logger.info('发现新版本')
|
||||||
|
dialog
|
||||||
|
.showMessageBox(win,{
|
||||||
|
type: 'info',
|
||||||
|
title: '新版本可用',
|
||||||
|
message: '有一个可用的新版本,要更新吗',
|
||||||
|
buttons: ['是', '否']
|
||||||
|
})
|
||||||
|
.then((result) => {
|
||||||
|
if (result.response === 0) {
|
||||||
|
// 用户选择更新,触发下载和安装
|
||||||
|
autoUpdater.downloadUpdate()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
// 没有新版本
|
||||||
|
autoUpdater.on('update-not-available', () => {
|
||||||
|
logger.info('没有新版本')
|
||||||
|
})
|
||||||
|
|
||||||
|
// 更新发生错误
|
||||||
|
autoUpdater.on('error', () => {
|
||||||
|
logger.error('检查更新失败')
|
||||||
|
})
|
||||||
|
|
||||||
|
// 跟新下载完毕
|
||||||
|
autoUpdater.on('update-downloaded', () => {
|
||||||
|
dialog
|
||||||
|
.showMessageBox({
|
||||||
|
type: 'info',
|
||||||
|
title: '更新下载完成',
|
||||||
|
message: '点击确定重启获取最新内容',
|
||||||
|
buttons: ['确定']
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
// 调用 quitAndInstall 来安装更新
|
||||||
|
autoUpdater.quitAndInstall()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export default updateInit
|
|
@ -4,11 +4,12 @@
|
||||||
<el-form>
|
<el-form>
|
||||||
<el-form-item label="文件">
|
<el-form-item label="文件">
|
||||||
<div class="create-item file-item flex">
|
<div class="create-item file-item flex">
|
||||||
<el-upload :file-list="fileList" :show-file-list="false" :auto-upload="false" multiple
|
<el-upload :file-list="fileList" :limit="limit" :show-file-list="false" :auto-upload="false" multiple
|
||||||
:on-change="hanleFileChange">
|
:on-change="hanleFileChange">
|
||||||
<el-button slot="trigger">选择文件</el-button>
|
<el-button slot="trigger">选择文件</el-button>
|
||||||
</el-upload>
|
</el-upload>
|
||||||
<span class="upload-desc">说明:一次最多上传5个文件,单个文件大小不能大于100M</span>
|
<span class="upload-desc">说明:一次最多上传{{ limit }}个文件,单个文件大小不能大于100M</span>
|
||||||
|
<span class="upload-desc">仅支持图片、音频、视频、word、ppt、pdf、txt、zip文件</span>
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
|
@ -16,14 +17,15 @@
|
||||||
<div class="file-list-item flex" v-for="(item, index) in fileList" :key="item.uid">
|
<div class="file-list-item flex" v-for="(item, index) in fileList" :key="item.uid">
|
||||||
<div class="file-name">
|
<div class="file-name">
|
||||||
<span class="name">标题:</span>
|
<span class="name">标题:</span>
|
||||||
<FileImage :fileName="item.name" :size="50"/>
|
<FileImage :fileName="item.name" :size="50" />
|
||||||
<el-input class="file-input" v-model="item.fileData.name" placeholder="请输入文件名" />
|
<el-input class="file-input" v-model="item.fileData.name" placeholder="请输入文件名" />
|
||||||
<span>.{{ getFileSuffix(item.name) }}</span>
|
<span>.{{ getFileSuffix(item.name) }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-type flex">
|
<div class="flex-type flex">
|
||||||
<span class="name">类别:</span>
|
<span class="name">类别:</span>
|
||||||
<el-select v-model="item.fileData.fileFlag" placeholder="Select" style="width: 100px">
|
<el-select v-model="item.fileData.fileFlag" placeholder="Select" style="width: 100px">
|
||||||
<el-option v-for="item in resourceType" :key="item.alue" :label="item.label" :value="item.value" />
|
<el-option v-for="el in resourceType" :key="el.alue" :label="el.label" :value="el.value"
|
||||||
|
:disabled="checkFile(el, item)" />
|
||||||
</el-select>
|
</el-select>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -58,6 +60,7 @@ const props = defineProps({
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
const dialogValue = ref(false)
|
const dialogValue = ref(false)
|
||||||
|
const limit = ref(5)
|
||||||
// 定义要发送的emit事件
|
// 定义要发送的emit事件
|
||||||
const emit = defineEmits(['update:modelValue', 'submitFile'])
|
const emit = defineEmits(['update:modelValue', 'submitFile'])
|
||||||
// 文件列表
|
// 文件列表
|
||||||
|
@ -68,7 +71,7 @@ watch(() => props.modelValue, (newVal) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
const hanleFileChange = (file) => {
|
const hanleFileChange = (file) => {
|
||||||
console.log(file)
|
console.log(file)
|
||||||
|
|
||||||
//音频 类型
|
//音频 类型
|
||||||
const audioTypes = ['audio/mpeg', 'audio/wav', 'audio/ogg', 'audio/aac']
|
const audioTypes = ['audio/mpeg', 'audio/wav', 'audio/ogg', 'audio/aac']
|
||||||
|
@ -81,9 +84,9 @@ const hanleFileChange = (file) => {
|
||||||
// pdf 类型
|
// pdf 类型
|
||||||
const pdfTypes = ['application/pdf']
|
const pdfTypes = ['application/pdf']
|
||||||
// zip 类型
|
// zip 类型
|
||||||
const zipTypes = ['application/x-zip-compressed','application/x-compressed']
|
const zipTypes = ['application/x-zip-compressed', 'application/x-compressed']
|
||||||
// 图片 类型
|
// 图片 类型
|
||||||
const imgTypes = ['image/jpeg','image/gif', 'image/png']
|
const imgTypes = ['image/jpeg', 'image/gif', 'image/png']
|
||||||
// text 类型
|
// text 类型
|
||||||
const textTypes = ['text/plain']
|
const textTypes = ['text/plain']
|
||||||
|
|
||||||
|
@ -93,22 +96,39 @@ const hanleFileChange = (file) => {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// 验证文件大小
|
// 验证文件大小
|
||||||
|
// B < KB < MB < GB
|
||||||
|
// file.raw.size 单位是B
|
||||||
const fileSize = file.raw.size / 1024 / 1024 > 100
|
const fileSize = file.raw.size / 1024 / 1024 > 100
|
||||||
if (fileSize) {
|
if (fileSize) {
|
||||||
ElMessage.error('文件大小错误! 请上传小于100M的文件!')
|
ElMessage.error('文件大小错误! 请上传小于100M的文件!')
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if (file.status === 'ready') {
|
if (file.status === 'ready') {
|
||||||
|
|
||||||
// 给一个默认的fileData
|
// 给一个默认的fileData
|
||||||
file.fileData = {
|
file.fileData = {
|
||||||
fileFlag: '课件',
|
fileFlag: '素材',
|
||||||
name: getFileName(file.name),
|
name: getFileName(file.name),
|
||||||
}
|
}
|
||||||
fileList.value.push(file)
|
fileList.value.push(file)
|
||||||
|
console.log(fileList.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查文件类型
|
||||||
|
const checkFile = (item, file) => {
|
||||||
|
const type = file.raw.type
|
||||||
|
const pptTypes = ['application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.presentationml.presentation']
|
||||||
|
let isPpt = pptTypes.includes(type)
|
||||||
|
if(!isPpt && item.value == '教案'){
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// 删除
|
// 删除
|
||||||
const delFile = (index) => {
|
const delFile = (index) => {
|
||||||
fileList.value.splice(index, 1)
|
fileList.value.splice(index, 1)
|
||||||
|
@ -133,7 +153,7 @@ const submitFile = () => {
|
||||||
item.fileData.fileShowName = item.fileData.name + '.' + suffix
|
item.fileData.fileShowName = item.fileData.name + '.' + suffix
|
||||||
delete item.fileData.name
|
delete item.fileData.name
|
||||||
})
|
})
|
||||||
emit('submitFile',fileList.value)
|
emit('submitFile', fileList.value)
|
||||||
closeDialog()
|
closeDialog()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,24 +223,28 @@ const submitFile = () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.file-input {
|
.file-input {
|
||||||
border-bottom: solid #dfdfdf 1px;
|
border-bottom: solid #dfdfdf 1px;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
border-color: #409EFF;
|
border-color: #409EFF;
|
||||||
}
|
}
|
||||||
&:focus{
|
|
||||||
|
&:focus {
|
||||||
border-color: #409EFF;
|
border-color: #409EFF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.el-input__wrapper){
|
:deep(.el-input__wrapper) {
|
||||||
box-shadow: none
|
|
||||||
}
|
|
||||||
:deep(.el-input__wrapper.is-focus){
|
|
||||||
box-shadow: none
|
|
||||||
}
|
|
||||||
:deep(.el-input__wrapper:hover){
|
|
||||||
box-shadow: none
|
box-shadow: none
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:deep(.el-input__wrapper.is-focus) {
|
||||||
|
box-shadow: none
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-input__wrapper:hover) {
|
||||||
|
box-shadow: none
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -71,7 +71,6 @@ const submitFile = (data) => {
|
||||||
item.fileData = fileData
|
item.fileData = fileData
|
||||||
item.callback = fileCallBack
|
item.callback = fileCallBack
|
||||||
})
|
})
|
||||||
// console.log(fileList)
|
|
||||||
uploaderState().pushFile(fileList)
|
uploaderState().pushFile(fileList)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue