✨ 新增only office组件
This commit is contained in:
parent
e32b5a9bb1
commit
2336b39a79
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "jmal-cloud-view",
|
||||
"version": "2.2.35",
|
||||
"version": "2.2.36",
|
||||
"description": "jmalcloud",
|
||||
"author": "Jmal <zhushilun084@163.com>",
|
||||
"license": "MIT",
|
||||
|
||||
@ -377,6 +377,7 @@
|
||||
<sim-text-preview :file.sync="textPreviewRow" :status.sync="textPreviewVisible"></sim-text-preview>
|
||||
<image-viewer :fileList="fileList" :file="imagePreviewRow" :status.sync="imagePreviewVisible"></image-viewer>
|
||||
<video-preview :file="videoPreviewRow" :status.sync="videoPreviewVisible"></video-preview>
|
||||
<office-preview :file="officePreviewRow" :status.sync="officePreviewVisible"></office-preview>
|
||||
<!-- <audio-preview :file="audioPreviewRow" :status.sync="audioPreviewVisible"></audio-preview> -->
|
||||
<!--文件详细信息-->
|
||||
<el-drawer
|
||||
@ -544,11 +545,13 @@ import '@/utils/directives.js'
|
||||
|
||||
import fileConfig from '@/utils/file-config'
|
||||
import EditElement from "@/views/markdown/EditElement";
|
||||
import OfficePreview from "@/components/preview/OfficePreview";
|
||||
|
||||
var rowStyleExecuting = false
|
||||
export default {
|
||||
name: 'ShowFile',
|
||||
components: {
|
||||
OfficePreview,
|
||||
EditElement,
|
||||
MessageDialog, AudioPreview, VideoPreview, ImageViewer, SimTextPreview, IconFile, BreadcrumbFilePath, EmptyFile,
|
||||
ButtonUpload,
|
||||
@ -774,6 +777,8 @@ export default {
|
||||
imagePreviewVisible: false,
|
||||
videoPreviewRow: {},
|
||||
videoPreviewVisible: false,
|
||||
officePreviewRow: {},
|
||||
officePreviewVisible: false,
|
||||
audioPreviewRow: {},
|
||||
audioPreviewVisible: false,
|
||||
drawer: false,
|
||||
@ -3109,6 +3114,12 @@ export default {
|
||||
Bus.$emit('onAddAudio', row, this.audioCoverUrl)
|
||||
return
|
||||
}
|
||||
if (row.contentType.indexOf('office') > -1) {
|
||||
// office文件
|
||||
this.officePreviewVisible = true
|
||||
this.officePreviewRow = row
|
||||
return
|
||||
}
|
||||
if (row.suffix === 'pdf') {
|
||||
// pdf文件
|
||||
fileConfig.preview(this.$store.state.user.name, row, this.$store.getters.token)
|
||||
|
||||
@ -5,36 +5,10 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.component-only-office {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
.placeholder {
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.office-loading {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 2;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
|
||||
import fileConfig from "@/utils/file-config";
|
||||
|
||||
export default {
|
||||
name: "OnlyOfficeEditor",
|
||||
props: {
|
||||
@ -70,7 +44,6 @@ export default {
|
||||
},
|
||||
|
||||
mounted() {
|
||||
//
|
||||
},
|
||||
|
||||
beforeDestroy() {
|
||||
@ -83,14 +56,13 @@ export default {
|
||||
computed: {
|
||||
|
||||
fileType() {
|
||||
return this.getType(this.value.type);
|
||||
return this.getType(this.value.suffix);
|
||||
},
|
||||
|
||||
fileName() {
|
||||
return this.value.name;
|
||||
},
|
||||
},
|
||||
|
||||
watch: {
|
||||
'value.id': {
|
||||
handler(id) {
|
||||
@ -98,10 +70,10 @@ export default {
|
||||
return;
|
||||
}
|
||||
this.loadIng++;
|
||||
$A.loadScript($A.apiUrl("../office/web-apps/apps/api/documents/api.js"), (e) => {
|
||||
$J.loadScript($J.apiUrl("http://nps.jmal.top:18849/web-apps/apps/api/documents/api.js"), (e) => {
|
||||
this.loadIng--;
|
||||
if (e !== null) {
|
||||
$A.modalAlert("组件加载失败!");
|
||||
$J.modalAlert("组件加载失败!");
|
||||
return;
|
||||
}
|
||||
if (!this.documentKey) {
|
||||
@ -138,61 +110,67 @@ export default {
|
||||
this.docEditor.destroyEditor();
|
||||
this.docEditor = null;
|
||||
}
|
||||
//
|
||||
let lang = "zh";
|
||||
switch (this.getLanguage()) {
|
||||
case 'CN':
|
||||
case 'TC':
|
||||
lang = "zh";
|
||||
break;
|
||||
default:
|
||||
lang = 'en';
|
||||
break;
|
||||
}
|
||||
//
|
||||
let fileKey = this.code || this.value.id;
|
||||
let fileName = $A.strExists(this.fileName, '.') ? this.fileName : (this.fileName + '.' + this.fileType);
|
||||
let fileName = $J.strExists(this.fileName, '.') ? this.fileName : (this.fileName + '.' + this.fileType);
|
||||
const config = {
|
||||
"document": {
|
||||
"fileType": this.fileType,
|
||||
"key": `${this.fileType}-${fileKey}-${keyAppend}`,
|
||||
"key": `${this.fileType}-${$J.randNum(0,45678)}`,
|
||||
"title": fileName,
|
||||
"url": `http://nginx/api/file/content/?id=${fileKey}&token=${this.userToken}`,
|
||||
//"url": window.location.origin + fileConfig.previewUrl(this.$store.state.user.name, this.value, this.$store.getters.token),
|
||||
"url": "http://nps.jmal.top:19957/download?fileName=new+%281%29.docx&userAddress=%2FUsers%2Fjmal%2FDownloads%2Ftest%2F",
|
||||
},
|
||||
"editorConfig": {
|
||||
"mode": "edit",
|
||||
"lang": lang,
|
||||
"lang": "zh",
|
||||
"user": {
|
||||
"id": this.userInfo.userid,
|
||||
"name": this.userInfo.nickname
|
||||
"id": this.$store.state.user.name,
|
||||
"name": this.$store.state.user.name
|
||||
},
|
||||
// "customization": {
|
||||
// "uiTheme": this.themeIsDark ? "theme-dark" : "theme-classic-light",
|
||||
// },
|
||||
"customization": {
|
||||
"uiTheme": this.themeIsDark ? "theme-dark" : "theme-classic-light",
|
||||
"logo": null,
|
||||
"autosave": true,
|
||||
"comments": true,
|
||||
"compactHeader": false,
|
||||
"compactToolbar": false,
|
||||
"compatibleFeatures": false,
|
||||
"forcesave": false,
|
||||
"help": false,
|
||||
"hideRightMenu": false,
|
||||
"hideRulers": false,
|
||||
"submitForm": false,
|
||||
"about": false,
|
||||
"feedback": false
|
||||
},
|
||||
"callbackUrl": `http://nginx/api/file/content/office?id=${fileKey}&token=${this.userToken}`,
|
||||
// "callbackUrl": `${window.location.origin}/api/office/track?jmal-token=${this.$store.getters.token}&fileName=new.docx&userAddress=%2FUsers%2Fjmal%2FDownloads%2Ftest%2F`,
|
||||
callbackUrl: "http://nps.jmal.top:19957/track?fileName=new+%281%29.docx&userAddress=%2FUsers%2Fjmal%2FDownloads%2Ftest%2F",
|
||||
}
|
||||
};
|
||||
if (/\/hideenOfficeTitle\//.test(window.navigator.userAgent)) {
|
||||
config.document.title = " ";
|
||||
}
|
||||
if ($A.leftExists(fileKey, "msgFile_")) {
|
||||
config.document.url = `http://nginx/api/dialog/msg/download/?msg_id=${$A.leftDelete(fileKey, "msgFile_")}&token=${this.userToken}`;
|
||||
} else if ($A.leftExists(fileKey, "taskFile_")) {
|
||||
config.document.url = `http://nginx/api/project/task/filedown/?file_id=${$A.leftDelete(fileKey, "taskFile_")}&token=${this.userToken}`;
|
||||
}
|
||||
if (this.readOnly) {
|
||||
config.editorConfig.mode = "view";
|
||||
config.editorConfig.callbackUrl = null;
|
||||
if (!config.editorConfig.user.id) {
|
||||
let viewer = $A.getStorageInt("viewer")
|
||||
if (!viewer) {
|
||||
viewer = $A.randNum(1000, 99999);
|
||||
$A.setStorage("viewer", viewer)
|
||||
}
|
||||
config.editorConfig.user.id = "viewer_" + viewer;
|
||||
config.editorConfig.user.name = "Viewer_" + viewer
|
||||
}
|
||||
}
|
||||
console.log(config.document, config.editorConfig)
|
||||
// if ($J.leftExists(fileKey, "msgFile_")) {
|
||||
// config.document.url = `http://nginx/api/dialog/msg/download/?msg_id=${$J.leftDelete(fileKey, "msgFile_")}&token=${this.userToken}`;
|
||||
// } else if ($J.leftExists(fileKey, "taskFile_")) {
|
||||
// config.document.url = `http://nginx/api/project/task/filedown/?file_id=${$J.leftDelete(fileKey, "taskFile_")}&token=${this.userToken}`;
|
||||
// }
|
||||
// if (this.readOnly) {
|
||||
// config.editorConfig.mode = "view";
|
||||
// config.editorConfig.callbackUrl = null;
|
||||
// if (!config.editorConfig.user.id) {
|
||||
// let viewer = $J.getStorageInt("viewer")
|
||||
// if (!viewer) {
|
||||
// viewer = $J.randNum(1000, 99999);
|
||||
// $J.setStorage("viewer", viewer)
|
||||
// }
|
||||
// config.editorConfig.user.id = "viewer_" + viewer;
|
||||
// config.editorConfig.user.name = "Viewer_" + viewer
|
||||
// }
|
||||
// }
|
||||
this.$nextTick(() => {
|
||||
this.docEditor = new DocsAPI.DocEditor(this.id, config);
|
||||
})
|
||||
@ -200,3 +178,6 @@ export default {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
||||
|
||||
146
src/components/preview/OfficePreview.vue
Normal file
146
src/components/preview/OfficePreview.vue
Normal file
@ -0,0 +1,146 @@
|
||||
<template>
|
||||
<div class="preview" v-if="show">
|
||||
<van-overlay :show="show">
|
||||
<div class="block">
|
||||
<div class="close-bar" @click="close">
|
||||
<svg-icon class="preview-close" icon-class="close"/>
|
||||
</div>
|
||||
<div class="wrapper">
|
||||
<div class="block">
|
||||
<only-office-editor v-model="file" :documentKey="documentKey"></only-office-editor>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</van-overlay>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import 'vue-video-player/src/custom-theme.css'
|
||||
import 'video.js/dist/video-js.css'
|
||||
import OnlyOfficeEditor from "@/components/office/OnlyOfficeEditor";
|
||||
import fileConfig from "@/utils/file-config";
|
||||
|
||||
export default {
|
||||
name: 'OfficePreview',
|
||||
components: {
|
||||
OnlyOfficeEditor,
|
||||
},
|
||||
props: {
|
||||
file: {
|
||||
type: Object,
|
||||
default: function () {
|
||||
return {}
|
||||
}
|
||||
},
|
||||
shareId: {
|
||||
type: String,
|
||||
default: undefined
|
||||
},
|
||||
status: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
pc: this.$pc,
|
||||
show: this.status,
|
||||
url: '',
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
status: function(visible){
|
||||
if(visible){
|
||||
this.url = fileConfig.previewUrl(this.$store.state.user.name, this.file, this.$store.getters.token)
|
||||
if(this.shareId){
|
||||
this.url = fileConfig.publicPreviewUrl(this.file.id, window.shareId);
|
||||
}
|
||||
this.show = true
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
close() {
|
||||
this.show = false
|
||||
this.$emit('update:status', false)
|
||||
},
|
||||
documentKey() {
|
||||
console.log("documentKey")
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
.preview {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 1002;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.van-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 1003;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(0,0,0,.7);
|
||||
}
|
||||
|
||||
.block {
|
||||
.close-bar {
|
||||
z-index: 2006;
|
||||
background-color: rgba(0,0,0,.5);
|
||||
position: relative;
|
||||
top: -36px;
|
||||
right: -36px;
|
||||
float: right;
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-radius: 36px;
|
||||
border-width: 36px;
|
||||
border-style: solid;
|
||||
border-color: transparent transparent transparent #d4d4d475;
|
||||
line-height: 36px;
|
||||
opacity: 1;
|
||||
transform: rotate(-45deg);
|
||||
}
|
||||
|
||||
.close-bar:hover {
|
||||
cursor: pointer;
|
||||
border-color: transparent transparent transparent #69696975;
|
||||
}
|
||||
|
||||
.preview-close {
|
||||
transform: rotate(-45deg);
|
||||
z-index: 2009;
|
||||
position: absolute;
|
||||
font-size: 18px;
|
||||
top: -8px;
|
||||
right: 13px;
|
||||
}
|
||||
}
|
||||
|
||||
.wrapper {
|
||||
|
||||
>>> .component-only-office {
|
||||
position: absolute;
|
||||
top: 36px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
@ -1,5 +1,8 @@
|
||||
import 'normalize.css/normalize.css' // A modern alternative to CSS resets
|
||||
|
||||
import '@/utils/common'
|
||||
import '@/utils/web'
|
||||
|
||||
import '@/styles/index.scss' // global css
|
||||
import uploader from 'vue-simple-uploader'
|
||||
import EVueContextmenu from 'e-vue-contextmenu'
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* 基础函数
|
||||
*/
|
||||
(function (window, $, undefined) {
|
||||
(function (window, fuc, undefined) {
|
||||
window.systemInfo = window.systemInfo || {};
|
||||
|
||||
/**
|
||||
@ -9,7 +9,7 @@
|
||||
* ******************************* 基础函数类 *******************************
|
||||
* =============================================================================
|
||||
*/
|
||||
$.extend({
|
||||
fuc.extend({
|
||||
/**
|
||||
* 是否数组
|
||||
* @param obj
|
||||
@ -27,20 +27,6 @@
|
||||
isJson(obj) {
|
||||
return typeof (obj) == "object" && Object.prototype.toString.call(obj).toLowerCase() === "[object object]" && typeof obj.length == "undefined";
|
||||
},
|
||||
|
||||
/**
|
||||
* 是否在数组里
|
||||
* @param key
|
||||
* @param array
|
||||
* @returns {boolean|*}
|
||||
*/
|
||||
inArray(key, array) {
|
||||
if (!this.isArray(array)) {
|
||||
return false;
|
||||
}
|
||||
return array.includes(key);
|
||||
},
|
||||
|
||||
/**
|
||||
* 随机获取范围
|
||||
* @param Min
|
||||
@ -168,21 +154,6 @@
|
||||
return string;
|
||||
},
|
||||
|
||||
/**
|
||||
* 截取字符串
|
||||
* @param string
|
||||
* @param start
|
||||
* @param end
|
||||
* @returns {string}
|
||||
*/
|
||||
subString(string, start, end) {
|
||||
string += "";
|
||||
if (!this.isHave(end)) {
|
||||
end = string.length;
|
||||
}
|
||||
return string.substring(start, end);
|
||||
},
|
||||
|
||||
/**
|
||||
* 随机字符
|
||||
* @param len
|
||||
@ -232,63 +203,7 @@
|
||||
return _s;
|
||||
},
|
||||
|
||||
/**
|
||||
* 返回10位数时间戳
|
||||
* @param v
|
||||
* @returns {number}
|
||||
* @constructor
|
||||
*/
|
||||
Time(v) {
|
||||
let time
|
||||
if (typeof v === "string" && this.strExists(v, "-")) {
|
||||
v = v.replace(/-/g, '/');
|
||||
time = new Date(v).getTime();
|
||||
} else {
|
||||
time = new Date().getTime();
|
||||
}
|
||||
return Math.round(time / 1000)
|
||||
},
|
||||
|
||||
/**
|
||||
* 返回 时间对象|时间戳
|
||||
* @param v
|
||||
* @param stamp 是否返回时间戳
|
||||
* @returns {Date|number}
|
||||
* @constructor
|
||||
*/
|
||||
Date(v, stamp = false) {
|
||||
if (typeof v === "string" && this.strExists(v, "-")) {
|
||||
v = v.replace(/-/g, '/');
|
||||
}
|
||||
if (stamp === true) {
|
||||
return Math.round(new Date(v).getTime() / 1000)
|
||||
}
|
||||
return new Date(v);
|
||||
},
|
||||
|
||||
/**
|
||||
* 补零
|
||||
* @param str
|
||||
* @param length
|
||||
* @param after
|
||||
* @returns {*}
|
||||
*/
|
||||
zeroFill(str, length, after) {
|
||||
str+= "";
|
||||
if (str.length >= length) {
|
||||
return str;
|
||||
}
|
||||
let _str = '', _ret = '';
|
||||
for (let i = 0; i < length; i++) {
|
||||
_str += '0';
|
||||
}
|
||||
if (after || typeof after === 'undefined') {
|
||||
_ret = (_str + "" + str).substr(length * -1);
|
||||
} else {
|
||||
_ret = (str + "" + _str).substr(0, length);
|
||||
}
|
||||
return _ret;
|
||||
},
|
||||
|
||||
/**
|
||||
* 时间戳转时间格式
|
||||
@ -319,7 +234,7 @@
|
||||
} else {
|
||||
return v;
|
||||
}
|
||||
dateObj = $A.Date(v);
|
||||
dateObj = $J.Date(v);
|
||||
}
|
||||
//
|
||||
format = format.replace(/Y/g, dateObj.getFullYear());
|
||||
@ -339,7 +254,7 @@
|
||||
*/
|
||||
timeDiff(s, e) {
|
||||
if (typeof e === 'undefined') {
|
||||
e = $A.Time();
|
||||
e = $J.Time();
|
||||
}
|
||||
let d = e - s;
|
||||
if (d > 86400) {
|
||||
@ -448,7 +363,7 @@
|
||||
if(typeof(myObj) !== 'object') return myObj;
|
||||
if(myObj === null) return myObj;
|
||||
//
|
||||
return $A.jsonParse($A.jsonStringify(myObj))
|
||||
return $J.jsonParse($J.jsonStringify(myObj))
|
||||
},
|
||||
|
||||
/**
|
||||
@ -494,7 +409,7 @@
|
||||
* @param callback
|
||||
*/
|
||||
resize(obj, callback) {
|
||||
let myObj = $A(obj);
|
||||
let myObj = $J(obj);
|
||||
if (myObj.length === 0) return;
|
||||
let height = parseInt(myObj.outerHeight()),
|
||||
width = parseInt(myObj.outerWidth());
|
||||
@ -611,7 +526,7 @@
|
||||
return "";
|
||||
}
|
||||
let str = "";
|
||||
$A.each(obj, (val) => {
|
||||
$J.each(obj, (val) => {
|
||||
if (val !== null) {
|
||||
if (typeof val === "object" && this.count(val) > 0) {
|
||||
str += this.objImplode(val);
|
||||
@ -658,7 +573,7 @@
|
||||
removeURLParameter(url, parameter) {
|
||||
if (parameter instanceof Array) {
|
||||
parameter.forEach((key) => {
|
||||
url = $A.removeURLParameter(url, key)
|
||||
url = $J.removeURLParameter(url, key)
|
||||
});
|
||||
return url;
|
||||
}
|
||||
@ -688,7 +603,7 @@
|
||||
* @returns {*}
|
||||
*/
|
||||
urlAddParams(url, params) {
|
||||
if ($A.isJson(params)) {
|
||||
if ($J.isJson(params)) {
|
||||
if (url) {
|
||||
url = this.removeURLParameter(url, Object.keys(params))
|
||||
}
|
||||
@ -763,7 +678,7 @@
|
||||
if (object === null || typeof object !== "object") return;
|
||||
if (typeof object.length === 'number' && object.length > 0) object = object[0];
|
||||
|
||||
let ele = typeof object.$el === "object" ? $A(object.$el) : $A(object);
|
||||
let ele = typeof object.$el === "object" ? $J(object.$el) : $J(object);
|
||||
if (ele.length === 0) return;
|
||||
let eleDom = ele[0];
|
||||
|
||||
@ -811,7 +726,7 @@
|
||||
* @param callback
|
||||
*/
|
||||
loadScript(url, callback) {
|
||||
url = $A.originUrl(url);
|
||||
url = $J.originUrl(url);
|
||||
if (this.rightExists(url, '.css')) {
|
||||
this.loadCss(url, callback)
|
||||
return;
|
||||
@ -865,7 +780,7 @@
|
||||
* @param callback
|
||||
*/
|
||||
loadCss(url, callback) {
|
||||
url = $A.originUrl(url);
|
||||
url = $J.originUrl(url);
|
||||
if (this.rightExists(url, '.js')) {
|
||||
this.loadScript(url, callback)
|
||||
return;
|
||||
@ -929,17 +844,17 @@
|
||||
format = "Y-m-d H:i:s";
|
||||
}
|
||||
if (params instanceof Date) {
|
||||
params = $A.formatDate(format, params);
|
||||
} else if ($A.isJson(params)) {
|
||||
params = $J.formatDate(format, params);
|
||||
} else if ($J.isJson(params)) {
|
||||
params = Object.assign({}, params)
|
||||
for (let key in params) {
|
||||
if (!params.hasOwnProperty(key)) continue;
|
||||
params[key] = $A.date2string(params[key], format);
|
||||
params[key] = $J.date2string(params[key], format);
|
||||
}
|
||||
} else if ($A.isArray(params)) {
|
||||
} else if ($J.isArray(params)) {
|
||||
params = Object.assign([], params)
|
||||
params.forEach((val, index) => {
|
||||
params[index] = $A.date2string(val, format);
|
||||
params[index] = $J.date2string(val, format);
|
||||
});
|
||||
}
|
||||
return params;
|
||||
@ -958,7 +873,7 @@
|
||||
if (typeof sizes[i] === "undefined") {
|
||||
return '0 B';
|
||||
}
|
||||
return $A.runNum((bytes / Math.pow(k, i)), 2) + ' ' + sizes[i];
|
||||
return $J.runNum((bytes / Math.pow(k, i)), 2) + ' ' + sizes[i];
|
||||
},
|
||||
|
||||
/**
|
||||
@ -1014,7 +929,7 @@
|
||||
* ******************************** storage ********************************
|
||||
* =============================================================================
|
||||
*/
|
||||
$.extend({
|
||||
fuc.extend({
|
||||
setStorage(key, value) {
|
||||
return this.storage(key, value);
|
||||
},
|
||||
@ -1102,7 +1017,7 @@
|
||||
* ********************************* ihttp *********************************
|
||||
* =============================================================================
|
||||
*/
|
||||
$.extend({
|
||||
fuc.extend({
|
||||
serializeObject(obj, parents) {
|
||||
if (typeof obj === 'string') return obj;
|
||||
let resultArray = [];
|
||||
@ -1446,7 +1361,7 @@
|
||||
* ***************************** ajaxc ****************************
|
||||
* =============================================================================
|
||||
*/
|
||||
$.extend({
|
||||
fuc.extend({
|
||||
ajaxc(params) {
|
||||
if (!params) return false;
|
||||
if (typeof params.url === 'undefined') return false;
|
||||
@ -1463,7 +1378,7 @@
|
||||
if (typeof params.header == 'undefined') params.header = {};
|
||||
//
|
||||
params.before();
|
||||
$A.ihttp({
|
||||
$J.ihttp({
|
||||
url: params.url,
|
||||
data: params.data,
|
||||
cache: params.cache,
|
||||
@ -1487,5 +1402,5 @@
|
||||
}
|
||||
});
|
||||
|
||||
window.$A = $;
|
||||
})(window, window.$ = window.jQuery = require('jquery'));
|
||||
window.$J = fuc;
|
||||
})(window, window.fuc = window.jQuery = require('jquery'));
|
||||
|
||||
@ -53,6 +53,8 @@ iconClass.set('pkg','file-pkg')
|
||||
iconClass.set('mpkg','file-pkg')
|
||||
iconClass.set('exe','file-exe')
|
||||
iconClass.set('word','file-word')
|
||||
iconClass.set('doc','file-word')
|
||||
iconClass.set('docx','file-word')
|
||||
iconClass.set('pdf','file-pdf')
|
||||
iconClass.set('zip','zip')
|
||||
iconClass.set('rar','zip')
|
||||
|
||||
126
src/utils/web.js
126
src/utils/web.js
@ -2,7 +2,7 @@
|
||||
* 页面专用
|
||||
*/
|
||||
(function (window) {
|
||||
const $ = window.$A;
|
||||
const $ = window.$J;
|
||||
/**
|
||||
* =============================================================================
|
||||
* ******************************* web extra *******************************
|
||||
@ -81,14 +81,14 @@
|
||||
* @param data
|
||||
*/
|
||||
formatWebsocketMessageDetail(data) {
|
||||
if ($A.isJson(data)) {
|
||||
if ($J.isJson(data)) {
|
||||
for (let key in data) {
|
||||
if (!data.hasOwnProperty(key)) continue;
|
||||
data[key] = $A.formatWebsocketMessageDetail(data[key]);
|
||||
data[key] = $J.formatWebsocketMessageDetail(data[key]);
|
||||
}
|
||||
} else if ($A.isArray(data)) {
|
||||
} else if ($J.isArray(data)) {
|
||||
data.forEach((val, index) => {
|
||||
data[index] = $A.formatWebsocketMessageDetail(val);
|
||||
data[index] = $J.formatWebsocketMessageDetail(val);
|
||||
});
|
||||
} else if (typeof data === "string") {
|
||||
data = data.replace(/\{\{RemoteURL\}\}/g, this.apiUrl('../'))
|
||||
@ -102,14 +102,14 @@
|
||||
* @returns {*|string}
|
||||
*/
|
||||
formatTime(date) {
|
||||
let time = $A.Date(date, true),
|
||||
let time = $J.Date(date, true),
|
||||
string = '';
|
||||
if ($A.formatDate('Ymd') === $A.formatDate('Ymd', time)) {
|
||||
string = $A.formatDate('H:i', time)
|
||||
} else if ($A.formatDate('Y') === $A.formatDate('Y', time)) {
|
||||
string = $A.formatDate('m-d', time)
|
||||
if ($J.formatDate('Ymd') === $J.formatDate('Ymd', time)) {
|
||||
string = $J.formatDate('H:i', time)
|
||||
} else if ($J.formatDate('Y') === $J.formatDate('Y', time)) {
|
||||
string = $J.formatDate('m-d', time)
|
||||
} else {
|
||||
string = $A.formatDate('Y-m-d', time)
|
||||
string = $J.formatDate('Y-m-d', time)
|
||||
}
|
||||
return string || '';
|
||||
},
|
||||
@ -262,7 +262,7 @@
|
||||
if (retInt === true) {
|
||||
return time;
|
||||
}
|
||||
return $A.formatDate("Y-m-d", parseInt(time / 1000))
|
||||
return $J.formatDate("Y-m-d", parseInt(time / 1000))
|
||||
},
|
||||
|
||||
/**
|
||||
@ -271,46 +271,46 @@
|
||||
*/
|
||||
timeOptionShortcuts() {
|
||||
const lastSecond = (e) => {
|
||||
return $A.Date($A.formatDate("Y-m-d 23:59:29", Math.round(e / 1000)))
|
||||
return $J.Date($J.formatDate("Y-m-d 23:59:29", Math.round(e / 1000)))
|
||||
};
|
||||
return [{
|
||||
text: $A.L('今天'),
|
||||
text: $J.L('今天'),
|
||||
value() {
|
||||
return [new Date(), lastSecond(new Date().getTime())];
|
||||
}
|
||||
}, {
|
||||
text: $A.L('明天'),
|
||||
text: $J.L('明天'),
|
||||
value() {
|
||||
let e = new Date();
|
||||
e.setDate(e.getDate() + 1);
|
||||
return [new Date(), lastSecond(e.getTime())];
|
||||
}
|
||||
}, {
|
||||
text: $A.L('本周'),
|
||||
text: $J.L('本周'),
|
||||
value() {
|
||||
return [$A.getData('今天', true), lastSecond($A.getData('本周结束2', true))];
|
||||
return [$J.getData('今天', true), lastSecond($J.getData('本周结束2', true))];
|
||||
}
|
||||
}, {
|
||||
text: $A.L('本月'),
|
||||
text: $J.L('本月'),
|
||||
value() {
|
||||
return [$A.getData('今天', true), lastSecond($A.getData('本月结束', true))];
|
||||
return [$J.getData('今天', true), lastSecond($J.getData('本月结束', true))];
|
||||
}
|
||||
}, {
|
||||
text: $A.L('3天'),
|
||||
text: $J.L('3天'),
|
||||
value() {
|
||||
let e = new Date();
|
||||
e.setDate(e.getDate() + 2);
|
||||
return [new Date(), lastSecond(e.getTime())];
|
||||
}
|
||||
}, {
|
||||
text: $A.L('5天'),
|
||||
text: $J.L('5天'),
|
||||
value() {
|
||||
let e = new Date();
|
||||
e.setDate(e.getDate() + 4);
|
||||
return [new Date(), lastSecond(e.getTime())];
|
||||
}
|
||||
}, {
|
||||
text: $A.L('7天'),
|
||||
text: $J.L('7天'),
|
||||
value() {
|
||||
let e = new Date();
|
||||
e.setDate(e.getDate() + 6);
|
||||
@ -327,7 +327,7 @@
|
||||
dialogTags(dialog) {
|
||||
let tags = [];
|
||||
if (dialog.type === 'group') {
|
||||
if (['project', 'task'].includes(dialog.group_type) && $A.isJson(dialog.group_info)) {
|
||||
if (['project', 'task'].includes(dialog.group_type) && $J.isJson(dialog.group_info)) {
|
||||
if (dialog.group_type === 'task' && dialog.group_info.complete_at) {
|
||||
tags.push({
|
||||
color: 'success',
|
||||
@ -377,8 +377,8 @@
|
||||
$.extend({
|
||||
// 加载器
|
||||
spinnerShow() {
|
||||
$A.spinnerLoadNum++
|
||||
if ($A.spinnerLoadNum > 0) {
|
||||
$J.spinnerLoadNum++
|
||||
if ($J.spinnerLoadNum > 0) {
|
||||
const spinner = document.getElementById("common-spinner");
|
||||
if (spinner) {
|
||||
spinner.style.display = "block"
|
||||
@ -387,8 +387,8 @@
|
||||
},
|
||||
|
||||
spinnerHide() {
|
||||
$A.spinnerLoadNum--
|
||||
if ($A.spinnerLoadNum <= 0) {
|
||||
$J.spinnerLoadNum--
|
||||
if ($J.spinnerLoadNum <= 0) {
|
||||
const spinner = document.getElementById("common-spinner");
|
||||
if (spinner) {
|
||||
spinner.style.display = "none"
|
||||
@ -404,29 +404,29 @@
|
||||
} else if (typeof config === "string") {
|
||||
config = {content: config};
|
||||
}
|
||||
config.title = $A.L(config.title || (typeof config.render === 'undefined' ? '温馨提示' : ''));
|
||||
config.content = $A.L(config.content || '');
|
||||
config.okText = $A.L(config.okText || '确定');
|
||||
config.cancelText = $A.L(config.cancelText || '取消');
|
||||
config.title = $J.L(config.title || (typeof config.render === 'undefined' ? '温馨提示' : ''));
|
||||
config.content = $J.L(config.content || '');
|
||||
config.okText = $J.L(config.okText || '确定');
|
||||
config.cancelText = $J.L(config.cancelText || '取消');
|
||||
return config;
|
||||
},
|
||||
|
||||
modalInput(config, millisecond = 0) {
|
||||
if (millisecond > 0) {
|
||||
setTimeout(() => { $A.modalInput(config) }, millisecond);
|
||||
setTimeout(() => { $J.modalInput(config) }, millisecond);
|
||||
return;
|
||||
}
|
||||
if (typeof config === "string") config = {title:config};
|
||||
let inputId = "modalInput_" + $A.randomString(6);
|
||||
let inputId = "modalInput_" + $J.randomString(6);
|
||||
const onOk = () => {
|
||||
if (typeof config.onOk === "function") {
|
||||
if (config.onOk(config.value, () => {
|
||||
$A.Modal.remove();
|
||||
$J.Modal.remove();
|
||||
}) === true) {
|
||||
$A.Modal.remove();
|
||||
$J.Modal.remove();
|
||||
}
|
||||
} else {
|
||||
$A.Modal.remove();
|
||||
$J.Modal.remove();
|
||||
}
|
||||
};
|
||||
const onCancel = () => {
|
||||
@ -434,7 +434,7 @@
|
||||
config.onCancel();
|
||||
}
|
||||
};
|
||||
$A.Modal.confirm({
|
||||
$J.Modal.confirm({
|
||||
render: (h) => {
|
||||
return h('div', [
|
||||
h('div', {
|
||||
@ -443,11 +443,11 @@
|
||||
fontWeight: '500',
|
||||
marginBottom: '20px',
|
||||
}
|
||||
}, $A.L(config.title)),
|
||||
}, $J.L(config.title)),
|
||||
h('Input', {
|
||||
props: {
|
||||
value: config.value,
|
||||
placeholder: $A.L(config.placeholder),
|
||||
placeholder: $J.L(config.placeholder),
|
||||
elementId: inputId,
|
||||
},
|
||||
on: {
|
||||
@ -455,7 +455,7 @@
|
||||
config.value = val;
|
||||
},
|
||||
'on-enter': (e) => {
|
||||
$A(e.target).parents(".ivu-modal-body").find(".ivu-btn-primary").click();
|
||||
$J(e.target).parents(".ivu-modal-body").find(".ivu-btn-primary").click();
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -464,8 +464,8 @@
|
||||
onOk,
|
||||
onCancel,
|
||||
loading: true,
|
||||
okText: $A.L(config.okText || '确定'),
|
||||
cancelText: $A.L(config.cancelText || '取消'),
|
||||
okText: $J.L(config.okText || '确定'),
|
||||
cancelText: $J.L(config.cancelText || '取消'),
|
||||
});
|
||||
setTimeout(() => {
|
||||
document.getElementById(inputId) && document.getElementById(inputId).focus();
|
||||
@ -477,10 +477,10 @@
|
||||
return;
|
||||
}
|
||||
if (millisecond > 0) {
|
||||
setTimeout(() => { $A.modalConfirm(config) }, millisecond);
|
||||
setTimeout(() => { $J.modalConfirm(config) }, millisecond);
|
||||
return;
|
||||
}
|
||||
$A.Modal.confirm($A.modalConfig(config));
|
||||
$J.Modal.confirm($J.modalConfig(config));
|
||||
},
|
||||
|
||||
modalSuccess(config, millisecond = 0) {
|
||||
@ -488,10 +488,10 @@
|
||||
return;
|
||||
}
|
||||
if (millisecond > 0) {
|
||||
setTimeout(() => { $A.modalSuccess(config) }, millisecond);
|
||||
setTimeout(() => { $J.modalSuccess(config) }, millisecond);
|
||||
return;
|
||||
}
|
||||
$A.Modal.success($A.modalConfig(config));
|
||||
$J.Modal.success($J.modalConfig(config));
|
||||
},
|
||||
|
||||
modalInfo(config, millisecond = 0) {
|
||||
@ -499,10 +499,10 @@
|
||||
return;
|
||||
}
|
||||
if (millisecond > 0) {
|
||||
setTimeout(() => { $A.modalInfo(config) }, millisecond);
|
||||
setTimeout(() => { $J.modalInfo(config) }, millisecond);
|
||||
return;
|
||||
}
|
||||
$A.Modal.info($A.modalConfig(config));
|
||||
$J.Modal.info($J.modalConfig(config));
|
||||
},
|
||||
|
||||
modalWarning(config, millisecond = 0) {
|
||||
@ -510,10 +510,10 @@
|
||||
return;
|
||||
}
|
||||
if (millisecond > 0) {
|
||||
setTimeout(() => { $A.modalWarning(config) }, millisecond);
|
||||
setTimeout(() => { $J.modalWarning(config) }, millisecond);
|
||||
return;
|
||||
}
|
||||
$A.Modal.warning($A.modalConfig(config));
|
||||
$J.Modal.warning($J.modalConfig(config));
|
||||
},
|
||||
|
||||
modalError(config, millisecond = 0) {
|
||||
@ -521,30 +521,30 @@
|
||||
return;
|
||||
}
|
||||
if (millisecond > 0) {
|
||||
setTimeout(() => { $A.modalError(config) }, millisecond);
|
||||
setTimeout(() => { $J.modalError(config) }, millisecond);
|
||||
return;
|
||||
}
|
||||
$A.Modal.error($A.modalConfig(config));
|
||||
$J.Modal.error($J.modalConfig(config));
|
||||
},
|
||||
|
||||
modalAlert(msg) {
|
||||
if (msg === false) {
|
||||
return;
|
||||
}
|
||||
alert($A.L(msg));
|
||||
alert($J.L(msg));
|
||||
},
|
||||
|
||||
//提示
|
||||
messageSuccess(msg) {
|
||||
$A.Message.success($A.L(msg));
|
||||
$J.Message.success($J.L(msg));
|
||||
},
|
||||
|
||||
messageWarning(msg) {
|
||||
$A.Message.warning($A.L(msg));
|
||||
$J.Message.warning($J.L(msg));
|
||||
},
|
||||
|
||||
messageError(msg) {
|
||||
$A.Message.error($A.L(msg));
|
||||
$J.Message.error($J.L(msg));
|
||||
},
|
||||
|
||||
//通知
|
||||
@ -554,17 +554,17 @@
|
||||
} else if (typeof config === "string") {
|
||||
config = {desc: config};
|
||||
}
|
||||
config.title = $A.L(config.title || (typeof config.render === 'undefined' ? '温馨提示' : ''));
|
||||
config.desc = $A.L(config.desc || '');
|
||||
config.title = $J.L(config.title || (typeof config.render === 'undefined' ? '温馨提示' : ''));
|
||||
config.desc = $J.L(config.desc || '');
|
||||
return config;
|
||||
},
|
||||
|
||||
noticeSuccess(config) {
|
||||
$A.Notice.success($A.noticeConfig(config));
|
||||
$J.Notice.success($J.noticeConfig(config));
|
||||
},
|
||||
|
||||
noticeWarning(config) {
|
||||
$A.Notice.warning($A.noticeConfig(config));
|
||||
$J.Notice.warning($J.noticeConfig(config));
|
||||
},
|
||||
|
||||
noticeError(config) {
|
||||
@ -574,7 +574,7 @@
|
||||
duration: 6
|
||||
};
|
||||
}
|
||||
$A.Notice.error($A.noticeConfig(config));
|
||||
$J.Notice.error($J.noticeConfig(config));
|
||||
},
|
||||
});
|
||||
|
||||
@ -718,7 +718,7 @@
|
||||
},
|
||||
|
||||
enableDarkMode() {
|
||||
if (!$A.isChrome()) {
|
||||
if (!$J.isChrome()) {
|
||||
return;
|
||||
}
|
||||
if (this.isDarkEnabled()) {
|
||||
@ -753,5 +753,5 @@
|
||||
}
|
||||
});
|
||||
|
||||
window.$A = $;
|
||||
window.$J = $;
|
||||
})(window);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user