添加富文本url
This commit is contained in:
BIN
src/assets/image/jiace.png
Normal file
BIN
src/assets/image/jiace.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 477 KiB |
Binary file not shown.
Before Width: | Height: | Size: 369 KiB |
86
src/main.js
86
src/main.js
@ -1,56 +1,66 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue';
|
||||||
|
|
||||||
import Cookies from 'js-cookie'
|
import Cookies from 'js-cookie';
|
||||||
|
|
||||||
import 'normalize.css/normalize.css' // a modern alternative to CSS resets
|
import 'normalize.css/normalize.css'; // a modern alternative to CSS resets
|
||||||
|
|
||||||
import Element from 'element-ui'
|
import Element from 'element-ui';
|
||||||
import './assets/styles/element-variables.scss'
|
import './assets/styles/element-variables.scss';
|
||||||
|
|
||||||
import '@/assets/styles/index.scss' // global css
|
import '@/assets/styles/index.scss'; // global css
|
||||||
import '@/assets/styles/ruoyi.scss' // ruoyi css
|
import '@/assets/styles/ruoyi.scss'; // ruoyi css
|
||||||
import App from './App'
|
import App from './App';
|
||||||
import store from './store'
|
import store from './store';
|
||||||
import router from './router'
|
import router from './router';
|
||||||
import permission from './directive/permission'
|
import permission from './directive/permission';
|
||||||
|
|
||||||
import './assets/icons' // icon
|
import './assets/icons'; // icon
|
||||||
import './permission' // permission control
|
import './permission'; // permission control
|
||||||
import { getDicts } from "@/api/system/dict/data";
|
import { getDicts } from '@/api/system/dict/data';
|
||||||
import { getConfigKey } from "@/api/system/config";
|
import { getConfigKey } from '@/api/system/config';
|
||||||
import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, download, handleTree } from "@/utils/ruoyi";
|
import {
|
||||||
import Pagination from "@/components/Pagination";
|
parseTime,
|
||||||
|
resetForm,
|
||||||
|
addDateRange,
|
||||||
|
selectDictLabel,
|
||||||
|
selectDictLabels,
|
||||||
|
download,
|
||||||
|
handleTree
|
||||||
|
} from '@/utils/ruoyi';
|
||||||
|
import { formatRichText } from '@/utils/editor';
|
||||||
|
import Pagination from '@/components/Pagination';
|
||||||
//自定义表格工具扩展
|
//自定义表格工具扩展
|
||||||
import RightToolbar from "@/components/RightToolbar"
|
import RightToolbar from '@/components/RightToolbar';
|
||||||
|
|
||||||
// 全局方法挂载
|
// 全局方法挂载
|
||||||
Vue.prototype.getDicts = getDicts
|
Vue.prototype.getDicts = getDicts;
|
||||||
Vue.prototype.getConfigKey = getConfigKey
|
Vue.prototype.getConfigKey = getConfigKey;
|
||||||
Vue.prototype.parseTime = parseTime
|
Vue.prototype.parseTime = parseTime;
|
||||||
Vue.prototype.resetForm = resetForm
|
Vue.prototype.resetForm = resetForm;
|
||||||
Vue.prototype.addDateRange = addDateRange
|
Vue.prototype.addDateRange = addDateRange;
|
||||||
Vue.prototype.selectDictLabel = selectDictLabel
|
Vue.prototype.selectDictLabel = selectDictLabel;
|
||||||
Vue.prototype.selectDictLabels = selectDictLabels
|
Vue.prototype.selectDictLabels = selectDictLabels;
|
||||||
Vue.prototype.download = download
|
Vue.prototype.download = download;
|
||||||
Vue.prototype.handleTree = handleTree
|
Vue.prototype.handleTree = handleTree;
|
||||||
|
Vue.prototype.formatRichText = formatRichText;
|
||||||
|
|
||||||
Vue.prototype.msgSuccess = function(msg) {
|
Vue.prototype.msgSuccess = function(msg) {
|
||||||
this.$message({ showClose: true, message: msg, type: "success" });
|
this.$message({ showClose: true, message: msg, type: 'success' });
|
||||||
}
|
};
|
||||||
|
|
||||||
Vue.prototype.msgError = function(msg) {
|
Vue.prototype.msgError = function(msg) {
|
||||||
this.$message({ showClose: true, message: msg, type: "error" });
|
this.$message({ showClose: true, message: msg, type: 'error' });
|
||||||
}
|
};
|
||||||
|
|
||||||
Vue.prototype.msgInfo = function(msg) {
|
Vue.prototype.msgInfo = function(msg) {
|
||||||
this.$message.info(msg);
|
this.$message.info(msg);
|
||||||
}
|
};
|
||||||
|
|
||||||
// 全局组件挂载
|
// 全局组件挂载
|
||||||
Vue.component('Pagination', Pagination)
|
Vue.component('Pagination', Pagination);
|
||||||
Vue.component('RightToolbar', RightToolbar)
|
Vue.component('RightToolbar', RightToolbar);
|
||||||
|
|
||||||
Vue.use(permission)
|
Vue.use(permission);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If you don't want to use mock-server
|
* If you don't want to use mock-server
|
||||||
@ -63,13 +73,13 @@ Vue.use(permission)
|
|||||||
|
|
||||||
Vue.use(Element, {
|
Vue.use(Element, {
|
||||||
size: Cookies.get('size') || 'medium' // set element-ui default size
|
size: Cookies.get('size') || 'medium' // set element-ui default size
|
||||||
})
|
});
|
||||||
|
|
||||||
Vue.config.productionTip = false
|
Vue.config.productionTip = false;
|
||||||
|
|
||||||
new Vue({
|
new Vue({
|
||||||
el: '#app',
|
el: '#app',
|
||||||
router,
|
router,
|
||||||
store,
|
store,
|
||||||
render: h => h(App)
|
render: h => h(App)
|
||||||
})
|
});
|
||||||
|
51
src/utils/editor.js
Normal file
51
src/utils/editor.js
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
export function formatRichText(url) {
|
||||||
|
let src = document.querySelectorAll('#text .ql-editor img');
|
||||||
|
console.log(src);
|
||||||
|
for (let i = 0; i < src.length; i++) {
|
||||||
|
const string = src[i].getAttribute('src');
|
||||||
|
src[i].setAttribute('src', url + string);
|
||||||
|
}
|
||||||
|
let src2 = document.querySelectorAll('#text .ql-editor a');
|
||||||
|
for (let i = 0; i < src2.length; i++) {
|
||||||
|
const string = src2[i].getAttribute('href');
|
||||||
|
src2[i].setAttribute('href', url + string);
|
||||||
|
}
|
||||||
|
// console.log(document.querySelectorAll('#text .ql-editor a'));
|
||||||
|
// var imgReg = /<img.*?(?:>|\/>)/gi;
|
||||||
|
// var srcReg = /src=[\'\"]?([^\'\"]*)[\'\"]?/i;
|
||||||
|
// var arr = html.match(imgReg);
|
||||||
|
// // console.log(arr);
|
||||||
|
// for (let i = 0; i < arr.length; i++) {
|
||||||
|
// let src = arr[i].match(srcReg);
|
||||||
|
// //获取图片地址
|
||||||
|
// console.log(html);
|
||||||
|
// console.log(src[1]);
|
||||||
|
// if (src[1]) {
|
||||||
|
// var newContent = html.replace(
|
||||||
|
// /\<img/gi,
|
||||||
|
// `<img src="${url}${src[1]}"`
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return this.aaa(url, newContent);
|
||||||
|
}
|
||||||
|
// function aaa(url, html) {
|
||||||
|
// console.log(url);
|
||||||
|
// console.log(html);
|
||||||
|
// var aReg = /<a.*?(?:>|\/>)/gi;
|
||||||
|
// var hrefReg = /href=[\'\"]?([^\'\"]*)[\'\"]?/i;
|
||||||
|
// var arr2 = html.match(aReg);
|
||||||
|
// for (let i = 0; i < arr2.length; i++) {
|
||||||
|
// let src = arr2[i].match(hrefReg);
|
||||||
|
// //获取图片地址
|
||||||
|
// if (src[1]) {
|
||||||
|
// var newContent = html.replace(/\<a/gi, `<a href="${url}${src[1]}"`);
|
||||||
|
// }
|
||||||
|
// // 替换src
|
||||||
|
// // if (src[0]) {
|
||||||
|
// // var t = src[0].replace(/src/i, 'href');
|
||||||
|
// // console.log(t);
|
||||||
|
// // }
|
||||||
|
// }
|
||||||
|
// return newContent;
|
||||||
|
// }
|
@ -2,7 +2,7 @@
|
|||||||
<div class="login">
|
<div class="login">
|
||||||
<div class="login-title">
|
<div class="login-title">
|
||||||
<!-- <img src="../assets/image/logo.png" alt="" /> -->
|
<!-- <img src="../assets/image/logo.png" alt="" /> -->
|
||||||
<span>嘉策科技创新服务平台</span>
|
<!-- <span>嘉策科技创新服务平台</span> -->
|
||||||
</div>
|
</div>
|
||||||
<el-form
|
<el-form
|
||||||
ref="loginForm"
|
ref="loginForm"
|
||||||
@ -70,28 +70,26 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Cookies from "js-cookie";
|
import Cookies from 'js-cookie';
|
||||||
import { encrypt, decrypt } from "@/utils/jsencrypt";
|
import { encrypt, decrypt } from '@/utils/jsencrypt';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Login",
|
name: 'Login',
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
loginForm: {
|
loginForm: {
|
||||||
username: "ailanyin",
|
username: 'ailanyin',
|
||||||
password: "ailanyin",
|
password: 'ailanyin',
|
||||||
rememberMe: false,
|
rememberMe: false
|
||||||
},
|
},
|
||||||
loginRules: {
|
loginRules: {
|
||||||
username: [
|
username: [
|
||||||
{ required: true, trigger: "blur", message: "用户名不能为空" },
|
{ required: true, trigger: 'blur', message: '用户名不能为空' }
|
||||||
],
|
|
||||||
password: [
|
|
||||||
{ required: true, trigger: "blur", message: "密码不能为空" },
|
|
||||||
],
|
],
|
||||||
|
password: [{ required: true, trigger: 'blur', message: '密码不能为空' }]
|
||||||
},
|
},
|
||||||
loading: false,
|
loading: false,
|
||||||
redirect: undefined,
|
redirect: undefined
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@ -99,53 +97,53 @@ export default {
|
|||||||
handler: function(route) {
|
handler: function(route) {
|
||||||
this.redirect = route.query && route.query.redirect;
|
this.redirect = route.query && route.query.redirect;
|
||||||
},
|
},
|
||||||
immediate: true,
|
immediate: true
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.getCookie();
|
this.getCookie();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getCookie() {
|
getCookie() {
|
||||||
const username = Cookies.get("username");
|
const username = Cookies.get('username');
|
||||||
const password = Cookies.get("password");
|
const password = Cookies.get('password');
|
||||||
const rememberMe = Cookies.get("rememberMe");
|
const rememberMe = Cookies.get('rememberMe');
|
||||||
this.loginForm = {
|
this.loginForm = {
|
||||||
username: username === undefined ? this.loginForm.username : username,
|
username: username === undefined ? this.loginForm.username : username,
|
||||||
password:
|
password:
|
||||||
password === undefined ? this.loginForm.password : decrypt(password),
|
password === undefined ? this.loginForm.password : decrypt(password),
|
||||||
rememberMe: rememberMe === undefined ? false : Boolean(rememberMe),
|
rememberMe: rememberMe === undefined ? false : Boolean(rememberMe)
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
handleLogin() {
|
handleLogin() {
|
||||||
this.$refs.loginForm.validate((valid) => {
|
this.$refs.loginForm.validate(valid => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
if (this.loginForm.rememberMe) {
|
if (this.loginForm.rememberMe) {
|
||||||
Cookies.set("username", this.loginForm.username, { expires: 30 });
|
Cookies.set('username', this.loginForm.username, { expires: 30 });
|
||||||
Cookies.set("password", encrypt(this.loginForm.password), {
|
Cookies.set('password', encrypt(this.loginForm.password), {
|
||||||
expires: 30,
|
expires: 30
|
||||||
});
|
});
|
||||||
Cookies.set("rememberMe", this.loginForm.rememberMe, {
|
Cookies.set('rememberMe', this.loginForm.rememberMe, {
|
||||||
expires: 30,
|
expires: 30
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
Cookies.remove("username");
|
Cookies.remove('username');
|
||||||
Cookies.remove("password");
|
Cookies.remove('password');
|
||||||
Cookies.remove("rememberMe");
|
Cookies.remove('rememberMe');
|
||||||
}
|
}
|
||||||
this.$store
|
this.$store
|
||||||
.dispatch("Login", this.loginForm)
|
.dispatch('Login', this.loginForm)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.$router.push({ path: this.redirect || "/" });
|
this.$router.push({ path: this.redirect || '/' });
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -158,7 +156,7 @@ $loginForm: 383px;
|
|||||||
// align-items: center;
|
// align-items: center;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
min-height: $loginHeight;
|
min-height: $loginHeight;
|
||||||
// background-image: url('../assets/image/login-bg.jpg');
|
background-image: url('../assets/image/jiace.png');
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,9 @@
|
|||||||
<el-input placeholder="请输入" v-model="ruleForm.source"></el-input>
|
<el-input placeholder="请输入" v-model="ruleForm.source"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="正文" prop="text">
|
<el-form-item label="正文" prop="text">
|
||||||
|
<div id="text">
|
||||||
<editor v-model="ruleForm.text" :min-height="192" />
|
<editor v-model="ruleForm.text" :min-height="192" />
|
||||||
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" @click="submitForm('ruleForm')"
|
<el-button type="primary" @click="submitForm('ruleForm')"
|
||||||
@ -155,6 +157,16 @@ export default {
|
|||||||
// this.$refs[formName].resetFields();
|
// this.$refs[formName].resetFields();
|
||||||
// }
|
// }
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
ruleForm: {
|
||||||
|
handler: function() {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.formatRichText(this.ruleForm.downloadUrl);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
deep: true
|
||||||
|
},
|
||||||
created() {
|
created() {
|
||||||
let { id } = this.$route.query;
|
let { id } = this.$route.query;
|
||||||
if (id) {
|
if (id) {
|
||||||
|
@ -12,8 +12,9 @@
|
|||||||
<el-form-item label="成果标题" prop="title">
|
<el-form-item label="成果标题" prop="title">
|
||||||
<el-input placeholder="请输入" v-model="ruleForm.title"></el-input>
|
<el-input placeholder="请输入" v-model="ruleForm.title"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="成果图片" prop="image">
|
<el-form-item label="成果图片" prop="pic">
|
||||||
<multi-upload v-model="ruleForm.image"></multi-upload>
|
<!-- :maxCount="1" -->
|
||||||
|
<multi-upload v-model="selectProductPics"></multi-upload>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="技术领域" prop="level">
|
<el-form-item label="技术领域" prop="level">
|
||||||
<el-select v-model="ruleForm.level" placeholder="请选择">
|
<el-select v-model="ruleForm.level" placeholder="请选择">
|
||||||
@ -70,12 +71,21 @@ export default {
|
|||||||
MultiUpload
|
MultiUpload
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
// var valiIcon = (rule, value, callback) => {
|
||||||
|
// // 图片验证
|
||||||
|
// if (!this.selectProductPics[0]) {
|
||||||
|
// callback(new Error('请上传成果图片'));
|
||||||
|
// } else {
|
||||||
|
// callback();
|
||||||
|
// }
|
||||||
|
// };
|
||||||
return {
|
return {
|
||||||
aaa: '',
|
aaa: '',
|
||||||
bbb: '',
|
bbb: '',
|
||||||
editPage: false,
|
editPage: false,
|
||||||
ruleForm: {
|
ruleForm: {
|
||||||
title: '',
|
title: '',
|
||||||
|
pic: '',
|
||||||
level: '',
|
level: '',
|
||||||
attribute: '',
|
attribute: '',
|
||||||
source: '',
|
source: '',
|
||||||
@ -123,9 +133,55 @@ export default {
|
|||||||
source: [{ required: true, message: '请填写', trigger: 'blur' }],
|
source: [{ required: true, message: '请填写', trigger: 'blur' }],
|
||||||
source2: [{ required: true, message: '请填写', trigger: 'blur' }],
|
source2: [{ required: true, message: '请填写', trigger: 'blur' }],
|
||||||
text: [{ required: true, message: '请填写内容', trigger: 'blur' }]
|
text: [{ required: true, message: '请填写内容', trigger: 'blur' }]
|
||||||
|
// pic: [{ required: true, validator: valiIcon }]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
//商品的主图和画册图片
|
||||||
|
selectProductPics: {
|
||||||
|
get: function() {
|
||||||
|
let pics = [];
|
||||||
|
if (
|
||||||
|
this.ruleForm.pic === undefined ||
|
||||||
|
this.ruleForm.pic == null ||
|
||||||
|
this.ruleForm.pic === ''
|
||||||
|
) {
|
||||||
|
return pics;
|
||||||
|
}
|
||||||
|
pics.push(this.value.pic);
|
||||||
|
// if (
|
||||||
|
// this.value.albumPics === undefined ||
|
||||||
|
// this.value.albumPics == null ||
|
||||||
|
// this.value.albumPics === ''
|
||||||
|
// ) {
|
||||||
|
// return pics;
|
||||||
|
// }
|
||||||
|
// let albumPics = this.value.albumPics.split(',');
|
||||||
|
// for (let i = 0; i < albumPics.length; i++) {
|
||||||
|
// pics.push(albumPics[i]);
|
||||||
|
// }
|
||||||
|
// return pics;
|
||||||
|
},
|
||||||
|
set: function(newValue) {
|
||||||
|
if (newValue == null || newValue.length === 0) {
|
||||||
|
this.ruleForm.pic = null;
|
||||||
|
// this.value.albumPics = null;
|
||||||
|
} else {
|
||||||
|
this.value.pic = newValue[0];
|
||||||
|
// this.value.albumPics = '';
|
||||||
|
// if (newValue.length > 1) {
|
||||||
|
// for (let i = 1; i < newValue.length; i++) {
|
||||||
|
// this.value.albumPics += newValue[i];
|
||||||
|
// if (i !== newValue.length - 1) {
|
||||||
|
// this.value.albumPics += ',';
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
submitForm(formName) {
|
submitForm(formName) {
|
||||||
this.$refs[formName].validate(valid => {
|
this.$refs[formName].validate(valid => {
|
||||||
|
Reference in New Issue
Block a user