Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
liangzhen
/
framework-tools-web
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 3f76f439
authored
Nov 30, 2023
by
Thews
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
20231130wangwansu
1 parent
9abd42a8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
173 additions
and
12 deletions
package.json
public/index.html
src/utils/request.js
src/views/wenDangDemo/index.vue
package.json
View file @
3f76f43
...
...
@@ -8,6 +8,7 @@
},
"dependencies"
:
{
"@onlyoffice/document-editor-vue"
:
"^1.3.0"
,
"axios"
:
"^1.6.2"
,
"core-js"
:
"^3.8.3"
,
"element-ui"
:
"^2.15.14"
,
"jquery"
:
"^3.7.1"
,
...
...
public/index.html
View file @
3f76f43
...
...
@@ -12,10 +12,9 @@
<strong>
We're sorry but
<
%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.
</strong>
</noscript>
<div
id=
"app"
></div>
<
!-- <script type="text/javascript" src="https://documentserver/web-apps/apps/api/documents/api.js"></script> --
>
<
script
type=
"text/javascript"
src=
"http://192.168.0.187:9999/web-apps/apps/api/documents/api.js"
></script
>
<!-- built files will be auto injected -->
</body>
<script
type=
"text/javascript"
src=
"http://192.168.0.187:9999/web-apps/apps/api/documents/api.js"
></script>
<style>
html
,
body
{
height
:
100%
;
...
...
src/utils/request.js
0 → 100644
View file @
3f76f43
import
Vue
from
'vue'
;
import
axios
from
'axios'
;
import
router
from
'../router/index.js'
;
import
{
Message
,
MessageBox
,
Loading
}
from
'element-ui'
;
let
head
=
false
;
axios
.
defaults
.
timeout
=
300000
;
axios
.
defaults
.
baseURL
=
process
.
env
.
VUE_APP_BASE_API
;
// axios.defaults.baseURL = 'http://61.141.221.175:8081';
//http request 拦截器
axios
.
interceptors
.
request
.
use
(
config
=>
{
// MessageBox.alert('<div class="box"><p>这里放图标</p><p>HTML</p></div>',{
// confirmButtonText: '确定',
// center: true,
// cancelButtonClass:"Text",
// dangerouslyUseHTMLString: true
// })
if
(
head
)
{
// if(head.headers){
// config.headers['content-type'] = 'multipart/form-data'
// }else{
// config.headers['content-type'] = 'application/x-www-form-urlencoded'
// }
config
.
headers
[
'content-type'
]
=
'multipart/form-data'
}
else
{
config
.
data
=
JSON
.
stringify
(
config
.
data
);
config
.
headers
[
'content-type'
]
=
'application/json'
}
if
(
config
.
url
==
'/framework/page'
||
config
.
url
==
'/user/page'
||
config
.
url
==
'/activiti/saveModel'
||
config
.
url
==
'/activiti/processList'
||
config
.
url
==
'/activiti/findModelInfoDto'
){
config
.
headers
[
'content-type'
]
=
'application/json'
}
if
(
config
.
url
==
'/processClassification/delete'
){
//||config.url=="/activiti/createModel"
config
.
headers
[
'content-type'
]
=
'application/x-www-form-urlencoded'
}
if
(
config
.
url
!=
'/auth/login'
){
config
.
headers
[
'Authorization'
]
=
sessionStorage
.
getItem
(
'adminToken'
)
||
''
}
return
config
;
},
error
=>
{
return
Promise
.
reject
(
error
);
}
);
//响应拦截器即异常处理
axios
.
interceptors
.
response
.
use
(
response
=>
{
let
code
=
response
.
data
.
code
if
(
code
==
200
)
{
return
response
}
else
if
(
code
==
507
||
code
==
502
)
{
Vue
.
prototype
.
$message
.
error
(
'登录状态过期或者没有token,请重新登录!'
);
sessionStorage
.
clear
()
router
.
push
({
path
:
'/login'
})
console
.
log
(
'507------'
,
response
)
// console.log('未登录')
// Vue.prototype.$message.error(response.data.msg);
}
else
if
(
code
==
500
)
{
if
(
response
.
config
.
url
==
'/approvalTask/queryToDoTasks'
){
console
.
log
(
'流程图获取不到数据'
)
return
;
}
if
(
response
.
config
.
url
==
'/anasz-smart-screen/importExcel/verifyExcelImport'
){
return
response
}
Vue
.
prototype
.
$message
({
message
:
response
.
data
.
msg
,
type
:
'error'
,
customClass
:
'messageIndex_'
});
return
response
}
else
{
// console.log('其他--------',response)
return
response
}
},
err
=>
{
if
(
err
&&
err
.
response
)
{
console
.
log
(
'连接到服务器失败'
)
}
else
{
console
.
log
(
'未知错误'
)
// Message.error('连接到服务器失败')
}
return
Promise
.
resolve
(
err
.
response
)
})
export
function
get
(
url
,
params
=
{},
type
=
false
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
head
=
type
axios
.
get
(
url
,
{
params
:
params
}).
then
(
response
=>
{
if
(
response
){
resolve
(
response
.
data
);
}
})
.
catch
(
err
=>
{
reject
(
err
)
})
})
}
export
function
post
(
url
,
data
=
{},
type
=
false
,
loading
=
true
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
head
=
type
axios
.
post
(
url
,
data
)
.
then
(
response
=>
{
if
(
response
){
resolve
(
response
.
data
);
}
},
err
=>
{
reject
(
err
)
})
})
}
export
function
postDownloadResponse
(
url
,
params
=
{},
type
=
false
,
loading
=
true
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
head
=
type
axios
.
post
(
url
,
params
,{
responseType
:
'blob'
}).
then
(
response
=>
{
if
(
response
)
{
resolve
(
response
);
}
}).
catch
(
err
=>
{
reject
(
err
)
})
})
}
export
function
getOnlyOfficeToken
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
url
=
"http://192.168.0.187:9999/token"
;
// 将此处URL更改为真正的OnlyOffice服务器地址
axios
.
get
(
url
).
then
(
response
=>
{
resolve
(
response
.
data
);
}).
catch
(
error
=>
{
reject
(
error
);
});
});
}
src/views/wenDangDemo/index.vue
View file @
3f76f43
...
...
@@ -9,6 +9,8 @@
<
script
>
import
{
getOnlyOfficeToken
}
from
'@/utils/request.js'
;
export
default
{
name
:
'wenDangDemo'
,
components
:
{
...
...
@@ -24,37 +26,46 @@ export default {
"url"
:
"http://192.168.0.187:9999/example/editor?fileName=new.docx"
},
"documentType"
:
"word"
,
"editorConfig"
:
{
"callbackUrl"
:
"https://example.com/url-to-callback.ashx"
'editorConfig'
:
{
//语言:zh-CN简体中文/en英文
'lang'
:
'zh-CN'
,
//阅读状态 view/edit
'mode'
:
'view'
,
'customization'
:
{
//是否显示插件
'plugins'
:
false
,
},
"callbackUrl"
:
"http://192.168.0.187:9999/url-to-callback.ashx"
},
"token"
:
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.LwimMJA3puF3ioGeS-tfczR3370GXBZMIL-bdpu4hOU"
,
// "token": "CqzsKuP7jlI1aBatn4esS91ysFxDBR",
},
};
},
methods
:
{
gotoOffice
()
{
getOnlyOfficeToken
().
then
(
token
=>
{
console
.
log
(
"只有Office Token:"
,
token
);
// 这里可以对获得的 OnlyOffice Token 进行后续操作
}).
catch
(
error
=>
{
console
.
error
(
"无法获取 OnlyOffice Token:"
,
error
);
});
let
config
=
{
"document"
:
{
"fileType"
:
"docx"
,
"key"
:
"Khirz6zTPdfd7"
,
"title"
:
"new.docx"
,
"url"
:
"http://192.168.0.187:
8081
/example/editor?fileName=new.docx"
"url"
:
"http://192.168.0.187:
9999
/example/editor?fileName=new.docx"
},
"documentType"
:
"word"
,
"editorConfig"
:
{
"callbackUrl"
:
"http
s://example.com
/url-to-callback.ashx"
"callbackUrl"
:
"http
://192.168.0.187:9999
/url-to-callback.ashx"
},
"token"
:
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.LwimMJA3puF3ioGeS-tfczR3370GXBZMIL-bdpu4hOU"
,
};
var
docEditor
=
new
DocsAPI
.
DocEditor
(
"placeholder"
,
config
);
},
onDocumentReady
()
{
console
.
log
(
"Document is loaded"
);
},
}
}
</
script
>
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment