当前文档空间上传图片优化

This commit is contained in:
xiaoqi.cxq 2022-11-13 15:16:46 +08:00
parent 5eb2b2e67a
commit 4e9acad585
5 changed files with 14 additions and 3 deletions

View File

@ -64,10 +64,12 @@ module.exports = (app) => {
// Google Drive action receiver // Google Drive action receiver
app.get('/googleDriveAction', (req, res) => app.get('/googleDriveAction', (req, res) =>
res.redirect(`./app#providerId=googleDrive&state=${encodeURIComponent(req.query.state)}`)); res.redirect(`./app#providerId=googleDrive&state=${encodeURIComponent(req.query.state)}`));
// Serve the static folder with 1 day max-age // Serve the static folder with 30 day max-age
app.use('/themes', serveStatic(resolvePath('static/themes'), { app.use('/themes', serveStatic(resolvePath('static/themes'), {
maxAge: '1d', maxAge: '30d',
})); }));
// Serve empty.js
app.get('/empty.js', (req, res) => res.send(''));
// Serve static resources // Serve static resources
if (process.env.NODE_ENV === 'production') { if (process.env.NODE_ENV === 'production') {

View File

@ -109,11 +109,15 @@ export default modalTemplate({
computed: { computed: {
...mapGetters('workspace', [ ...mapGetters('workspace', [
'currentWorkspace', 'currentWorkspace',
'currentWorkspaceIsGit',
]), ]),
checkedStorage() { checkedStorage() {
return store.getters['img/getCheckedStorage']; return store.getters['img/getCheckedStorage'];
}, },
workspaceImgPath() { workspaceImgPath() {
if (!this.currentWorkspaceIsGit) {
return [];
}
const workspaceImgPath = store.getters['img/getWorkspaceImgPath']; const workspaceImgPath = store.getters['img/getWorkspaceImgPath'];
return Object.keys(workspaceImgPath || {}); return Object.keys(workspaceImgPath || {});
}, },

View File

@ -28,6 +28,10 @@ export default {
} }
// 判断是否文档空间路径 // 判断是否文档空间路径
if (currStorage.type === 'workspace') { if (currStorage.type === 'workspace') {
// 如果不是git仓库 则提示不支持
if (!store.getters['workspace/currentWorkspaceIsGit']) {
return { error: '暂无已选择的图床!' };
}
const path = getImagePath(currStorage.sub, imgFile.type); const path = getImagePath(currStorage.sub, imgFile.type);
// 保存到indexeddb // 保存到indexeddb
const base64 = await utils.encodeFiletoBase64(imgFile); const base64 = await utils.encodeFiletoBase64(imgFile);

View File

@ -69,7 +69,7 @@ export default {
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
script.onload = resolve; script.onload = resolve;
script.onerror = reject; script.onerror = reject;
script.src = `https://g.alicdn.com/sd/baxia-entry/index.js?${Date.now()}`; script.src = `/empty.js?${Date.now()}`;
try { try {
document.head.appendChild(script); // This can fail with bad network document.head.appendChild(script); // This can fail with bad network
timeout = setTimeout(reject, networkTimeout); timeout = setTimeout(reject, networkTimeout);

View File

@ -111,6 +111,7 @@ export default {
* https://developers.google.com/identity/protocols/OpenIDConnect * https://developers.google.com/identity/protocols/OpenIDConnect
*/ */
async startOauth2(scopes, sub = null, silent = false) { async startOauth2(scopes, sub = null, silent = false) {
await networkSvc.getServerConf();
const clientId = store.getters['data/serverConf'].googleClientId; const clientId = store.getters['data/serverConf'].googleClientId;
// Get an OAuth2 code // Get an OAuth2 code