Browse Source

change ie and pwdfile

master
godo 6 months ago
parent
commit
c1889c3946
  1. 3
      CHANGELOG.md
  2. 2
      README.md
  3. 34
      frontend/src/components/builtin/Browser.vue
  4. 4
      frontend/src/system/config.ts
  5. 3
      godo/files/pwdfile.go
  6. 5
      godo/store/ie.go

3
CHANGELOG.md

@ -47,3 +47,6 @@ bug梳理:
2. 新增 权限管理 文件加密 以及远程存储服务端(企业版本)
3. 应用商店重构 陆续会新增php/node/go/java
4. 文档可上传图片
5. 文件搜索功能
6. 应用商店添加我的世界https://mc.163.com/exp/

2
README.md

@ -18,7 +18,7 @@
- 新增ai模型管理,可下载管理ollama模型
- 新增ai助手,可控制整个系统的prompt
- word新增ai优化/续写/纠错/翻译/总结,生成大纲,根据大纲一键创建文章
- markdown更换为更实用的cherry-markdown,绘图,支持导出为思维导图/pdf/长图/md/html格式
- markdown更换为更实用的cherry-markdown,支持draw.io绘图,支持导出为思维导图/pdf/长图/md/html格式
- 修复截图/截屏路径
- 新增文件密码箱(系统设置里),可根据不同文件进行加密存储

34
frontend/src/components/builtin/Browser.vue

@ -13,28 +13,30 @@
<input class="url-input" v-model="urlinput" @keydown.enter="changeUrl" placeholder="Enter URL" />
</div>
<!-- <div class="webframe" v-html="webContent"></div> -->
<iframe
ref="iframeRef"
class="webframe"
:srcdoc="webContent"
frameborder="0"
allowfullscreen
@load="onIframeLoad"
></iframe>
</div>
</template>
<script lang="ts" setup>
import { ref, onMounted, onUnmounted } from 'vue';
import { ref, onMounted, onUnmounted, Ref } from 'vue';
import { getSystemKey } from '@/system/config';
const urlinput = ref('https://godoos.com/');
const webContent = ref('');
const canGoBack = ref(false);
const canGoForward = ref(false);
const iframeRef: Ref<HTMLIFrameElement | null> = ref(null);
async function callApi(endpoint: string) {
const apiUrl = await getSystemKey('apiUrl');
let fetchUrl = `${apiUrl}/ie/${endpoint}?url=${encodeURIComponent(urlinput.value)}`
let fetchUrl = `${apiUrl}/ie/${endpoint}?url=${encodeURIComponent(urlinput.value)}`;
const response = await fetch(fetchUrl);
if (response.ok) {
const data = await response.text();
@ -71,14 +73,40 @@ function changeUrl() {
callApi('navigate');
}
function onIframeLoad() {
if (iframeRef.value) {
let currentUrl = '';
if (iframeRef.value.srcdoc) {
// 使 srcdoc URL
currentUrl = urlinput.value;
} else {
// 使 src contentWindow URL
currentUrl = iframeRef.value.contentWindow?.location.href || '';
}
console.log('Current URL:', currentUrl);
//urlinput.value = currentUrl;
callApi('navigate'); // iframe callApi
updateNavigationButtons();
}
}
function handleIframeMessage(event: MessageEvent) {
if (event.origin !== 'https://your-iframe-origin') return; // origin
const currentUrl = event.data;
console.log('Current URL from iframe:', currentUrl);
urlinput.value = currentUrl;
updateNavigationButtons();
}
onMounted(() => {
window.addEventListener('popstate', updateNavigationButtons);
window.addEventListener('message', handleIframeMessage);
updateNavigationButtons();
callApi('navigate');
});
onUnmounted(() => {
window.removeEventListener('popstate', updateNavigationButtons);
window.removeEventListener('message', handleIframeMessage);
});
</script>

4
frontend/src/system/config.ts

@ -24,7 +24,7 @@ export const getSystemConfig = (ifset = false) => {
}
// 初始化API相关URL,若本地存储中已存在则不进行覆盖
if (!config.apiUrl) {
config.apiUrl = 'http://localhost:56780';
config.apiUrl = 'http://' + window.location.host + ':56780';
}
if (!config.userType) {
config.userType = 'person'
@ -149,7 +149,7 @@ export const getSystemConfig = (ifset = false) => {
}
}
if (!config.ollamaUrl) {
config.ollamaUrl = 'http://localhost:11434'
config.ollamaUrl = 'http://' + window.location.host + ':11434'
}
if (!config.dataDir) {
config.dataDir = ''

3
godo/files/pwdfile.go

@ -44,7 +44,8 @@ func HandleWriteFile(w http.ResponseWriter, r *http.Request) {
return
}
configPwd, ishas := libs.GetConfig("filePwd")
if !ishas {
// 如果不是加密文件或者exe文件
if !ishas || strings.HasPrefix(string(fileData), "link::") {
// 没开启加密,直接明文写入
_, err := newFile.Write(fileData)
if err != nil {

5
godo/store/ie.go

@ -42,6 +42,11 @@ func fetchPageContent(url string) (string, error) {
// 移除 X-Frame-Options 和 Content-Security-Policy 头
resp.Header.Del("X-Frame-Options")
resp.Header.Del("Content-Security-Policy")
html += `<script>
window.onload = function() {
window.parent.postMessage(window.location.href, '*');
};
</script>`
return html, nil
}

Loading…
Cancel
Save