Compare commits
No commits in common. "b1407706a8e298d9b8985fa2115c9114f98c7f3d" and "45315333828c7f0219e941fbe78f6b38a145b468" have entirely different histories.
b1407706a8
...
4531533382
25
.env.yc
25
.env.yc
|
@ -1,25 +0,0 @@
|
|||
# 页面标题
|
||||
VITE_APP_TITLE = 文枢课堂
|
||||
|
||||
# 生产环境配置
|
||||
VITE_APP_ENV = 'production'
|
||||
|
||||
# AIx融合数字管理系统/生产环境
|
||||
VITE_APP_BASE_API = 'https://prev.ysaix.com:7868/prod-api'
|
||||
|
||||
VITE_APP_DOMAIN = 'prev.ysaix.com'
|
||||
|
||||
VITE_APP_UPLOAD_API = 'https://prev.ysaix.com:7868/prod-api'
|
||||
|
||||
# 是否在打包时开启压缩,支持 gzip 和 brotli
|
||||
VITE_BUILD_COMPRESS = gzip
|
||||
|
||||
VITE_APP_RES_FILE_PATH = 'https://prev.ysaix.com:7868/src/assets/textbook/booktxt/'
|
||||
|
||||
VITE_APP_BUILD_BASE_PATH = 'https://prev.ysaix.com:7868/'
|
||||
|
||||
# websocket 地址
|
||||
VITE_APP_WS_URL = 'wss://prev.ysaix.com:7868'
|
||||
|
||||
# 是否显示开发工具
|
||||
VITE_SHOW_DEV_TOOLS = 'false'
|
25
.env.yc2
25
.env.yc2
|
@ -1,25 +0,0 @@
|
|||
# 页面标题
|
||||
VITE_APP_TITLE = 实训教学
|
||||
|
||||
# 生产环境配置
|
||||
VITE_APP_ENV = 'production'
|
||||
|
||||
# AIx融合数字管理系统/生产环境
|
||||
VITE_APP_BASE_API = 'https://prev.ysaix.com:7868/prod-api'
|
||||
|
||||
VITE_APP_DOMAIN = 'prev.ysaix.com'
|
||||
|
||||
VITE_APP_UPLOAD_API = 'https://prev.ysaix.com:7868/prod-api'
|
||||
|
||||
# 是否在打包时开启压缩,支持 gzip 和 brotli
|
||||
VITE_BUILD_COMPRESS = gzip
|
||||
|
||||
VITE_APP_RES_FILE_PATH = 'https://prev.ysaix.com:7868/src/assets/textbook/booktxt/'
|
||||
|
||||
VITE_APP_BUILD_BASE_PATH = 'https://prev.ysaix.com:7868/'
|
||||
|
||||
# websocket 地址
|
||||
VITE_APP_WS_URL = 'wss://prev.ysaix.com:7868'
|
||||
|
||||
# 是否显示开发工具
|
||||
VITE_SHOW_DEV_TOOLS = 'false'
|
|
@ -1,54 +0,0 @@
|
|||
appId: com.electron.app.yc
|
||||
productName: 文枢课堂
|
||||
directories:
|
||||
output: dist
|
||||
buildResources: build
|
||||
win:
|
||||
executableName: 文枢课堂
|
||||
icon: resources/yc-logo.png
|
||||
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/**
|
||||
nsis:
|
||||
oneClick: false
|
||||
allowToChangeInstallationDirectory: true
|
||||
artifactName: ${name}-yc-${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: https://prev.ysaix.com:7868/src/assets/smarttalkyc/
|
||||
electronDownload:
|
||||
mirror: https://npmmirror.com/mirrors/electron/
|
||||
# 额外依赖打包到输出目录
|
||||
extraFiles:
|
||||
- from: ./node_modules/im_electron_sdk/lib/
|
||||
to: ./resources
|
||||
filter:
|
||||
- '**/*'
|
|
@ -1,54 +0,0 @@
|
|||
appId: com.electron.app.yc2
|
||||
productName: 实训教学
|
||||
directories:
|
||||
output: dist
|
||||
buildResources: build
|
||||
win:
|
||||
executableName: 实训教学
|
||||
icon: resources/yc-logo.png
|
||||
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/**
|
||||
nsis:
|
||||
oneClick: false
|
||||
allowToChangeInstallationDirectory: true
|
||||
artifactName: ${name}-ycsx-${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: https://prev.ysaix.com:7868/src/assets/smarttalkycsx/
|
||||
electronDownload:
|
||||
mirror: https://npmmirror.com/mirrors/electron/
|
||||
# 额外依赖打包到输出目录
|
||||
extraFiles:
|
||||
- from: ./node_modules/im_electron_sdk/lib/
|
||||
to: ./resources
|
||||
filter:
|
||||
- '**/*'
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "aix-win-ws",
|
||||
"version": "2.5.8",
|
||||
"version": "2.5.7",
|
||||
"description": "",
|
||||
"main": "./out/main/index.js",
|
||||
"author": "上海交大重庆人工智能研究院",
|
||||
|
@ -16,8 +16,6 @@
|
|||
"build:dev": "npm run build && electron-builder --win --config ./electron-builder-test.yml",
|
||||
"build:test": "electron-vite build --mode test && electron-builder --win --config ./electron-builder.yml",
|
||||
"build:prod": "electron-vite build --mode production && electron-builder --win --config ./electron-builder-prod.yml",
|
||||
"build:yc": "electron-vite build --mode yc && electron-builder --win --config ./electron-builder-yc.yml",
|
||||
"build:yc2": "electron-vite build --mode yc2 && electron-builder --win --config ./electron-builder-yc2.yml",
|
||||
"build:lt": "electron-vite build --mode lt && electron-builder --win --config ./electron-builder-lt.yml",
|
||||
"build:mac": "electron-vite build --mode production && electron-builder --mac --config ./electron-builder-prod.yml",
|
||||
"build:linux": "npm run build && electron-builder --linux"
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 51 KiB |
|
@ -7,7 +7,6 @@ import Logger from './logger' // 日志封装
|
|||
import chat from './chat' // chat封装
|
||||
import Store from './store' // Store封装
|
||||
import updateInit from './update'
|
||||
|
||||
// 代理 electron/remote
|
||||
// 第一步:引入remote
|
||||
import remote from '@electron/remote/main'
|
||||
|
@ -42,19 +41,19 @@ if(!gotTheLock){
|
|||
}
|
||||
})
|
||||
}
|
||||
let logoIco = import.meta.env.MODE==='yc'||import.meta.env.MODE==='yc2'?'../../resources/yc-logo.png':'../../resources/logo2.ico'
|
||||
|
||||
//登录窗口
|
||||
function createLoginWindow() {
|
||||
if (loginWindow) return
|
||||
loginWindow = new BrowserWindow({
|
||||
width: import.meta.env.MODE==='yc'||import.meta.env.MODE==='yc2'?1060:888,
|
||||
width: 888,
|
||||
height: 520,
|
||||
show: false,
|
||||
frame: false,
|
||||
autoHideMenuBar: true,
|
||||
maximizable: false,
|
||||
resizable: false,
|
||||
icon: join(__dirname, logoIco),
|
||||
icon: join(__dirname, '../../resources/logo2.ico'),
|
||||
...(process.platform === 'linux' ? { icon } : {}),
|
||||
webPreferences: {
|
||||
defaultEncoding: 'utf-8',
|
||||
|
@ -96,7 +95,7 @@ function createMainWindow() {
|
|||
frame: false, // 无边框
|
||||
autoHideMenuBar: true,
|
||||
maximizable: false,
|
||||
icon: join(__dirname, logoIco),
|
||||
icon: join(__dirname, '../../resources/logo2.ico'),
|
||||
...(process.platform === 'linux' ? { icon } : {}),
|
||||
webPreferences: {
|
||||
defaultEncoding: 'utf-8',
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 51 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.1 MiB |
Binary file not shown.
Before Width: | Height: | Size: 520 KiB |
|
@ -104,7 +104,7 @@ import { cloneDeep } from 'lodash'
|
|||
const props = defineProps(['type'])
|
||||
const { user } = useUserStore()
|
||||
|
||||
const curMode = ref(2)
|
||||
const curMode = ref(1)
|
||||
const modeOptions = ref([
|
||||
{
|
||||
label: '教学大模型',
|
||||
|
@ -205,7 +205,7 @@ const scrollToBottom = (height, index) => {
|
|||
let listDom = listRef.value.children
|
||||
|
||||
if (index == 0) {
|
||||
// 220 去掉头部
|
||||
// 220 去掉头部
|
||||
let screenHeight = window.innerHeight - 220
|
||||
if (height > screenHeight) {
|
||||
listRef.value.scrollTop = (height - screenHeight + 50)
|
||||
|
@ -240,7 +240,7 @@ const changeTemplate = (val) => {
|
|||
const removeItem = async (item, isChild) => {
|
||||
/**
|
||||
* item: 当前操作的模板
|
||||
* isChild: 子模板中的移除为 true
|
||||
* isChild: 子模板中的移除为 true
|
||||
*/
|
||||
if (item.ex3 != '1') {
|
||||
ElMessageBox.confirm(
|
||||
|
@ -320,7 +320,7 @@ const againResult = async (index, item) => {
|
|||
str = str.replace('{模板内容}',item.prompt)
|
||||
params.prompt = str
|
||||
params.template = item.prompt
|
||||
|
||||
|
||||
let data = null;
|
||||
// 教学大模型
|
||||
if (curMode.value == 1) {
|
||||
|
@ -606,4 +606,4 @@ onUnmounted(() => {
|
|||
width: 110px !important;
|
||||
min-width: 110px !important;
|
||||
}
|
||||
</style>
|
||||
</style>
|
|
@ -38,7 +38,6 @@ const closeWindow = () => {
|
|||
ElMessageBox.confirm('确认退出系统吗?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
customClass: 'login-close-tool',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
userStore.logOut().then(() => {
|
||||
|
@ -55,11 +54,7 @@ onMounted(() =>{
|
|||
})
|
||||
|
||||
</script>
|
||||
<style>
|
||||
.login-close-tool {
|
||||
-webkit-app-region: no-drag;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.header-tool {
|
||||
width: 100%;
|
||||
|
@ -86,4 +81,4 @@ onMounted(() =>{
|
|||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
|
@ -49,10 +49,10 @@ export function blobToFile(blob, fileName, contentType) {
|
|||
/**
|
||||
* @description 计算两点直线距离 (获取直径)
|
||||
* (欧几里得距离公式): [ \text{distance} = \sqrt{(x2 - x1)^2 + (y2 - y1)^2} ]
|
||||
* @param {*} x1
|
||||
* @param {*} y1
|
||||
* @param {*} x2
|
||||
* @param {*} y2
|
||||
* @param {*} x1
|
||||
* @param {*} y1
|
||||
* @param {*} x2
|
||||
* @param {*} y2
|
||||
*/
|
||||
export function getDistance(x1,y1,x2,y2) {
|
||||
return Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2))
|
||||
|
@ -62,10 +62,10 @@ export function getRadius(x1,y1,x2,y2) { return getDistance(x1,y1,x2,y2) / 2 }
|
|||
|
||||
/**
|
||||
* 计算某个值在总数中所占的百分比。
|
||||
*
|
||||
*
|
||||
* 此函数用于根据给定的值和总数,计算该值占总数的百分比。它还支持指定百分比的小数位数。
|
||||
* 如果计算结果小于0,则返回0;如果大于100,则返回100,以确保百分比的合理范围。
|
||||
*
|
||||
*
|
||||
* @param {number} v - 待计算的值。
|
||||
* @param {number} total - 总数。
|
||||
* @param {number} [step=2] - 百分比的小数位数,默认为2。
|
||||
|
@ -76,7 +76,7 @@ export function getPercent(v, total, step=2) {
|
|||
!total && (total = 1)
|
||||
// 计算百分比,保留指定的小数位,并转换为数字类型
|
||||
let res = (v / total * 100).toFixed(step)-0
|
||||
|
||||
|
||||
// 确保百分比在0到100之间
|
||||
return res < 0 ? 0 : res > 100 ? 100 : res
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ export function getPercent(v, total, step=2) {
|
|||
* @param {*} start 前面保留几位 默认 3位
|
||||
* @param {*} end 后面保留几位 默认 3位
|
||||
* @param {*} rstr 替换字符 默认 ****
|
||||
* @returns
|
||||
* @returns
|
||||
*/
|
||||
export function phoneHideFormat(phone, start = 3, end = 4, rstr = '****') {
|
||||
// const reg = /^(\d{3})\d*(\d{4})$/
|
||||
|
@ -101,8 +101,8 @@ export function phoneHideFormat(phone, start = 3, end = 4, rstr = '****') {
|
|||
// ============= 习题工具--相关 ===================
|
||||
/**
|
||||
* @description 将字符串转换为数组
|
||||
* @param {*} str
|
||||
* @returns
|
||||
* @param {*} str
|
||||
* @returns
|
||||
*/
|
||||
export function quizStrToList(str = '') {
|
||||
if (!str) return []
|
||||
|
@ -175,8 +175,8 @@ export const validateUrl = (url) => {
|
|||
|
||||
/**
|
||||
* @description 时间 秒 转化 时分秒
|
||||
* @param {*} seconds
|
||||
* @returns
|
||||
* @param {*} seconds
|
||||
* @returns
|
||||
*/
|
||||
export function formatTime(seconds) {
|
||||
seconds = parseInt(seconds) // 转换整数
|
||||
|
@ -188,9 +188,9 @@ export function formatTime(seconds) {
|
|||
|
||||
/**
|
||||
* @description 时间格式化
|
||||
* @param {*} time
|
||||
* @param {*} fmt
|
||||
* @returns
|
||||
* @param {*} time
|
||||
* @param {*} fmt
|
||||
* @returns
|
||||
*/
|
||||
export function formatDate(time, fmt = 'yyyy-MM-dd') {
|
||||
let date
|
||||
|
@ -300,7 +300,7 @@ export function getDateStr1(num, fmt = 'yyyy-MM-dd hh:mm:ss') {
|
|||
}
|
||||
/**
|
||||
* 获取当前 0:0:0:0 时间
|
||||
* @param {*} [fmt] 格式 'yyyy-MM-dd hh:mm:ss'
|
||||
* @param {*} [fmt] 格式 'yyyy-MM-dd hh:mm:ss'
|
||||
*/
|
||||
export function getDateNow(fmt) {
|
||||
const date = new Date()
|
||||
|
@ -339,9 +339,9 @@ export function timeToStr(time,str = '时分秒', isPad = false) {
|
|||
* debounce(() => {
|
||||
console.log('Input event handled');
|
||||
}, 300);
|
||||
* @param {*} func
|
||||
* @param {*} wait
|
||||
* @returns
|
||||
* @param {*} func
|
||||
* @param {*} wait
|
||||
* @returns
|
||||
*/
|
||||
export function debounce(func, wait) {
|
||||
let timeout;
|
||||
|
@ -358,9 +358,9 @@ export function debounce(func, wait) {
|
|||
* throttle(() => {
|
||||
console.log('Scroll event handled');
|
||||
}, 300);
|
||||
* @param {*} func
|
||||
* @param {*} wait
|
||||
* @returns
|
||||
* @param {*} func
|
||||
* @param {*} wait
|
||||
* @returns
|
||||
*/
|
||||
export function throttle(func, wait) {
|
||||
let lastTime = 0;
|
||||
|
@ -376,7 +376,7 @@ export function throttle(func, wait) {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* 大模型对话dataset_id
|
||||
*/
|
||||
export const dataSetJson = {
|
||||
|
@ -403,11 +403,5 @@ export const dataSetJson = {
|
|||
"教材-高中-数学": "e03aa4fe9fd011ef91270242ac140006",
|
||||
"教材-高中-地理": "270516829fd111efb13c0242ac140006",
|
||||
"教材-高中-政治": "a2f0b247b85d11ef84290242ac140005",
|
||||
"课标-小学-科学": "935cfec8bf6a11ef98950242ac140006",
|
||||
"课标-小学-数学": "3c4e298fbf7911ef8e8b0242ac140002",
|
||||
"课标-小学-语文": "f76f1aa5bf7111ef90c80242ac140002",
|
||||
"教材-小学-科学": "935cfec8bf6a11ef98950242ac140006",
|
||||
"教材-小学-数学": "3c4e298fbf7911ef8e8b0242ac140002",
|
||||
"教材-小学-语文": "f76f1aa5bf7111ef90c80242ac140002",
|
||||
"鉴权": "ragflow-IwMDI1MGU2YTU3NjExZWZiNWEzMDI0Mm"
|
||||
}
|
||||
}
|
|
@ -248,11 +248,10 @@ export function toolWindow(type, {url, isConsole, isWeb=true, option={}}) {
|
|||
const devUrl = `${BaseUrl}${url}`
|
||||
const buildUrl = path.join(__dirname, 'index.html')
|
||||
const urlAll = isDev ? devUrl : buildUrl
|
||||
let logoIco = import.meta.env.MODE==='yc'||import.meta.env.MODE==='yc2'?'/resources/yc-logo.png':'/resources/logo2.ico'
|
||||
return new Promise(async(resolve) => {
|
||||
const config = {
|
||||
width, height,
|
||||
icon: path.join(appPath, logoIco),
|
||||
icon: path.join(appPath, '/resources/logo2.ico'),
|
||||
webPreferences: {
|
||||
preload: path.join(API.preloadPath, '/index.js'),
|
||||
sandbox: false,
|
||||
|
|
|
@ -1,427 +0,0 @@
|
|||
<template>
|
||||
<div class="login-container">
|
||||
<div class="box-item desc">
|
||||
<div class="welcome">
|
||||
<p>欢迎登录 {{ homeTitle }}</p>
|
||||
</div>
|
||||
<img class="welcome-img" :src="leftBg2" />
|
||||
</div>
|
||||
<div class="box-item login" v-if="isRegister">
|
||||
<WindowTools :is-has-max="false" />
|
||||
<div class="login-title">账号登录</div>
|
||||
<el-form ref="formRef" class="login-form" :model="loginForm" :rules="rules" size="large">
|
||||
<el-form-item prop="username">
|
||||
<el-input v-model.trim="loginForm.username" placeholder="请输入用户名" />
|
||||
</el-form-item>
|
||||
<el-form-item prop="password" style="margin-bottom: 15px">
|
||||
<el-input v-model="loginForm.password" autocomplete="on" type="password" placeholder="请输入密码" />
|
||||
</el-form-item>
|
||||
<div class="flex mb-5">
|
||||
<el-checkbox v-model="loginForm.rememberMe">记住密码</el-checkbox>
|
||||
<!-- <el-checkbox >阅读并同意《xxx》</el-checkbox> -->
|
||||
</div>
|
||||
|
||||
<el-form-item>
|
||||
<el-button :loading="btnLoading" class="btn" type="primary" @click="submitForm(formRef)">登录</el-button>
|
||||
</el-form-item>
|
||||
<div class="flex mb-4" style="display: flex;justify-content: center;color: #ccc;cursor: pointer;">
|
||||
<a class="hover:text-sky-500" style="margin-right: 10px;" @click="gotoreRegister">注册账号</a>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="box-item login" v-else>
|
||||
<WindowTools :is-has-max="false" />
|
||||
<div class="login-title">账号注册</div>
|
||||
<el-form ref="ruleFormRef" class="login-form" :model="ruleForm" label-width="auto" :rules="rules" size="large">
|
||||
<el-form-item label="手机号" prop="username">
|
||||
<el-input v-model="ruleForm.username" placeholder="请输入手机号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="验证码" prop="smsCode" style="display: flex">
|
||||
<el-input style="width:185px" v-model="ruleForm.smsCode" placeholder="请输入验证码" /><el-button style="margin-left:10px;width:100px" :disabled="codeName=='发送验证码'?false:true" type="primary" @click="sendyzm">{{ codeName }}</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item label="密码" prop="password" >
|
||||
<el-input autocomplete="on" type="password" v-model="ruleForm.password" placeholder="请输入密码" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button class="btn" type="primary" @click="RegisterForm(ruleFormRef)">立即注册</el-button>
|
||||
</el-form-item>
|
||||
<div class="flex mb-4" style="display: flex;justify-content: center;color: #ccc;cursor: pointer;">
|
||||
<a class="hover:text-sky-500" style="margin-right: 10px;" @click="gotoLogin"> 《 返回登录 </a>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
</div>
|
||||
<el-dialog v-model="showDownLoading" width="500" :show-close="false" :close-on-click-modal="false"
|
||||
:close-on-press-escape="false" align-center>
|
||||
<el-progress :text-inside="true" :stroke-width="22" :percentage="downloadProp" :show-text="false"
|
||||
status="success" />
|
||||
</el-dialog>
|
||||
<el-dialog
|
||||
v-model="isImg"
|
||||
title="人机验证"
|
||||
width="500"
|
||||
style=" -webkit-app-region: no-drag;"
|
||||
>
|
||||
<span>根据图片回答相关问题1</span>
|
||||
<div style="display: flex;align-items: center;;margin-top:30px">
|
||||
<img :src="isPeopleImg" style="width:200px;height:60px;cursor: pointer;" alt="" srcset="" @click="refreshImg">
|
||||
<el-input v-model="ruleForm.imgCode" style="width: 250px;height:40px;margin-left:20px" placeholder="请根据图片填入答案" />
|
||||
</div>
|
||||
<div style="display: flex;justify-content: center;margin-top:30px">
|
||||
<el-button type="primary" @click="sbmitImg">确定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!--选择学科-->
|
||||
<SelectSubject v-model="isSubject" :login-data="loginForm" />
|
||||
<!--注册弹框-->
|
||||
<Register ref="RegModel"></Register>
|
||||
|
||||
|
||||
</template>
|
||||
<script setup>
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { encrypt, decrypt } from '@/utils/jsencrypt'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import leftBg2 from '@/assets/images/login/left-bg2.png'
|
||||
import WindowTools from '@/components/window-tools/index.vue'
|
||||
import SelectSubject from '@/components/select-subject/index.vue'
|
||||
import Register from './components/Register.vue'
|
||||
import { sessionStore } from '@/utils/store'
|
||||
import {sendcode,instructorregister,getCodeImg} from '@/api/login'
|
||||
|
||||
const { session } = require('@electron/remote')
|
||||
const downloadProp = ref(0)
|
||||
const showDownLoading = ref(false)
|
||||
const { ipcRenderer } = window.electron || {}
|
||||
const formRef = ref()
|
||||
const userStore = useUserStore()
|
||||
const btnLoading = ref(false)
|
||||
const isSubject = ref(false)
|
||||
const RegModel = ref(false)
|
||||
const isRegister = ref(true)
|
||||
const ruleFormRef = ref(null)
|
||||
const codeName=ref('发送验证码')
|
||||
const timer=ref(null)
|
||||
const isImg=ref(false)
|
||||
const isPeopleImg=ref(null)
|
||||
const type=ref(1) // 1注册 2找回密码
|
||||
const resImg = reactive({ imgData: {} });
|
||||
|
||||
//表单
|
||||
const loginForm = reactive({
|
||||
username: '',
|
||||
password: '',
|
||||
rememberMe: false
|
||||
})
|
||||
// 注册表单
|
||||
const ruleForm = reactive({
|
||||
|
||||
})
|
||||
//表单规则
|
||||
const rules = reactive({
|
||||
username: [{ required: true, trigger: 'blur', message: '请输入您的账号' }],
|
||||
password: [{ required: true, trigger: 'blur', message: '请输入您的密码' }],
|
||||
smsCode: [{ required: true, trigger: 'blur', message: '请输入您的验证码' }],
|
||||
})
|
||||
|
||||
let curWinUrl = import.meta.env.VITE_APP_BUILD_BASE_PATH
|
||||
let homeTitle = ref(import.meta.env.VITE_APP_TITLE)
|
||||
ipcRenderer.on('update-app-progress', (e, prop) => {
|
||||
downloadProp.value = prop
|
||||
showDownLoading.value = prop !== 100
|
||||
})
|
||||
const gotoreRegister=()=>{
|
||||
codeName.value='发送验证码'
|
||||
if(timer.value){
|
||||
clearInterval(timer.value);
|
||||
}
|
||||
isRegister.value=false
|
||||
}
|
||||
// 刷新
|
||||
const refreshImg=()=>{
|
||||
getCodeImg().then(res=>{
|
||||
isPeopleImg.value='data:image/jpg;base64,'+res.img
|
||||
resImg.imgData=res
|
||||
})
|
||||
}
|
||||
// 提交人机验证
|
||||
const sbmitImg=()=>{
|
||||
if(ruleForm.imgCode){
|
||||
// {mobile:ruleForm.phoneNumber,code:ruleForm.imgCode,uuid:resImg.imgData.uuid}
|
||||
const { username:username,imgCode:code } = ruleForm
|
||||
const params = {
|
||||
username, code,
|
||||
uuid: resImg.imgData.uuid,
|
||||
source:4
|
||||
}
|
||||
sendcode(params).then(res=>{
|
||||
if(res.code==200){
|
||||
ElMessage.success('短信发送成功')
|
||||
ruleForm.Code=res.data
|
||||
isImg.value=false
|
||||
codeName.value=60
|
||||
timer.value=setInterval(()=>{
|
||||
codeName.value--
|
||||
if(codeName.value==0){
|
||||
codeName.value='发送验证码'
|
||||
clearInterval(timer.value);
|
||||
}
|
||||
},1000)
|
||||
}
|
||||
|
||||
})
|
||||
}else{
|
||||
ElMessage.error('请根据图片输入验证码')
|
||||
}
|
||||
//
|
||||
}
|
||||
// 发送验证码
|
||||
const sendyzm=()=>{
|
||||
if(ruleForm.username){
|
||||
const pattern = /^1[3-9]\d{9}$/;
|
||||
if( pattern.test(ruleForm.username) ){
|
||||
|
||||
getCodeImg().then(res=>{
|
||||
if(res.code==200){
|
||||
ruleForm.imgCode=null
|
||||
isPeopleImg.value='data:image/jpg;base64,'+res.img
|
||||
isImg.value=true
|
||||
resImg.imgData=res
|
||||
// codeName.value=60
|
||||
// timer.value=setInterval(()=>{
|
||||
// codeName.value--
|
||||
// if(codeName.value==0){
|
||||
// codeName.value='发送验证码'
|
||||
// clearInterval(timer.value);
|
||||
// }
|
||||
// },1000)
|
||||
}else{
|
||||
ElMessage.error(res.msg)
|
||||
}
|
||||
})
|
||||
}else{
|
||||
ElMessage.error('请输入正确的手机号码')
|
||||
}
|
||||
// captchaImg({mobile:ruleForm.phoneNumber}).then(res=>{
|
||||
// console.log('res->', res)
|
||||
// })
|
||||
}else{
|
||||
ElMessage.error('请输入手机号码')
|
||||
}
|
||||
}
|
||||
// 打开弹窗
|
||||
const RegisterModel = type => {
|
||||
RegModel.value.OpenModel(type)
|
||||
}
|
||||
//登录
|
||||
const submitForm = async (formEl) => {
|
||||
if (!formEl) return
|
||||
await formEl.validate(async (valid) => {
|
||||
if (valid) {
|
||||
btnLoading.value = true
|
||||
|
||||
// 勾选了需要记住密码设置在 cookie 中设置记住用户名和密码
|
||||
if (loginForm.rememberMe) {
|
||||
await setCookie('username', loginForm.username)
|
||||
await setCookie('password', encrypt(loginForm.password))
|
||||
await setCookie('rememberMe', loginForm.rememberMe.toString())
|
||||
} else {
|
||||
// 否则移除
|
||||
await session.defaultSession.clearStorageData({
|
||||
origin: curWinUrl,
|
||||
storages: ['cookies']
|
||||
})
|
||||
}
|
||||
|
||||
try {
|
||||
await userStore.login(loginForm)
|
||||
await userStore.getInfo()
|
||||
if (userStore.user.edustage || userStore.user.edusubject || isStadium(userStore.user)) {
|
||||
ElMessage.success('登录成功')
|
||||
ipcRenderer && ipcRenderer.send('openMainWindow')
|
||||
} else {
|
||||
isSubject.value = true
|
||||
}
|
||||
} finally {
|
||||
btnLoading.value = false
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const isStadium = (user) => {
|
||||
let roles = user.roles
|
||||
return roles.some(item => item.roleKey === 'stadium')
|
||||
}
|
||||
|
||||
const getCookie = async () => {
|
||||
const username = (await getCookieDetail('username'))[0]
|
||||
const password = (await getCookieDetail('password'))[0]
|
||||
const rememberMe = (await getCookieDetail('rememberMe'))[0]
|
||||
loginForm.username = username ? username.value : loginForm.username
|
||||
loginForm.password = password ? decrypt(password.value) : loginForm.password
|
||||
loginForm.rememberMe = rememberMe ? Boolean(rememberMe.value) : false
|
||||
}
|
||||
|
||||
// 获取cookie
|
||||
const getCookieDetail = (name) => {
|
||||
return session.defaultSession.cookies.get({ url: curWinUrl, name })
|
||||
}
|
||||
|
||||
// 设置cookie
|
||||
const setCookie = (name, value) => {
|
||||
// 30天过期
|
||||
let Days = 30
|
||||
let times = Math.round(Date.now() / 1000) + Days * 24 * 60 * 60
|
||||
const cookie = {
|
||||
url: curWinUrl,
|
||||
name,
|
||||
value,
|
||||
expirationDate: times
|
||||
}
|
||||
return session.defaultSession.cookies.set(cookie)
|
||||
}
|
||||
const gotoLogin = () => {
|
||||
codeName.value='发送验证码'
|
||||
if (timer.value){
|
||||
clearInterval(timer.value);
|
||||
}
|
||||
if (ruleFormRef.value) ruleFormRef.value.resetFields()
|
||||
isRegister.value = true
|
||||
}
|
||||
// 注册
|
||||
const RegisterForm = async (formEl) => {
|
||||
if (!formEl) return
|
||||
await formEl.validate((valid, fields) => {
|
||||
if (valid) {
|
||||
instructorregister(ruleForm).then(res=>{
|
||||
if(res.code==200){
|
||||
ElMessage.success('您已注册成功')
|
||||
if (ruleFormRef.value) ruleFormRef.value.resetFields()
|
||||
gotoLogin()
|
||||
}else{
|
||||
ElMessage.error(res.msg)
|
||||
}
|
||||
})
|
||||
console.log('submit!')
|
||||
} else {
|
||||
console.log('error submit!', fields)
|
||||
}
|
||||
})
|
||||
}
|
||||
onMounted(() => {
|
||||
localStorage.clear()
|
||||
sessionStore.set('subject', {
|
||||
bookList: null,
|
||||
curBook: null,
|
||||
curNode: null,
|
||||
defaultExpandedKeys: [],
|
||||
subjectTree: []
|
||||
})
|
||||
getCookie()
|
||||
})
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.login-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
-webkit-app-region: drag;
|
||||
|
||||
.box-item {
|
||||
width: 444px;
|
||||
height: 520px;
|
||||
|
||||
&.desc {
|
||||
background: #ffffff;
|
||||
border-radius: 12px 0px 0px 12px;
|
||||
box-shadow: 0px 16px 73px 8px rgba(203, 203, 203, 0.2);
|
||||
padding: 23px 25px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
background-color: #003b94;
|
||||
}
|
||||
|
||||
&.login {
|
||||
background: #ffffff;
|
||||
border-radius: 0px 12px 12px 0px;
|
||||
padding: 34px 42px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.welcome {
|
||||
padding-top: 35px;
|
||||
|
||||
p {
|
||||
color: #ffffff;
|
||||
line-height: 25px;
|
||||
letter-spacing: 0.26px;
|
||||
text-align: center;
|
||||
font-weight: 700;
|
||||
font-size: 26px;
|
||||
}
|
||||
}
|
||||
|
||||
.welcome-img {
|
||||
margin-top: 20px;
|
||||
width: 350px;
|
||||
height: 350px;
|
||||
}
|
||||
|
||||
.login-title {
|
||||
font-size: 20px;
|
||||
text-align: center;
|
||||
color: #1e1e1e;
|
||||
margin-bottom: 35px;
|
||||
margin-top: 50px;
|
||||
}
|
||||
|
||||
.login-form {
|
||||
-webkit-app-region: no-drag;
|
||||
|
||||
.captcha-input {
|
||||
width: 60%;
|
||||
}
|
||||
|
||||
.captcha-img {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.btn {
|
||||
width: 350px;
|
||||
height: 50px;
|
||||
border-radius: 4px;
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
text-align: center;
|
||||
color: #ffffff;
|
||||
line-height: 50px;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.header-tool {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
-webkit-app-region: no-drag;
|
||||
|
||||
span {
|
||||
padding: 5px 10px;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.el-form-item {
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
</style>
|
|
@ -1,13 +1,427 @@
|
|||
<template>
|
||||
<ycLogin v-if="buildMode === 'yc'||buildMode === 'yc2'">
|
||||
</ycLogin>
|
||||
<defultLogin v-else>
|
||||
</defultLogin>
|
||||
<div class="login-container">
|
||||
<div class="box-item desc">
|
||||
<div class="welcome">
|
||||
<p>欢迎登录 {{ homeTitle }}</p>
|
||||
</div>
|
||||
<img class="welcome-img" :src="leftBg2" />
|
||||
</div>
|
||||
<div class="box-item login" v-if="isRegister">
|
||||
<WindowTools :is-has-max="false" />
|
||||
<div class="login-title">账号登录</div>
|
||||
<el-form ref="formRef" class="login-form" :model="loginForm" :rules="rules" size="large">
|
||||
<el-form-item prop="username">
|
||||
<el-input v-model.trim="loginForm.username" placeholder="请输入用户名" />
|
||||
</el-form-item>
|
||||
<el-form-item prop="password" style="margin-bottom: 15px">
|
||||
<el-input v-model="loginForm.password" autocomplete="on" type="password" placeholder="请输入密码" />
|
||||
</el-form-item>
|
||||
<div class="flex mb-5">
|
||||
<el-checkbox v-model="loginForm.rememberMe">记住密码</el-checkbox>
|
||||
<!-- <el-checkbox >阅读并同意《xxx》</el-checkbox> -->
|
||||
</div>
|
||||
|
||||
<el-form-item>
|
||||
<el-button :loading="btnLoading" class="btn" type="primary" @click="submitForm(formRef)">登录</el-button>
|
||||
</el-form-item>
|
||||
<div class="flex mb-4" style="display: flex;justify-content: center;color: #ccc;cursor: pointer;">
|
||||
<a class="hover:text-sky-500" style="margin-right: 10px;" @click="gotoreRegister">注册账号</a>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="box-item login" v-else>
|
||||
<WindowTools :is-has-max="false" />
|
||||
<div class="login-title">账号注册</div>
|
||||
<el-form ref="ruleFormRef" class="login-form" :model="ruleForm" label-width="auto" :rules="rules" size="large">
|
||||
<el-form-item label="手机号" prop="username">
|
||||
<el-input v-model="ruleForm.username" placeholder="请输入手机号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="验证码" prop="smsCode" style="display: flex">
|
||||
<el-input style="width:185px" v-model="ruleForm.smsCode" placeholder="请输入验证码" /><el-button style="margin-left:10px;width:100px" :disabled="codeName=='发送验证码'?false:true" type="primary" @click="sendyzm">{{ codeName }}</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item label="密码" prop="password" >
|
||||
<el-input autocomplete="on" type="password" v-model="ruleForm.password" placeholder="请输入密码" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button class="btn" type="primary" @click="RegisterForm(ruleFormRef)">立即注册</el-button>
|
||||
</el-form-item>
|
||||
<div class="flex mb-4" style="display: flex;justify-content: center;color: #ccc;cursor: pointer;">
|
||||
<a class="hover:text-sky-500" style="margin-right: 10px;" @click="gotoLogin"> 《 返回登录 </a>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
</div>
|
||||
<el-dialog v-model="showDownLoading" width="500" :show-close="false" :close-on-click-modal="false"
|
||||
:close-on-press-escape="false" align-center>
|
||||
<el-progress :text-inside="true" :stroke-width="22" :percentage="downloadProp" :show-text="false"
|
||||
status="success" />
|
||||
</el-dialog>
|
||||
<el-dialog
|
||||
v-model="isImg"
|
||||
title="人机验证"
|
||||
width="500"
|
||||
style=" -webkit-app-region: no-drag;"
|
||||
>
|
||||
<span>根据图片回答相关问题1</span>
|
||||
<div style="display: flex;align-items: center;;margin-top:30px">
|
||||
<img :src="isPeopleImg" style="width:200px;height:60px;cursor: pointer;" alt="" srcset="" @click="refreshImg">
|
||||
<el-input v-model="ruleForm.imgCode" style="width: 250px;height:40px;margin-left:20px" placeholder="请根据图片填入答案" />
|
||||
</div>
|
||||
<div style="display: flex;justify-content: center;margin-top:30px">
|
||||
<el-button type="primary" @click="sbmitImg">确定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!--选择学科-->
|
||||
<SelectSubject v-model="isSubject" :login-data="loginForm" />
|
||||
<!--注册弹框-->
|
||||
<Register ref="RegModel"></Register>
|
||||
|
||||
|
||||
</template>
|
||||
<script setup>
|
||||
import ycLogin from './yc-login.vue'
|
||||
import defultLogin from './defult-login.vue'
|
||||
const buildMode = import.meta.env.MODE
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { encrypt, decrypt } from '@/utils/jsencrypt'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import leftBg2 from '@/assets/images/login/left-bg2.png'
|
||||
import WindowTools from '@/components/window-tools/index.vue'
|
||||
import SelectSubject from '@/components/select-subject/index.vue'
|
||||
import Register from './components/Register.vue'
|
||||
import { sessionStore } from '@/utils/store'
|
||||
import {sendcode,instructorregister,getCodeImg} from '@/api/login'
|
||||
|
||||
const { session } = require('@electron/remote')
|
||||
const downloadProp = ref(0)
|
||||
const showDownLoading = ref(false)
|
||||
const { ipcRenderer } = window.electron || {}
|
||||
const formRef = ref()
|
||||
const userStore = useUserStore()
|
||||
const btnLoading = ref(false)
|
||||
const isSubject = ref(false)
|
||||
const RegModel = ref(false)
|
||||
const isRegister = ref(true)
|
||||
const ruleFormRef = ref(null)
|
||||
const codeName=ref('发送验证码')
|
||||
const timer=ref(null)
|
||||
const isImg=ref(false)
|
||||
const isPeopleImg=ref(null)
|
||||
const type=ref(1) // 1注册 2找回密码
|
||||
const resImg = reactive({ imgData: {} });
|
||||
|
||||
//表单
|
||||
const loginForm = reactive({
|
||||
username: '',
|
||||
password: '',
|
||||
rememberMe: false
|
||||
})
|
||||
// 注册表单
|
||||
const ruleForm = reactive({
|
||||
|
||||
})
|
||||
//表单规则
|
||||
const rules = reactive({
|
||||
username: [{ required: true, trigger: 'blur', message: '请输入您的账号' }],
|
||||
password: [{ required: true, trigger: 'blur', message: '请输入您的密码' }],
|
||||
smsCode: [{ required: true, trigger: 'blur', message: '请输入您的验证码' }],
|
||||
})
|
||||
|
||||
let curWinUrl = import.meta.env.VITE_APP_BUILD_BASE_PATH
|
||||
let homeTitle = ref(import.meta.env.VITE_APP_TITLE)
|
||||
ipcRenderer.on('update-app-progress', (e, prop) => {
|
||||
downloadProp.value = prop
|
||||
showDownLoading.value = prop !== 100
|
||||
})
|
||||
const gotoreRegister=()=>{
|
||||
codeName.value='发送验证码'
|
||||
if(timer.value){
|
||||
clearInterval(timer.value);
|
||||
}
|
||||
isRegister.value=false
|
||||
}
|
||||
// 刷新
|
||||
const refreshImg=()=>{
|
||||
getCodeImg().then(res=>{
|
||||
isPeopleImg.value='data:image/jpg;base64,'+res.img
|
||||
resImg.imgData=res
|
||||
})
|
||||
}
|
||||
// 提交人机验证
|
||||
const sbmitImg=()=>{
|
||||
if(ruleForm.imgCode){
|
||||
// {mobile:ruleForm.phoneNumber,code:ruleForm.imgCode,uuid:resImg.imgData.uuid}
|
||||
const { username:username,imgCode:code } = ruleForm
|
||||
const params = {
|
||||
username, code,
|
||||
uuid: resImg.imgData.uuid,
|
||||
source:4
|
||||
}
|
||||
sendcode(params).then(res=>{
|
||||
if(res.code==200){
|
||||
ElMessage.success('短信发送成功')
|
||||
ruleForm.Code=res.data
|
||||
isImg.value=false
|
||||
codeName.value=60
|
||||
timer.value=setInterval(()=>{
|
||||
codeName.value--
|
||||
if(codeName.value==0){
|
||||
codeName.value='发送验证码'
|
||||
clearInterval(timer.value);
|
||||
}
|
||||
},1000)
|
||||
}
|
||||
|
||||
})
|
||||
}else{
|
||||
ElMessage.error('请根据图片输入验证码')
|
||||
}
|
||||
//
|
||||
}
|
||||
// 发送验证码
|
||||
const sendyzm=()=>{
|
||||
if(ruleForm.username){
|
||||
const pattern = /^1[3-9]\d{9}$/;
|
||||
if( pattern.test(ruleForm.username) ){
|
||||
|
||||
getCodeImg().then(res=>{
|
||||
if(res.code==200){
|
||||
ruleForm.imgCode=null
|
||||
isPeopleImg.value='data:image/jpg;base64,'+res.img
|
||||
isImg.value=true
|
||||
resImg.imgData=res
|
||||
// codeName.value=60
|
||||
// timer.value=setInterval(()=>{
|
||||
// codeName.value--
|
||||
// if(codeName.value==0){
|
||||
// codeName.value='发送验证码'
|
||||
// clearInterval(timer.value);
|
||||
// }
|
||||
// },1000)
|
||||
}else{
|
||||
ElMessage.error(res.msg)
|
||||
}
|
||||
})
|
||||
}else{
|
||||
ElMessage.error('请输入正确的手机号码')
|
||||
}
|
||||
// captchaImg({mobile:ruleForm.phoneNumber}).then(res=>{
|
||||
// console.log('res->', res)
|
||||
// })
|
||||
}else{
|
||||
ElMessage.error('请输入手机号码')
|
||||
}
|
||||
}
|
||||
// 打开弹窗
|
||||
const RegisterModel = type => {
|
||||
RegModel.value.OpenModel(type)
|
||||
}
|
||||
//登录
|
||||
const submitForm = async (formEl) => {
|
||||
if (!formEl) return
|
||||
await formEl.validate(async (valid) => {
|
||||
if (valid) {
|
||||
btnLoading.value = true
|
||||
|
||||
// 勾选了需要记住密码设置在 cookie 中设置记住用户名和密码
|
||||
if (loginForm.rememberMe) {
|
||||
await setCookie('username', loginForm.username)
|
||||
await setCookie('password', encrypt(loginForm.password))
|
||||
await setCookie('rememberMe', loginForm.rememberMe.toString())
|
||||
} else {
|
||||
// 否则移除
|
||||
await session.defaultSession.clearStorageData({
|
||||
origin: curWinUrl,
|
||||
storages: ['cookies']
|
||||
})
|
||||
}
|
||||
|
||||
try {
|
||||
await userStore.login(loginForm)
|
||||
await userStore.getInfo()
|
||||
if (userStore.user.edustage || userStore.user.edusubject || isStadium(userStore.user)) {
|
||||
ElMessage.success('登录成功')
|
||||
ipcRenderer && ipcRenderer.send('openMainWindow')
|
||||
} else {
|
||||
isSubject.value = true
|
||||
}
|
||||
} finally {
|
||||
btnLoading.value = false
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const isStadium = (user) => {
|
||||
let roles = user.roles
|
||||
return roles.some(item => item.roleKey === 'stadium')
|
||||
}
|
||||
|
||||
const getCookie = async () => {
|
||||
const username = (await getCookieDetail('username'))[0]
|
||||
const password = (await getCookieDetail('password'))[0]
|
||||
const rememberMe = (await getCookieDetail('rememberMe'))[0]
|
||||
loginForm.username = username ? username.value : loginForm.username
|
||||
loginForm.password = password ? decrypt(password.value) : loginForm.password
|
||||
loginForm.rememberMe = rememberMe ? Boolean(rememberMe.value) : false
|
||||
}
|
||||
|
||||
// 获取cookie
|
||||
const getCookieDetail = (name) => {
|
||||
return session.defaultSession.cookies.get({ url: curWinUrl, name })
|
||||
}
|
||||
|
||||
// 设置cookie
|
||||
const setCookie = (name, value) => {
|
||||
// 30天过期
|
||||
let Days = 30
|
||||
let times = Math.round(Date.now() / 1000) + Days * 24 * 60 * 60
|
||||
const cookie = {
|
||||
url: curWinUrl,
|
||||
name,
|
||||
value,
|
||||
expirationDate: times
|
||||
}
|
||||
return session.defaultSession.cookies.set(cookie)
|
||||
}
|
||||
const gotoLogin = () => {
|
||||
codeName.value='发送验证码'
|
||||
if (timer.value){
|
||||
clearInterval(timer.value);
|
||||
}
|
||||
if (ruleFormRef.value) ruleFormRef.value.resetFields()
|
||||
isRegister.value = true
|
||||
}
|
||||
// 注册
|
||||
const RegisterForm = async (formEl) => {
|
||||
if (!formEl) return
|
||||
await formEl.validate((valid, fields) => {
|
||||
if (valid) {
|
||||
instructorregister(ruleForm).then(res=>{
|
||||
if(res.code==200){
|
||||
ElMessage.success('您已注册成功')
|
||||
if (ruleFormRef.value) ruleFormRef.value.resetFields()
|
||||
gotoLogin()
|
||||
}else{
|
||||
ElMessage.error(res.msg)
|
||||
}
|
||||
})
|
||||
console.log('submit!')
|
||||
} else {
|
||||
console.log('error submit!', fields)
|
||||
}
|
||||
})
|
||||
}
|
||||
onMounted(() => {
|
||||
localStorage.clear()
|
||||
sessionStore.set('subject', {
|
||||
bookList: null,
|
||||
curBook: null,
|
||||
curNode: null,
|
||||
defaultExpandedKeys: [],
|
||||
subjectTree: []
|
||||
})
|
||||
getCookie()
|
||||
})
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.login-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
-webkit-app-region: drag;
|
||||
|
||||
.box-item {
|
||||
width: 444px;
|
||||
height: 520px;
|
||||
|
||||
&.desc {
|
||||
background: #ffffff;
|
||||
border-radius: 12px 0px 0px 12px;
|
||||
box-shadow: 0px 16px 73px 8px rgba(203, 203, 203, 0.2);
|
||||
padding: 23px 25px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
background-color: #003b94;
|
||||
}
|
||||
|
||||
&.login {
|
||||
background: #ffffff;
|
||||
border-radius: 0px 12px 12px 0px;
|
||||
padding: 34px 42px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.welcome {
|
||||
padding-top: 35px;
|
||||
|
||||
p {
|
||||
color: #ffffff;
|
||||
line-height: 25px;
|
||||
letter-spacing: 0.26px;
|
||||
text-align: center;
|
||||
font-weight: 700;
|
||||
font-size: 26px;
|
||||
}
|
||||
}
|
||||
|
||||
.welcome-img {
|
||||
margin-top: 20px;
|
||||
width: 350px;
|
||||
height: 350px;
|
||||
}
|
||||
|
||||
.login-title {
|
||||
font-size: 20px;
|
||||
text-align: center;
|
||||
color: #1e1e1e;
|
||||
margin-bottom: 35px;
|
||||
margin-top: 50px;
|
||||
}
|
||||
|
||||
.login-form {
|
||||
-webkit-app-region: no-drag;
|
||||
|
||||
.captcha-input {
|
||||
width: 60%;
|
||||
}
|
||||
|
||||
.captcha-img {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.btn {
|
||||
width: 350px;
|
||||
height: 50px;
|
||||
border-radius: 4px;
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
text-align: center;
|
||||
color: #ffffff;
|
||||
line-height: 50px;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.header-tool {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
-webkit-app-region: no-drag;
|
||||
|
||||
span {
|
||||
padding: 5px 10px;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.el-form-item {
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -1,463 +0,0 @@
|
|||
<template>
|
||||
<div class="login-container">
|
||||
<div class="login-yc">
|
||||
<img class="welcome-img" :src="buildMode === 'yc2'?leftBg2:leftBg1" />
|
||||
</div>
|
||||
<div class="box-item login" v-if="isRegister">
|
||||
<WindowTools :is-has-max="false" />
|
||||
<div style="display: flex;justify-content: center;"><img class="title-logo" :src="yclogo" /></div>
|
||||
<div class="login-title">永川中小学</div>
|
||||
<div class="login-title2">{{buildMode === 'yc2'?'虚拟仿真AI实训教学管理系统':'人工智能赋能科学素养与劳动技能系统'}}</div>
|
||||
<el-form ref="formRef" class="login-form" :model="loginForm" :rules="rules" size="large">
|
||||
<el-form-item prop="username">
|
||||
<el-input v-model.trim="loginForm.username" placeholder="请输入用户名" />
|
||||
</el-form-item>
|
||||
<el-form-item prop="password" style="margin-bottom: 15px">
|
||||
<el-input v-model="loginForm.password" autocomplete="on" type="password" placeholder="请输入密码" />
|
||||
</el-form-item>
|
||||
<div class="flex mb-5">
|
||||
<el-checkbox v-model="loginForm.rememberMe">记住密码</el-checkbox>
|
||||
<!-- <el-checkbox >阅读并同意《xxx》</el-checkbox> -->
|
||||
</div>
|
||||
|
||||
<el-form-item style="margin-bottom: 20px">
|
||||
<el-button :loading="btnLoading" class="btn" type="primary" @click="submitForm(formRef)">登录</el-button>
|
||||
</el-form-item>
|
||||
<div class="flex mb-4" style="display: flex;justify-content: center;color: #ccc;cursor: pointer;">
|
||||
<a class="hover:text-sky-500" style="margin-right: 10px;" @click="gotoreRegister">注册账号</a>
|
||||
</div>
|
||||
<div class="title-bottom">
|
||||
重庆市永川区教育委员会
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="box-item login" v-else>
|
||||
<WindowTools :is-has-max="false" />
|
||||
<div class="login-title">账号注册</div>
|
||||
<el-form ref="ruleFormRef" class="login-form" :model="ruleForm" label-width="auto" :rules="rules" size="large">
|
||||
<el-form-item label="手机号" prop="username">
|
||||
<el-input v-model="ruleForm.username" placeholder="请输入手机号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="验证码" prop="smsCode" style="display: flex">
|
||||
<el-input style="width:185px" v-model="ruleForm.smsCode" placeholder="请输入验证码" /><el-button style="margin-left:10px;width:100px" :disabled="codeName=='发送验证码'?false:true" type="primary" @click="sendyzm">{{ codeName }}</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item label="密码" prop="password" >
|
||||
<el-input autocomplete="on" type="password" v-model="ruleForm.password" placeholder="请输入密码" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button class="btn" type="primary" @click="RegisterForm(ruleFormRef)">立即注册</el-button>
|
||||
</el-form-item>
|
||||
<div class="flex mb-4" style="display: flex;justify-content: center;color: #ccc;cursor: pointer;">
|
||||
<a class="hover:text-sky-500" style="margin-right: 10px;" @click="gotoLogin"> 《 返回登录 </a>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
</div>
|
||||
<el-dialog v-model="showDownLoading" width="500" :show-close="false" :close-on-click-modal="false"
|
||||
:close-on-press-escape="false" align-center>
|
||||
<el-progress :text-inside="true" :stroke-width="22" :percentage="downloadProp" :show-text="false"
|
||||
status="success" />
|
||||
</el-dialog>
|
||||
<el-dialog
|
||||
v-model="isImg"
|
||||
title="人机验证"
|
||||
width="500"
|
||||
style=" -webkit-app-region: no-drag;"
|
||||
>
|
||||
<span>根据图片回答相关问题1</span>
|
||||
<div style="display: flex;align-items: center;;margin-top:30px">
|
||||
<img :src="isPeopleImg" style="width:200px;height:60px;cursor: pointer;" alt="" srcset="" @click="refreshImg">
|
||||
<el-input v-model="ruleForm.imgCode" style="width: 250px;height:40px;margin-left:20px" placeholder="请根据图片填入答案" />
|
||||
</div>
|
||||
<div style="display: flex;justify-content: center;margin-top:30px">
|
||||
<el-button type="primary" @click="sbmitImg">确定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!--选择学科-->
|
||||
<SelectSubject v-model="isSubject" :login-data="loginForm" />
|
||||
<!--注册弹框-->
|
||||
<Register ref="RegModel"></Register>
|
||||
|
||||
|
||||
</template>
|
||||
<script setup>
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { encrypt, decrypt } from '@/utils/jsencrypt'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import WindowTools from '@/components/window-tools/index.vue'
|
||||
import SelectSubject from '@/components/select-subject/index.vue'
|
||||
import Register from './components/Register.vue'
|
||||
import { sessionStore } from '@/utils/store'
|
||||
import {sendcode,instructorregister,getCodeImg} from '@/api/login'
|
||||
import yclogo from '@/assets/images/login/yc-logo.png'
|
||||
import leftBg1 from '@/assets/images/login/ycpeitu.png'
|
||||
import leftBg2 from '@/assets/images/login/ycpeitu2.jpg'
|
||||
const { session } = require('@electron/remote')
|
||||
const buildMode = import.meta.env.MODE
|
||||
const downloadProp = ref(0)
|
||||
const showDownLoading = ref(false)
|
||||
const { ipcRenderer } = window.electron || {}
|
||||
const formRef = ref()
|
||||
const userStore = useUserStore()
|
||||
const btnLoading = ref(false)
|
||||
const isSubject = ref(false)
|
||||
const RegModel = ref(false)
|
||||
const isRegister = ref(true)
|
||||
const ruleFormRef = ref(null)
|
||||
const codeName=ref('发送验证码')
|
||||
const timer=ref(null)
|
||||
const isImg=ref(false)
|
||||
const isPeopleImg=ref(null)
|
||||
const type=ref(1) // 1注册 2找回密码
|
||||
const resImg = reactive({ imgData: {} });
|
||||
|
||||
//表单
|
||||
const loginForm = reactive({
|
||||
username: '',
|
||||
password: '',
|
||||
rememberMe: false
|
||||
})
|
||||
// 注册表单
|
||||
const ruleForm = reactive({
|
||||
|
||||
})
|
||||
//表单规则
|
||||
const rules = reactive({
|
||||
username: [{ required: true, trigger: 'blur', message: '请输入您的账号' }],
|
||||
password: [{ required: true, trigger: 'blur', message: '请输入您的密码' }],
|
||||
smsCode: [{ required: true, trigger: 'blur', message: '请输入您的验证码' }],
|
||||
})
|
||||
|
||||
let curWinUrl = import.meta.env.VITE_APP_BUILD_BASE_PATH
|
||||
let homeTitle = ref(import.meta.env.VITE_APP_TITLE)
|
||||
ipcRenderer.on('update-app-progress', (e, prop) => {
|
||||
downloadProp.value = prop
|
||||
showDownLoading.value = prop !== 100
|
||||
})
|
||||
const gotoreRegister=()=>{
|
||||
codeName.value='发送验证码'
|
||||
if(timer.value){
|
||||
clearInterval(timer.value);
|
||||
}
|
||||
isRegister.value=false
|
||||
}
|
||||
// 刷新
|
||||
const refreshImg=()=>{
|
||||
getCodeImg().then(res=>{
|
||||
isPeopleImg.value='data:image/jpg;base64,'+res.img
|
||||
resImg.imgData=res
|
||||
})
|
||||
}
|
||||
// 提交人机验证
|
||||
const sbmitImg=()=>{
|
||||
if(ruleForm.imgCode){
|
||||
// {mobile:ruleForm.phoneNumber,code:ruleForm.imgCode,uuid:resImg.imgData.uuid}
|
||||
const { username:username,imgCode:code } = ruleForm
|
||||
const params = {
|
||||
username, code,
|
||||
uuid: resImg.imgData.uuid,
|
||||
source:4
|
||||
}
|
||||
sendcode(params).then(res=>{
|
||||
if(res.code==200){
|
||||
ElMessage.success('短信发送成功')
|
||||
ruleForm.Code=res.data
|
||||
isImg.value=false
|
||||
codeName.value=60
|
||||
timer.value=setInterval(()=>{
|
||||
codeName.value--
|
||||
if(codeName.value==0){
|
||||
codeName.value='发送验证码'
|
||||
clearInterval(timer.value);
|
||||
}
|
||||
},1000)
|
||||
}
|
||||
|
||||
})
|
||||
}else{
|
||||
ElMessage.error('请根据图片输入验证码')
|
||||
}
|
||||
//
|
||||
}
|
||||
// 发送验证码
|
||||
const sendyzm=()=>{
|
||||
if(ruleForm.username){
|
||||
const pattern = /^1[3-9]\d{9}$/;
|
||||
if( pattern.test(ruleForm.username) ){
|
||||
|
||||
getCodeImg().then(res=>{
|
||||
if(res.code==200){
|
||||
ruleForm.imgCode=null
|
||||
isPeopleImg.value='data:image/jpg;base64,'+res.img
|
||||
isImg.value=true
|
||||
resImg.imgData=res
|
||||
// codeName.value=60
|
||||
// timer.value=setInterval(()=>{
|
||||
// codeName.value--
|
||||
// if(codeName.value==0){
|
||||
// codeName.value='发送验证码'
|
||||
// clearInterval(timer.value);
|
||||
// }
|
||||
// },1000)
|
||||
}else{
|
||||
ElMessage.error(res.msg)
|
||||
}
|
||||
})
|
||||
}else{
|
||||
ElMessage.error('请输入正确的手机号码')
|
||||
}
|
||||
// captchaImg({mobile:ruleForm.phoneNumber}).then(res=>{
|
||||
// console.log('res->', res)
|
||||
// })
|
||||
}else{
|
||||
ElMessage.error('请输入手机号码')
|
||||
}
|
||||
}
|
||||
// 打开弹窗
|
||||
const RegisterModel = type => {
|
||||
RegModel.value.OpenModel(type)
|
||||
}
|
||||
//登录
|
||||
const submitForm = async (formEl) => {
|
||||
if (!formEl) return
|
||||
await formEl.validate(async (valid) => {
|
||||
if (valid) {
|
||||
btnLoading.value = true
|
||||
|
||||
// 勾选了需要记住密码设置在 cookie 中设置记住用户名和密码
|
||||
if (loginForm.rememberMe) {
|
||||
await setCookie('username', loginForm.username)
|
||||
await setCookie('password', encrypt(loginForm.password))
|
||||
await setCookie('rememberMe', loginForm.rememberMe.toString())
|
||||
} else {
|
||||
// 否则移除
|
||||
await session.defaultSession.clearStorageData({
|
||||
origin: curWinUrl,
|
||||
storages: ['cookies']
|
||||
})
|
||||
}
|
||||
|
||||
try {
|
||||
await userStore.login(loginForm)
|
||||
await userStore.getInfo()
|
||||
if (userStore.user.edustage || userStore.user.edusubject || isStadium(userStore.user)) {
|
||||
ElMessage.success('登录成功')
|
||||
ipcRenderer && ipcRenderer.send('openMainWindow')
|
||||
} else {
|
||||
isSubject.value = true
|
||||
}
|
||||
} finally {
|
||||
btnLoading.value = false
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const isStadium = (user) => {
|
||||
let roles = user.roles
|
||||
return roles.some(item => item.roleKey === 'stadium')
|
||||
}
|
||||
|
||||
const getCookie = async () => {
|
||||
const username = (await getCookieDetail('username'))[0]
|
||||
const password = (await getCookieDetail('password'))[0]
|
||||
const rememberMe = (await getCookieDetail('rememberMe'))[0]
|
||||
loginForm.username = username ? username.value : loginForm.username
|
||||
loginForm.password = password ? decrypt(password.value) : loginForm.password
|
||||
loginForm.rememberMe = rememberMe ? Boolean(rememberMe.value) : false
|
||||
}
|
||||
|
||||
// 获取cookie
|
||||
const getCookieDetail = (name) => {
|
||||
return session.defaultSession.cookies.get({ url: curWinUrl, name })
|
||||
}
|
||||
|
||||
// 设置cookie
|
||||
const setCookie = (name, value) => {
|
||||
// 30天过期
|
||||
let Days = 30
|
||||
let times = Math.round(Date.now() / 1000) + Days * 24 * 60 * 60
|
||||
const cookie = {
|
||||
url: curWinUrl,
|
||||
name,
|
||||
value,
|
||||
expirationDate: times
|
||||
}
|
||||
return session.defaultSession.cookies.set(cookie)
|
||||
}
|
||||
const gotoLogin = () => {
|
||||
codeName.value='发送验证码'
|
||||
if (timer.value){
|
||||
clearInterval(timer.value);
|
||||
}
|
||||
if (ruleFormRef.value) ruleFormRef.value.resetFields()
|
||||
isRegister.value = true
|
||||
}
|
||||
// 注册
|
||||
const RegisterForm = async (formEl) => {
|
||||
if (!formEl) return
|
||||
await formEl.validate((valid, fields) => {
|
||||
if (valid) {
|
||||
instructorregister(ruleForm).then(res=>{
|
||||
if(res.code==200){
|
||||
ElMessage.success('您已注册成功')
|
||||
if (ruleFormRef.value) ruleFormRef.value.resetFields()
|
||||
gotoLogin()
|
||||
}else{
|
||||
ElMessage.error(res.msg)
|
||||
}
|
||||
})
|
||||
console.log('submit!')
|
||||
} else {
|
||||
console.log('error submit!', fields)
|
||||
}
|
||||
})
|
||||
}
|
||||
onMounted(() => {
|
||||
localStorage.clear()
|
||||
sessionStore.set('subject', {
|
||||
bookList: null,
|
||||
curBook: null,
|
||||
curNode: null,
|
||||
defaultExpandedKeys: [],
|
||||
subjectTree: []
|
||||
})
|
||||
getCookie()
|
||||
})
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.login-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
-webkit-app-region: drag;
|
||||
|
||||
.login-yc{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
img{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.box-item {
|
||||
width: 370px;
|
||||
height: 520px;
|
||||
|
||||
&.desc {
|
||||
background: #ffffff;
|
||||
border-radius: 12px 0px 0px 12px;
|
||||
box-shadow: 0px 16px 73px 8px rgba(203, 203, 203, 0.2);
|
||||
padding: 23px 25px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
background-color: #003b94;
|
||||
}
|
||||
|
||||
&.login {
|
||||
background: #ffffff;
|
||||
border-radius: 0px 12px 12px 0px;
|
||||
padding: 34px 42px;
|
||||
position: relative;
|
||||
.title-logo{
|
||||
width: 50px;
|
||||
}
|
||||
}
|
||||
|
||||
.welcome {
|
||||
padding-top: 35px;
|
||||
|
||||
p {
|
||||
color: #ffffff;
|
||||
line-height: 25px;
|
||||
letter-spacing: 0.26px;
|
||||
text-align: center;
|
||||
font-weight: 700;
|
||||
font-size: 26px;
|
||||
}
|
||||
}
|
||||
|
||||
.welcome-img {
|
||||
margin-top: 20px;
|
||||
width: 350px;
|
||||
height: 350px;
|
||||
}
|
||||
|
||||
.login-title {
|
||||
font-size: 20px;
|
||||
text-align: center;
|
||||
color: #1e1e1e;
|
||||
margin-bottom: 35px;
|
||||
margin-top: 50px;
|
||||
}
|
||||
|
||||
.login-title {
|
||||
font-size: 20px;
|
||||
text-align: center;
|
||||
color: #1e1e1e;
|
||||
margin-bottom: 10px;
|
||||
margin-top: 5px;
|
||||
font-width: bold;
|
||||
}
|
||||
|
||||
.login-title2 {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.login-form {
|
||||
-webkit-app-region: no-drag;
|
||||
|
||||
.captcha-input {
|
||||
width: 60%;
|
||||
}
|
||||
|
||||
.captcha-img {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.title-bottom{
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
font-size: 14px;
|
||||
color: rgba(0, 0, 0, 0.45);
|
||||
}
|
||||
}
|
||||
|
||||
.btn {
|
||||
width: 350px;
|
||||
height: 50px;
|
||||
border-radius: 4px;
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
text-align: center;
|
||||
color: #ffffff;
|
||||
line-height: 50px;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.header-tool {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
-webkit-app-region: no-drag;
|
||||
|
||||
span {
|
||||
padding: 5px 10px;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.el-form-item {
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
</style>
|
|
@ -92,9 +92,7 @@ import * as API_entpcourse from '@/api/education/entpcourse' // 相关api
|
|||
import * as API_entpcoursefile from '@/api/education/entpcoursefile' // 相关api
|
||||
import * as Api_server from '@/api/apiService' // 相关api
|
||||
import * as API_smarttalk from '@/api/file' // 文件相关api
|
||||
import msgUtils from '@/plugins/modal'
|
||||
import { getEntpcoursefile } from '@/api/education/entpcoursefile'
|
||||
import { createWindow } from '@/utils/tool' // 消息工具
|
||||
import msgUtils from '@/plugins/modal' // 消息工具
|
||||
|
||||
const userStore = useUserStore()
|
||||
const pptDialog = ref(false)
|
||||
|
@ -348,20 +346,13 @@ const addAiPPT = async (res) => {
|
|||
const parentid = await HTTP_SERVER_API('addEntpcoursefile', p_params)
|
||||
if (!!parentid ?? null) { // 生成内容幻灯片
|
||||
// 生成备课资源-Smarttalk
|
||||
const smarttalk = await HTTP_SERVER_API('addSmarttalk', { fileId: parentid })
|
||||
HTTP_SERVER_API('addSmarttalk', { fileId: parentid })
|
||||
if (slides.length > 0) {
|
||||
const resSlides = slides.map(({ id, ...slide }) => JSON.stringify(slide))
|
||||
const params = { parentid, filetype: 'slide', title: '', slides: resSlides }
|
||||
const res_3 = await HTTP_SERVER_API('batchAddNew', params)
|
||||
if (res_3 && res_3.code == 200) {
|
||||
msgUtils.msgSuccess('生成PPT课件成功')
|
||||
//TODO 打开生成的课件
|
||||
const res = await getEntpcoursefile(parentid)
|
||||
if (res && res.code === 200) {
|
||||
openPublicScreen('edit', res.data, smarttalk.resData) // 打开公屏-窗口
|
||||
} else {
|
||||
ElMessage.warning(res.msg||'文件获取异常!')
|
||||
}
|
||||
} else {
|
||||
msgUtils.msgWarning('生成PPT课件失败')
|
||||
}
|
||||
|
@ -370,20 +361,7 @@ const addAiPPT = async (res) => {
|
|||
})
|
||||
}
|
||||
|
||||
const openPublicScreen = (type, resource, currData)=> {
|
||||
sessionStore.set('curr.resource', resource) // 缓存当前资源信息
|
||||
if (type=='edit') sessionStore.set('curr.smarttalk', currData) // 缓存当前文件smarttalk
|
||||
else sessionStore.set('curr.classcourse', currData) // 缓存当前当前上课
|
||||
createWindow('open-win', {
|
||||
url: '/pptist', // 窗口关闭时,清除缓存
|
||||
close: () => {
|
||||
sessionStore.set('curr.resource', null) // 清除缓存
|
||||
if (type=='edit') {
|
||||
sessionStore.set('curr.smarttalk', null) // 清除缓存
|
||||
} else sessionStore.set('curr.classcourse', null) // 清除缓存
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const isEdit = ref(false)
|
||||
// 当前操作的索引
|
||||
const curIndex = ref(-1)
|
||||
|
|
Loading…
Reference in New Issue