From 806298207d3b851a83025a60224f9cc409a3a5be Mon Sep 17 00:00:00 2001 From: godo Date: Tue, 3 Dec 2024 12:51:47 +0800 Subject: [PATCH 1/2] change restart --- frontend/src/components/chat/ChatMenu.vue | 4 ++-- frontend/src/system/config.ts | 18 +++++++++++------- frontend/src/system/index.ts | 8 +++++--- frontend/src/util/goutil.ts | 19 ++++++++++++------- frontend/vite.config.ts | 3 ++- 5 files changed, 32 insertions(+), 20 deletions(-) diff --git a/frontend/src/components/chat/ChatMenu.vue b/frontend/src/components/chat/ChatMenu.vue index 7dadf44..b499323 100644 --- a/frontend/src/components/chat/ChatMenu.vue +++ b/frontend/src/components/chat/ChatMenu.vue @@ -51,7 +51,7 @@ - + { // 从本地存储中尝试获取配置信息,若不存在则使用默认空对象 const configSetting = localStorage.getItem('GodoOS-config') || '{}'; // 解析配置信息为JSON对象 - let config:any = JSON.parse(configSetting); + let config: any = JSON.parse(configSetting); // 初始化配置对象的各项属性,若本地存储中已存在则不进行覆盖 if (!config.version) { @@ -82,10 +82,10 @@ export const getSystemConfig = (ifset = false) => { if (!config.storePath) { config.storePath = ""; } - if(!config.netPath) { + if (!config.netPath) { config.netPath = ""; } - if(!config.netPort) { + if (!config.netPort) { config.netPort = "56780"; } // 初始化背景设置,若本地存储中已存在则不进行覆盖 @@ -152,7 +152,7 @@ export const getSystemConfig = (ifset = false) => { 'fourthEnd': '254' } } - + // 初始化桌面快捷方式列表,若本地存储中已存在则不进行覆盖 if (!config.desktopList) { config.desktopList = []; @@ -309,9 +309,13 @@ export const setSystemConfig = (config: any) => { }; export const clearSystemConfig = () => { - const storetype = localStorage.getItem('GodoOS-storeType') || 'local'; - localStorage.clear() - localStorage.setItem('GodoOS-storeType', storetype) + const config = getSystemConfig(); + + if (config.userType === 'person') { + const storetype = localStorage.getItem('GodoOS-storeType') || 'local'; + localStorage.clear() + localStorage.setItem('GodoOS-storeType', storetype) + } //localStorage.removeItem('GodoOS-config'); }; // function bin2hex(s: string) { diff --git a/frontend/src/system/index.ts b/frontend/src/system/index.ts index 7d396bf..dbd9df3 100644 --- a/frontend/src/system/index.ts +++ b/frontend/src/system/index.ts @@ -123,10 +123,12 @@ export class System { upgradeStore.onlineMessage(); // upgradeStore.userChatMessage(); }, 3000); + }else{ + setTimeout(() => { + upgradeStore.systemMessage() + }, 6000); } - setTimeout(() => { - upgradeStore.systemMessage() - }, 6000); + } /** diff --git a/frontend/src/util/goutil.ts b/frontend/src/util/goutil.ts index 8a27e0d..597dad5 100644 --- a/frontend/src/util/goutil.ts +++ b/frontend/src/util/goutil.ts @@ -1,4 +1,4 @@ -import { getSystemKey } from "@/system/config"; +import { getSystemConfig } from "@/system/config"; export async function OpenDirDialog() { if ((window as any).go) { return (window as any)['go']['app']['App']['OpenDirDialog'](); @@ -19,12 +19,17 @@ export async function checkUrl(url: string) { } export function RestartApp() { if (!(window as any).go) { - const apiUrl = getSystemKey("apiUrl"); - fetch(apiUrl + "/system/restart").then(() => { - setTimeout(() => { - window.location.reload(); - }, 1000); - }) + const config = getSystemConfig(); + if (config.userType == 'person') { + fetch(config.apiUrl + "/system/restart").then(() => { + setTimeout(() => { + window.location.reload(); + }, 1000); + }) + } else { + window.location.reload(); + } + //window.location.reload(); } else { return (window as any)['go']['app']['App']['RestartApp'](); diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 4c8dc9a..53ba47a 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -43,5 +43,6 @@ export default defineConfig(async () => ({ } }, outDir: '../godo/deps/dist', - } + }, + base: './', })); From c20cffef5fdb8f991968dbfaa55850e67303ec31 Mon Sep 17 00:00:00 2001 From: godo Date: Tue, 3 Dec 2024 15:08:08 +0800 Subject: [PATCH 2/2] add cloud build --- cloud/.gitignore | 1 + cloud/README.md | 29 +++++++++++++++++++++++++++++ cloud/build.sh | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 cloud/README.md create mode 100644 cloud/build.sh diff --git a/cloud/.gitignore b/cloud/.gitignore index 655212e..891e963 100644 --- a/cloud/.gitignore +++ b/cloud/.gitignore @@ -1,3 +1,4 @@ tmp deps/dist deps/*.zip +dist/ diff --git a/cloud/README.md b/cloud/README.md new file mode 100644 index 0000000..42d0208 --- /dev/null +++ b/cloud/README.md @@ -0,0 +1,29 @@ +## 安装帮助 + +### 第一步:安装nodejs + +``` +cd ../frontend +npm i +npm run build +``` +- 打包成功后复制/godo/deps/dist目录下所有文件到cloud/deps/dist目录 + +### 第二步:安装golang环境打包 + +#### linux/mac环境下打包 + +``` +sudo chmod +x build.sh +./build.sh +``` +#### windows环境下打包 + +- 首先安装mingw-w64,进入命令行界面 + +``` +./build.sh +``` + +- 打包成功后每个系统的版本在dist目录下 + diff --git a/cloud/build.sh b/cloud/build.sh new file mode 100644 index 0000000..8aa689e --- /dev/null +++ b/cloud/build.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# 定义要构建的平台 +PLATFORMS=("linux/amd64" "windows/amd64" "darwin/amd64" "linux/arm64" "windows/arm64" "darwin/arm64") + +# 定义版本号 +SCRIPT_VERSION="1.0.0" +# 获取当前脚本的绝对路径 +SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) +for PLATFORM in "${PLATFORMS[@]}"; do + # 分割平台字符串 + OS=$(echo $PLATFORM | cut -d '/' -f 1) + ARCH=$(echo $PLATFORM | cut -d '/' -f 2) + + # 设置后缀 + case $OS in + "windows") SUFFIX=".exe" ;; + *) SUFFIX="" ;; + esac + OUT_PATH="./dist/" + if [ ! -d "$OUT_PATH" ]; then + mkdir "$OUT_PATH" + fi + # 输出文件名 + OUTPUT_FILE="${OUT_PATH}godocloud_${OS}_${ARCH}${SUFFIX}" + + # 设置GOOS和GOARCH环境变量 + export GOOS=$OS + export GOARCH=$ARCH + export GODOTOPTYPE="web" + + # 执行编译命令,并处理可能的错误 + go build -ldflags="-s -w" -o "$OUTPUT_FILE" ./main.go || { echo "编译 $OS/$ARCH 失败,请检查错误并尝试解决。"; continue; } + + echo "编译 $OS/$ARCH 成功,生成文件: $OUTPUT_FILE" +done